// ==UserScript==
// @name get-magnet
// @namespace http://tampermonkey.net/
// @version 0.33
// @description query the web pages all magnet link
// @author You
// @match https://fc2club.top/
// @match http://*/*
// @match https://*/*
// @license GPL
// @icon https://www.google.com/s2/favicons?sz=64&domain=fc2club.top
// @grant none
// @downloadURL none
// ==/UserScript==
(function() {
'use strict';
var orstr = ""
var divObj = document.createElement("div");
divObj.id = "magbtn";
divObj.style.position = "fixed";
divObj.style.right = "1%";
divObj.style.top = "55px";
divObj.style.textAlign = "center";
divObj.style.width = "88px";
divObj.style.margin = "auto";
divObj.style.borderRadius = "8px";
divObj.style.zIndex = "888";
divObj.style.boxShadow = "0px 0px 2px 2px rgb(0,0,0)";
if (self != top) {
return
};
document.body.appendChild(divObj);
document.getElementById("magbtn").innerHTML = orstr;
function getmag() {
var divObj = document.createElement("div");
divObj.id = "showmagnet";
divObj.style.position = "fixed";
divObj.style.left = "25%";
divObj.style.top = "55px";
divObj.style.textAlign = "center";
divObj.style.width = "50%";
divObj.style.margin = "auto";
divObj.style.zIndex = "999";
divObj.style.background = "pink";
divObj.style.boxShadow = "0px 0px 3px 3px rgb(0,0,0)";
divObj.style.borderRadius = "10px";
divObj.addEventListener("dblclick",
function() {
this.remove()
});
if (self != top) {
return
}
if (document.getElementById("showmagnet")) {
copy2brd();
document.getElementById("getmagbtn").innerHTML = "提取磁力链接";
return
}
document.body.appendChild(divObj);
var links = document.querySelector("body").innerHTML.match(/[0-9a-fA-F]{40}/g);
links = links.sort();
var tarstr = "magnet:?xt=urn:btih:" + links[0].toUpperCase() + "
";
var textrows = 1;
for (var i = 1,
l = links.length; i < l; i++) {
if (links[i].toUpperCase() !== links[i - 1].toUpperCase() && links[i].toUpperCase() !== "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA") {
tarstr += "magnet:?xt=urn:btih:" + links[i].toUpperCase() + "
";
textrows++
}
};
document.getElementById("showmagnet").innerHTML = tarstr;
textrows++;
tarstr = "
";
document.getElementById("showmagnet").innerHTML = tarstr;
document.getElementById("getmagbtn").innerHTML = "复制到剪贴板";
document.getElementById("clipbrdbtn").addEventListener("click",
function() {
copy2brd()
});
}
function copy2brd() {
var text = document.getElementById("clipboard").value;
if (navigator.clipboard) {
if (navigator.clipboard.writeText(text)) {
document.getElementById("clipboard").value = "";
}
} else {
document.getElementById("clipboard").select();
document.execCommand("cut", true)
}
document.getElementById("showmagnet").remove();
}
document.getElementById("getmagbtn").addEventListener("click",
function() {
getmag()
});
document.getElementById("getmagbtn").addEventListener("mouseenter",
function() {
document.getElementById("getmagbtn").style.backgroundColor = "green";
document.getElementById("getmagbtn").style.color = "pink";
document.getElementById("getmagbtn").style.fontWeight = "bold"
});
document.getElementById("getmagbtn").addEventListener("mouseleave",
function() {
document.getElementById("getmagbtn").style.backgroundColor = "";
document.getElementById("getmagbtn").style.color = "";
document.getElementById("getmagbtn").style.fontWeight = ""
});
})();