磁力云播

找出页面的磁力链,添加云播接口

Mint 2016.07.13.. Lásd a legutóbbi verzió

// ==UserScript==
// @name         磁力云播
// @version      1.3
// @description  找出页面的磁力链,添加云播接口
// @author       磁力云播
// @icon           http://findicons.com/icon/download/199777/adobe_media_player/128/ico
// @include      https://btdigg.org/search*
// @include      http://btdigg.org/search*
// @include      http://www.mp4ba.com/*
// @include      http://*.jav*.*
// @include      https://*.jav*.*
// @include      http://www.torrentkitty.*/search*
// @include      http://*.bt*.*
// @include      https://*.bt*.*
// @include      http://*.cili*.*
// @include      https://*.cili*.*
// @require      http://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js
// @run-at      document-end
// @namespace https://greasyfork.org/users/54472
// ==/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 = "data:text/html,<img src=\"http://img.lanrentuku.com/img/allimg/1212/5-121204193R0-50.gif\"/><meta http-equiv=\"refresh\" content=\"0.1;url=http://xabb360.net/?m=Pan&a=ShowBt&hash=magnet:?xt=urn:btih:" + btih + "\">";
	return torrentURL;
}

function code2down2(str) {
	var btih, torrentURL;
	btih = str.toLocaleUpperCase();
	torrentURL = "http://www.ttwanda.com/go.php?url=https://www.ttwanda.com/player/v.php?url=magnet:?xt=urn:btih:" + btih;
	return torrentURL;
}
function code2down3(str) {
	var btih, torrentURL;
	btih = str.toLocaleUpperCase();
    torrentURL = "http://www.997m.com/btago_player/player.php?td=3&u=magnet:?xt=urn:btih:" + 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('<style>.color1{background-color:#FFEB3B}.color2{background-color:#F44336}.color3{background-color:#4CAF50}a.wxz-a{ background-repeat: no-repeat;background-position: center;    display: inline-block;margin-left:5px;height: 20px;width: 20px;background-size: 20px;border-radius: 50%;background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAZCAYAAADE6YVjAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAInSURBVEhLpdXNq05BAMfx2VqQ17wkirIhRF2KyMY/YK2kZIXEComSl9gJK29FURShlJ2UlaRkZUFEiLy/Fr7faeZ27rlznnPufX71qTNzzsyc58wzM6Fj5uEAHuIHvuMB9mEO+spaXMVH/GvwAZexBiPKbFxD7ugbbuMItidHcQc/kZ9zsBlojW/0FjZ6iW2YiqbY6U68QW6zHI1ZjV/w4YuYhK7xRfy0tv2KAQzLTLyHDx2zYpQ5Cft4hSlWVHML3rwUS/3lBuzLORqM82Dla4yzopIJ2IoFsdQtk5G/yjIrzHVYsSWWhmYDvOdcHcZ4dMku2O6CBReTEyXfup7N8OHsOTaiLdPhi72zcBA2dh2Usgl/k+pgd7EKvXIPPhsep4tDFgpxkGrndWcxC6Uch8+EP+nCRVdK2yByL1uKevbA++F3uuhnEP+V81HP4CCP0oX/nFJ6DeJXcOFORCkn4HNhf7pwsyulaeJvYhF65T7iIE7aF/hdS3tV/S/8BOvQFrcpf6kbZ8wV2MGOWBqa9fDeZ+zGGHSJB5rtzsUSWQkrXDj17zsWLr65sdQtLsRPsM8lVuTkbdrDqt84v/Z1PpYq8Tzwr+hNt+vRxs9jH89Q2qbijukeln9Rp6M0xSPbrcm2nvsL0RiPzhfwYbdrd1M7aIobrJOc5+ApFqM10+DxayO5RtzsXFx7k1PI6yA7g5Ec2TEr4OR5lFY7q/JXn0bxTA8hhP9kB8zYIgcU7QAAAABJRU5ErkJggg==");vertical-align: middle;}</style>');
}

function getAllTorrentsNew() {
	var rawnodes = $('a[href^="magnet"]').get();
	var nodes = [];
	var codeList = [];
	var listLen = 0;
	for (var i = 0; i <rawnodes.length; i++) {
		if(!include(nodes,rawnodes[i])){
			nodes.push(rawnodes[i]);
		}
	};
	codeList = getAllMagnet(nodes);
	listLen = codeList.length;
    setCss();
   
	if (listLen !== 0) { //prase all magnet herf nodes into string
		for (var i = 0; i < listLen; i++) {
            $(nodes[i]).after($(nodes[i]).clone().addClass('wxz-a color3').empty().attr("target","_blank").attr("title","download torrent from torrent.org" ).attr("href", code2down3(codeList[i])));
			$(nodes[i]).after($(nodes[i]).clone().addClass('wxz-a color1').empty().attr("target","_blank").attr("title","download torrent from bt.box" ).attr("href", code2down1(codeList[i])));
			$(nodes[i]).after($(nodes[i]).clone().addClass('wxz-a color2').empty().attr("target","_blank").attr("title","download torrent from torcache" ).attr("href", code2down2(codeList[i])));
		}
	}
     $('.wxz-a').css('b','d');
}


function getAllTorrents() {
	var nodes = $('a[href^="magnet"]');
	var codeList = [];
	var listLen = 0;
	var i = 0;
	codeList = getAllMagnet(nodes);
	listLen = codeList.length;
	if (listLen !== 0) { //prase all magnet herf nodes into string
		for (i = 0; i < listLen; i++) {
			$(nodes[i]).after($(nodes[i]).clone().empty().html("[BT_2]").attr("target","_blank").attr("title","download torrent from torcache" ).attr("href", code2down3(codeList[i])));
		}
	}
}

var i=0


var t=window.setInterval(function() { //wait 2 seconds to execute getAllTorrents() function
    if($('a[href^="magnet"]').length>0||i>20){
        window.clearInterval(t);
        getAllTorrentsNew();
    }else{
        i++;
    }
}, 500);