// ==UserScript== // @name U2种子备份查询 // @namespace https://u2.dmhy.org/ // @version 1.7 // @description 在页面下载旁加入图标,支持一键发送请求。 // @author McHobby & kysdm // @grant GM_setValue // @grant GM_getValue // @grant GM_xmlhttpRequest // @match *://u2.dmhy.org/torrents.php* // @match *://u2.dmhy.org/sendmessage.php* // @match *://u2.dmhy.org/details.php* // @require https://cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.min.js // @connect cdn.jsdelivr.net // @downloadURL none // ==/UserScript== (async ($) => { 'use strict'; const gdListUrl = 'https://cdn.jsdelivr.net/gh/kysdm/u2_share@main/u2list.txt'; const date = new Date().getDate(); let gdListObj = GM_getValue('u2_gd_list', null); if (gdListObj === null || gdListObj.date !== date) { await new Promise((resolve, reject) => { GM_xmlhttpRequest({ method: 'GET', url: gdListUrl, onload: r => r.status < 400 ? resolve(r.responseText) : reject(r.status), onerror: r => reject(r.status) }) }) .then(g => { gdListObj = { date: date, list: g.trim().split('\n') }; GM_setValue('u2_gd_list', gdListObj); }) .catch(e => { console.log('下载列表发生错误,HTTP状态码[' + e + ']。'); }) } const gdList = gdListObj.list; const Uploaders = 7; const userid = 45940; // 勿动 var GstaticIco; const CurrentUrl = window.location.href; if (CurrentUrl.indexOf("//u2.dmhy.org/torrents.php") != -1) { new torrents(); } else if (CurrentUrl.indexOf("//u2.dmhy.org/details.php") != -1) { new torrents(); new details(); } else if (CurrentUrl.indexOf('//u2.dmhy.org/sendmessage.php?receiver=' + userid + '#') != -1) { new sendmessage(); } function torrents() { const torrentTable = $('table.torrents') torrentTable.find('> tbody > tr:not(:first-child)').each(function () { const tds = $(this).find('> td'); const SeederNum = parseInt($(tds[tds.length - 3]).text()); const idLink = $(this).find("[href*='id=']")[0].getAttribute('href'); const id = parseInt(idLink.substr(idLink.indexOf('id=') + 3)); const Id_Data = gdList.findIndex((value) => value == id); if (Id_Data != -1 && SeederNum <= Uploaders) { GstaticIco = $(this).find('td.embedded')[1]; $(GstaticIco).width(55); $(GstaticIco).prepend('request'); } else if (Id_Data != -1) { GstaticIco = $(this).find('td.embedded')[1]; $(GstaticIco).width(55); $(GstaticIco).prepend('request'); } }) } function details() { const id = $("#outer > h3").text().split(/\(#(\d+?)\)/, 2)[1] const SeederNum = $("#peercount").text().match(/^(\d+?)\s?(?:个做种者|個做種者|Seeders|Раздающих)/i)[1] const Id_Data = gdList.findIndex((value) => value == Number(id)); if (Id_Data != -1 && SeederNum <= Uploaders) { $("td.rowfollow:first").append(' [GD]'); } else if (Id_Data != -1) { $("td.rowfollow:first").append(' 
[GD]
'); } } function sendmessage() { const email = $.cookie('gd_email'); $("td.rowfollow > input[type=text]").val("#request#"); $(".bbcode").val('{ "id":"' + CurrentUrl.split("#")[1] + '" , "email":"' + email + '" }'); $('td.toolbox').append('记住邮箱地址'); $('#compose').attr('onsubmit', 'return checkemail();') $('body').append( "" ) } })($);