// ==UserScript== // @name GGn Additional Filters // @namespace http://tampermonkey.net/ // @version 1.0 // @description try to take over the world :) // @author BestGrapeLeaves // @match https://gazellegames.net/upload.php* // @match https://gazellegames.net/torrents.php* // @icon https://i.imgur.com/a6TlZtE.png // @license MIT // @downloadURL https://update.greasyfork.icu/scripts/451499/GGn%20Additional%20Filters.user.js // @updateURL https://update.greasyfork.icu/scripts/451499/GGn%20Additional%20Filters.meta.js // ==/UserScript== // yottabyte games when? const units = ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'] function humanizedToBytes(str) { const [numString, unit] = str.split(' ') const size = parseFloat(numString) const multiplier = Math.pow(1000, units.indexOf(unit) + 1) return size*multiplier } function filterTorrents(filterMethod, actionMethod) { const groups = {}; $(`#torrent_table > tbody > tr`).show(); $(`#torrent_table > tbody > tr`).each(function() { const classList = [...$(this).prop("classList")]; // Find group id const groupMatch = classList.map(c => c.match(/^groupid_(\d+)$/)).filter(m => m)[0]; if (!groupMatch) { return; } const groupId = groupMatch[1]; // Find edition id (it's just numbers increasing or even empty string) const editionMatch = classList.find(c => c.startsWith(`edition_${groupId}_`)); if(editionMatch === undefined) { return; } const editionId = editionMatch.replace(`edition_${groupId}_`, ''); // add if (!groups[groupId]) { groups[groupId] = {}; } if (!groups[groupId][editionId]) { groups[groupId][editionId] = [] } groups[groupId][editionId].push(this); }); let totalGroupsHidden = 0; let totalEditionsHidden = 0; let totalTorrentsHidden = 0; Object.entries(groups).forEach(([groupId, editions]) => { let editionsHidden = 0; Object.entries(editions).forEach(([editionId, torrents]) => { let torrentsHidden = 0; torrents.forEach(torrent => { if (!filterMethod($(torrent))) { torrentsHidden++; actionMethod($(torrent)); } }); const editionNum = Number(editionId); if (torrentsHidden === torrents.length) { editionsHidden++; if (editionNum > 0) { // Hide edition title as well const edition = $(`#torrent_table > tbody > tr.groupid_${groupId}`).has('td.edition_info').eq(editionNum - 1); actionMethod(edition) } } totalTorrentsHidden += editionsHidden; }); if (editionsHidden === Object.entries(editions).length) { totalGroupsHidden++; const group = $(`#torrent_table > tbody > tr.group_${groupId}`); actionMethod(group) } totalEditionsHidden += editionsHidden; }); return {totalGroupsHidden, totalEditionsHidden, totalTorrentsHidden}; } (function() { 'use strict'; console.log('targetinsert', $('#torrentbrowse > form[name="filter"] > div.filter_torrents > .box > table:first-child')) $('#torrentbrowse > form[name="filter"] > div.filter_torrents').append( `
Minimum Size: | ||
Maximum Size: |