Greasy Fork

Greasy Fork is available in English.

U2种子备份查询

在页面下载旁加入图标,可一键发送请求。

当前为 2020-10-28 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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
// ==/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('<a href="sendmessage.php?receiver='+userid+'#'+id+'" target="view_window"><img src="https://raw.githubusercontent.com/kysdm/u2_share_js/main/img/drive_2020q4_48dp.png" style="padding-bottom: 2px; width:16px;height:16px;" alt="request" title="发送请求"></a>');
                }
                else if (Id_Data != -1) {
                    GstaticIco = $(this).find('td.embedded')[1];
                    $(GstaticIco).width(55); //设置列宽
                    $(GstaticIco).prepend('<img src="https://raw.githubusercontent.com/kysdm/u2_share_js/main/img/drive_2020q4_48dp.png" style="padding-bottom: 2px; width:16px;height:16px; filter: grayscale(100%);" alt="request">');
                }
            })
        }
        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('&nbsp;<a class="index" href="sendmessage.php?receiver='+userid+'#'+id+'" title="查询网盘备份">[GD]</a>');
            }
            else if (Id_Data != -1) {
                $("td.rowfollow:first").append('&nbsp;<div class="gdindex" title="当前种子做种良好" style="display: inline-block; text-decoration: none; font-weight: bold" >[GD]</div>');
            }
    
        }
    }
    if (window.location.href.indexOf("//u2.dmhy.org/sendmessage.php") != -1 ){
        $("td.rowfollow > input[type=text]").val("#request#");
        if (email === ''){email = '请输入您的谷歌邮箱!'}
        $(".bbcode").val('{ "id":"'+window.location.href.split("#")[1]+'" , "email":"'+email+'" }');
}
})($);