// ==UserScript==
// @name All Magnet to BT
// @version 0.1.4.4
// @description 找出页面的磁力链,给出对应的种子下载地址//Find out all magnet links in current page and get their torrent download URLs. In theory, it supports many sites. you can add your favorites by //@include
// @author wanghsinche @ 201509
// @include https://btdigg.org/search*
// @include http://btdigg.org/search*
// @include http://*.jav*.*
// @include https://*.jav*.*
// @include http://www.torrentkitty.*/search*
// @require http://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js
// @run-at document-end
// @namespace https://greasyfork.org/users/326
// @downloadURL https://update.sleazyfork.org/scripts/12156/All%20Magnet%20to%20BT.user.js
// @updateURL https://update.sleazyfork.org/scripts/12156/All%20Magnet%20to%20BT.meta.js
// ==/UserScript==
function getAllMagnet(rawMagnets) {
var magnetNum = rawMagnets.length;
var rawString = "";
var rex = new RegExp("\\w{40}", 'g'); //regular expression to match all 40 bit code
if (magnetNum !== 0) { //prase all magnet herf nodes into string
for (var i = 0; i < magnetNum; i++) {
rawString += rawMagnets[i].toString();
}
}
return rawString.match(rex); //return the code list
}
function code2down1(str) {
var s1, s2, btih, torrentURL;
btih = str.toLocaleUpperCase();
s1 = btih.substr(0, 2);
s2 = btih.substr(str.length - 2);
torrentURL = "http://bt.box.n0808.com/" + s1 + "/" + s2 + "/" + btih + ".torrent";
return torrentURL;
}
function code2down2(str) {
var btih, torrentURL;
btih = str.toLocaleUpperCase();
torrentURL = "http://torcache.net/torrent/" + btih + ".torrent";
return torrentURL;
}
function code2down3(str) {
var btih, torrentURL;
btih = str.toLocaleUpperCase();
torrentURL = "http://www.torrent.org.cn/Home/torrent/download.html?hash=" + btih;
return torrentURL;
}
function include(Things,obj) {
for (var i = Things.length - 1; i >= 0; i--) {
if ($(Things[i]).attr('href')===$(obj).attr('href')){
return true;
}
}
}
function setCss(){
$('head').append('');
}
function getAllTorrentsNew() {
var rawnodes = $('a[href^="magnet"]').get();
var nodes = [];
var codeList = [];
var listLen = 0;
for (var i = 0; i 0||i>20){
window.clearInterval(t);
getAllTorrentsNew();
}else{
i++;
}
}, 500);