Greasy Fork

TPB Torrent Downloads Fork

Piratebay download via torrents

当前为 2017-06-28 提交的版本,查看 最新版本

// ==UserScript==
// @name         TPB Torrent Downloads Fork
// @version      0.5
// @description  Piratebay download via torrents
// @include      *thepiratebay.se/*
// @include      *thepiratebay.org/*
// @require        https://code.jquery.com/jquery-latest.min.js
// @namespace https://greasyfork.org/users/59385
// ==/UserScript==

(function() {
    'use strict';

    var user_preferred_cache = 'cache_2';

    var preferred_caches = {
        cache_1: {
            name: 'Torcache',
            url: 'https://torcache.net/torrent/',
            end: '.torrent'
        },
        cache_2: {
            name: 'Torrage',
            url: 'http://torrage.info/torrent.php?h=',
            end: ''
        },
        cache_3: {
            name: 'iTorrents',
            url: 'http://itorrents.org/torrent/',
            end: '.torrent'
        }
    };

    $('a[href^="magnet:"]').each(function() {
        var hash = $(this).attr('href').split(":")[3];
        hash = hash.split("&")[0];
        $(this).after('<br/><a href="'+preferred_caches[user_preferred_cache].url+hash.toUpperCase()+preferred_caches[user_preferred_cache].end+'" title="Download using torrent file"><img src="http://www.tech-faq.com/wp-content/uploads/2009/02/torrent.png" style="width: 12px; height: 12px;" alt="Torrent link"></a>');
    });
})();