javascript Rutracker Magnet +追踪器加入GreaseMonkey

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript Rutracker Magnet +追踪器加入GreaseMonkey相关的知识,希望对你有一定的参考价值。

// ==UserScript==
// @name        Rutracker.org Magnet URLs
// @namespace   rutrackerorg-magnet-urls
// @description Transforms torrent hash into a magnet url
// @include     https://rutracker.org/*
// @include     https://rutracker.cr/*
// @include     https://rutracker.net/*
// @include     https://rutracker.nl/*
// @include     http://rutrackerripnext.onion/*
// @version     9
// @grant       none
// ==/UserScript==

// No longer using udp://tracker.opentrackr.org:1337/announce - it has hash blacklists
// No longer using udp://open.demonii.com:1337 - stopped operation
var trackers = [
    "udp://tracker.coppersurfer.tk:6969/announce",
    "udp://tracker.leechers-paradise.org:6969/announce",
    "udp://tracker.internetwarriors.net:1337/announce",
    "udp://exodus.desync.com:6969/announce",
    "udp://tracker.openbittorrent.com:80/announce",
    "udp://tracker.sktorrent.net:6969/announce",
    "udp://tracker.zer0day.to:1337/announce",
    "udp://tracker.pirateparty.gr:6969/announce"
]

if (window.BB.IS_GUEST) {
    var e = document.getElementsByClassName('magnet-link')[0];
    
    if (e) {
        var magnet_link = e.getAttribute("href");
        var hash = magnet_link.match(/^magnet:\?xt=urn:btih:([0-9A-F]{40})&tr=.*/)[1];
        
        if (hash) {
            
            var rutracker_tracker = decodeURIComponent(magnet_link.match(/.*\&tr=(.*)$/)[1]);
            trackers.unshift(rutracker_tracker);
        
            var urlencoded_trackers = trackers.map(function(tracker) {
                return "&tr=" + encodeURIComponent(tracker);
            });
            
            e.innerText = hash;
            e.innerHTML = "<a href='magnet:?xt=urn:btih:" + hash + urlencoded_trackers.join('') + "'>" + hash + "</a>";
        }
    }
}
else {
    var e = document.getElementById("tor-hash");

    if (e) {
        var hash = e.innerText;
    
        if (/^[0-9A-F]{40}$/.test(hash)) {
            
            var parent_href = document.getElementsByClassName('med magnet-link magnet-link-16')[0];
            var magnet_link = decodeURIComponent(parent_href.getAttribute("href"));
            var rutracker_tracker = decodeURIComponent(magnet_link.match(/.*\&tr=(.*)$/)[1]);
            
            if(rutracker_tracker)
                trackers.unshift(rutracker_tracker);

            var urlencoded_trackers = trackers.map(function(tracker) {
                return "&tr=" + encodeURIComponent(tracker);
            });
        
            e.innerHTML = "<a href='magnet:?xt=urn:btih:" + hash + urlencoded_trackers.join('') + "'>" + hash + "</a>";
            //e.innerHTML = rutracker_tracker;
        }
    }
}

以上是关于javascript Rutracker Magnet +追踪器加入GreaseMonkey的主要内容,如果未能解决你的问题,请参考以下文章

通过时间反向传播,理解

使用磁传感器

将种子添加到来自 cron 的传输

VisibleDeprecationWarning:从不规则的嵌套序列创建一个 ndarray

ru tracker可以在国内用吗

快速切换标签时,Shiny Plotly Plot 卡住了