// ==UserScript== // @name 种子列表过滤与认领 // @namespace https://greasyfork.org/zh-CN/scripts/ // @version 0.2 // @license GPL-3.0 License // @description 在种子列表页中,过滤官种和保种中的种子,新增一列快速认领 // @author ccf2012 // @icon https://pterclub.com/favicon.ico // @grant GM_setClipboard // @grant GM_xmlhttpRequest // @require https://code.jquery.com/jquery-3.6.0.min.js // @match https://pterclub.com/torrents.php* // @match https://pterclub.com/officialgroup* // @downloadURL none // ==/UserScript== var config = [ { host: "pterclub.com", eleTorTable: "#torrenttable", eleCurPage: "#outer > table > tbody > tr > td > p:nth-child(4) > font", eleTorList: "#torrenttable > tbody > tr", eleTorItem: "td:nth-child(2) > table > tbody > tr > td:nth-child(2) > div > div:nth-child(1) > a", eleTorItemSize: "td:nth-child(5)", eleTorItemSeednum: "td:nth-child(6)", eleTorItemAdded: "td:nth-child(4) > span", useTitleName: true, eleSeeding: "img.progbargreen", eleIntnTag: "a.chs_tag-gf", eleDownLink: "td:nth-child(2) > table > tbody > tr > td:nth-child(5) > a", eleCatImg: "td:nth-child(1) > a:nth-child(1) > img", }, ] var THISCONFIG = config.find((cc) => window.location.host.includes(cc.host)); function addFilterPanel() { var torTable = $("#torrenttable"); var donwnloadPanel = `
` torTable.before(donwnloadPanel); } var onClickFilterList = (html) => { $("#process-log").text("处理中..."); let torlist = $(html).find(THISCONFIG.eleTorList); for (let index = 1; index < torlist.length; ++index) { let element = torlist[index]; let intnTag = $(torlist[index]).find(THISCONFIG.eleIntnTag).length > 0; var barGreen = torlist[index].querySelector(THISCONFIG.eleSeeding); // debugger; $(element).show() if ($("#intn_tor").is(":checked") && !intnTag) { $(element).hide() } if ($("#seeding").is(":checked") && !barGreen) { $(element).hide() } } $("#process-log").text("完成..."); }; function onClickDownloadFiltered(html) { $("#process-log").text('处理中...') let torlist = $(html).find(THISCONFIG.eleTorList); var resulttext = ''; for (let index = 1; index < torlist.length; ++index) { if ($(torlist[index]).is(":visible")) { var hrefele = torlist[index].querySelector(THISCONFIG.eleDownLink) if (hrefele) { resulttext += hrefele.href + '\n' } } } GM_setClipboard(resulttext, 'text'); $("#process-log").text('下载链接 已拷贝在剪贴板中'); } function addAdoptColumn(html) { // const torTable = $(THISCONFIG.eleTorTable); const idregex = /id=(\d+)/; var torlist = $(html).find(THISCONFIG.eleTorList); for (let index = 0; index < torlist.length; ++index) { let element = torlist[index]; let item = $(element).find(THISCONFIG.eleTorItem); let href = item.attr("href"); if (href) { let torid = href.match(idregex); if (torid) { let sizeele = $(element).find(THISCONFIG.eleTorItemSize); $(element).append(' 认领'); } } else { $(element).append(' 认领种子 '); } } } (function () { "use strict"; if (THISCONFIG) { addAdoptColumn(document); addFilterPanel(); $("#btn-filterlist").click(function () { onClickFilterList(document); }); $("#btn-downloadfiltered").click(function () { onClickDownloadFiltered(document); }); } })();