// ==UserScript==
// @name U2种子备份查询
// @namespace https://u2.dmhy.org/
// @version 0.4
// @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?receiver=*
// @match *://u2.dmhy.org/details.php*
// @connect raw.githubusercontent.com
// @downloadURL none
// ==/UserScript==
// debugger;(async ($) => {
(async ($) => {
'use strict'
var email = '' // 此处可写入谷歌邮箱,这样发送请求的时候就不用手动填写了
var userid = 45940 // 勿动
if (window.location.href.indexOf("//u2.dmhy.org/torrents.php") != -1 | window.location.href.indexOf("//u2.dmhy.org/details.php") != -1){
const gdListUrl = 'https://raw.githubusercontent.com/kysdm/u2_share_js/main/u2list.txt';
let gdListObj = GM_getValue('u2_gd_list', null);
if (gdListObj === null || gdListObj.url !== gdListUrl) {
const gdListRaw = await new Promise((resolve, reject) => {
GM_xmlhttpRequest({
method: 'GET',
url: gdListUrl,
onload: r => resolve(r.responseText),
onerror: r => reject(r)
})
})
gdListObj = {
url: gdListUrl,
list: gdListRaw.trim().split('\n')
}
GM_setValue('u2_gd_list', gdListObj)
}
const gdList = gdListObj.list;
//console.log(gdList)
const Uploaders = 3;
var GstaticIco;
if (window.location.href.indexOf("//u2.dmhy.org/torrents.php") != -1 ){
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('
');
}
else if (Id_Data != -1) {
GstaticIco = $(this).find('td.embedded')[1];
$(GstaticIco).width(55); //设置列宽
$(GstaticIco).prepend('
');
}
})
}
else if (window.location.href.indexOf("//u2.dmhy.org/details.php") != -1 ){
const id = $("#outer > h3").text().split(/\(#(\d+?)\)/, 2)[1]
const SeederNum = $("#peercount").text().split(/个(?:做种|下载)者\s?\|?\s?/, 2)[0]
//const SeederNum = Peer[0]
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('