// ==UserScript==
// @name nCore - makeup
// @namespace https://github.com/Victoare/ncore-makeup
// @version 0.5.6
// @description Ncore púder és szájfény
// @author Victoare
// @match https://ncore.pro/torrents.php*
// @downloadURL https://raw.githubusercontent.com/Victoare/ncore-makeup/main/makeup.user.js
// @updateURL https://raw.githubusercontent.com/Victoare/ncore-makeup/main/makeup.user.js
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js
// @grant GM_log
// ==/UserScript==
/* DEVNOTE:
Due to greasemonkey, it needs the "require-jquery", but with it added, the page's fancybox stopped working on chrome
needed to add "grant GM_log" which somehow fixes the issue.
*/
(function () {
'use strict';
// ===========================================================================================
// Extract torrent info
// ===========================================================================================
var torrents = [];
var $rowDivs = $('.box_torrent_all>div[style!="clear:both;"]');
var getImdbID = function ($row) {
var attr = $row.find('.infolink').attr('href');
if(!attr) return '';
var match = attr.match(/\/(ev\d{7}\/\d{4}(-\d)?|(ch|co|ev|nm|tt)\d{7,})/i);
if(!(match && match.length)) return '';
return match[1];
}
var getCoverImg = function ($row) {
var attr = $row.find('img.infobar_ico').attr('onmouseover');
return attr ? attr.match(/'([^']*)'/)[1] : '';
}
var getTorrentId = function ($row) {
var attr = $row.find('a[onclick^="torrent("]').attr('onclick');
return attr ? attr.match(/\((\d*)\)/)[1] : '';
}
var getUploadDate = function ($row) {
var val = $row.find('.box_feltoltve2').html()
var p = val.split(/-|
|:/g).map((n)=>parseInt(n,10));
return new Date(p[0], p[1]-1, p[2], p[3], p[4], p[5]).getTime() / 1000; // unix timestamp like 1649433945
}
var hasIMDBid = false;
for (var i = 0; i < $rowDivs.length - 1; i += 2) {
var $mainRow = $($rowDivs[i]);
var imdbId = getImdbID($mainRow);
hasIMDBid |= imdbId.length>0;
torrents.push({
imdbId,
torrentId: getTorrentId($mainRow),
coverImg: getCoverImg($mainRow),
uploaded: getUploadDate($mainRow),
$mainRow: $mainRow, // .box_torrent
detailRow: $rowDivs[i + 1], // .torrent_lenyilo v. .torrent_lenyilo2
});
}
if(!hasIMDBid) return; // if results contains no IMDB ID then don't alter the table
// ===========================================================================================
// CSS overload
// ===========================================================================================
// extract theme from stylesheet path
var theme = $('link[rel="stylesheet"][href^="https://static.ncore.pro/styles/"]').attr('href').match(/\/styles\/([^\/]*)\/style_/)[1];
$('body').addClass('theme_' + theme);
var qs = (new URL(document.location)).searchParams; // https://ncore.pro/torrents.php?miszerint=name&hogyan=DESC&tipus=hd_hun&mire=202&miben=name
var qsOrderBy = qs.get("miszerint");
var qsOrderDesc = qs.get("hogyan") != 'ASC';
var specOrder = (!qsOrderBy || qsOrderBy=='fid') && qsOrderDesc; //dátum szerint, csökkenő, de csoporton belül a legrégebbi dátum szerint, így előre kerülnek az új feltöltések
// overload some styles
var myStyle = document.createElement('style');
document.head.appendChild(myStyle);
var cssMod = myStyle.sheet;
cssMod.insertRule('.ajaxGetOtherVersions { cursor: pointer; float: right; border: 1px solid #838383; padding: 2px; background-color: #3c869a; font-weight: bold; }');
// table header
cssMod.insertRule('.box_borito { width: 164px; }');
cssMod.insertRule('.box_nev { width: 343px; }');
// table items
cssMod.insertRule('.box_borito_img { width: 182px; border: 1px solid #828282; float: left; margin-top: 1px; min-height: 32px; text-align: center;}');
cssMod.insertRule('.box_borito_img img { width: 182px; }');
cssMod.insertRule('.box_nev2 { width: 358px; height: 32px; }');
cssMod.insertRule('.box_nagy, .box_nagy2 { width: 659px; float: right; }');
cssMod.insertRule('.box_nagy.imdbinfo, .box_nagy2.imdbinfo { width:701px; padding:6px; height:auto; }');
cssMod.insertRule('.torrent_txt, .torrent_txt2 { text-overflow: ellipsis; width: 293px; overflow:hidden;}'); //313px for single icon, 293 for double
cssMod.insertRule('.torrent_txt a, .torrent_txt2 a { text-overflow: ellipsis; }');
cssMod.insertRule('.box_borito { width: 164px; }');
cssMod.insertRule('.box_nev { width: 255px; }');
cssMod.insertRule('.box_alap_img { float: right; }');
cssMod.insertRule('.box_torrent_all { width: 900px; }');
cssMod.insertRule('.torrent_lenyilo, .torrent_lenyilo2 { width: 715px; float: right; }');
cssMod.insertRule('.torrent_lenyilo_lehetoseg { width: 715px; }');
cssMod.insertRule('.torrent_lenyilo .torrent_lenyilo_tartalom { width: 693px; }');
cssMod.insertRule('.torrent_lenyilo2 .torrent_lenyilo_tartalom { width: 693px; }');
cssMod.insertRule('.torrent_leiras { width: 666px; }');
cssMod.insertRule('.hr_stuff { width: 693px; }');
cssMod.insertRule('.torrent_lenyilo_tartalom .banner { zoom: 50%; }');
// theme specific overrides
cssMod.insertRule('.theme_brutecore .box_nagy, .theme_brutecore .box_nagy2 { width: 650px; padding-left: 0; }');
cssMod.insertRule('.theme_brutecore .box_alap_img { position: inherit; }');
cssMod.insertRule('.theme_brutecore .torrent_lenyilo_lehetoseg { width: 700px; }');
cssMod.insertRule('.theme_brutecore .torrent_konyvjelzo2 { margin: 16px 5px 0 0; }');
// ===========================================================================================
// Modify table header, Add cover, remove uploader column
// ===========================================================================================
$('.box_alcimek_all').prepend(`
Borító |
');
$.get("ajax.php?action=other_versions&id=" + id + "&fid=" + torrentData.torrentId + "&details=1")
.fail(function () {
$infoBar.find('.ajaxGetOtherVersions').html('Más verziók keresése');
})
.done(function (data) {
var $data = $(data);
var html = $data.find('.box_torrent_mini2').map(function () {
var $itm = $(this);
var torrentID = $itm.find('a[href^="torrents.php?action=details&id="]').attr('href').match(/id=(\d+)/)[1];
if (torrentsOnScreen.indexOf(torrentID) > -1) return '';
var title = $itm.find('.box_txt_ownfree a').attr('title');
return `