// ==UserScript==
// @name get-magnet
// @namespace http://tampermonkey.net/
// @version 0.38.4
// @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 https://update.greasyfork.icu/scripts/476575/get-magnet.user.js
// @updateURL https://update.greasyfork.icu/scripts/476575/get-magnet.meta.js
// ==/UserScript==
(function() {
'use strict';
var links = document.querySelectorAll('a');
for (var i = 0,
l = links.length; i < l; i++) {
links[i].href = links[i].href.replace("https://btsow.quest", "https://btsow.motorcycles")
}
if (self != top) {
return
}
var arr = [(parseInt(Math.random() * 64 + 192)).toString(16), (parseInt(Math.random() * 64 + 192)).toString(16), (parseInt(Math.random() * 66 + 33)).toString(16)];
arr.sort(function() {
return Math.random() - 0.5
});
var bgdiv = "#" + arr[0] + arr[1] + arr[2];
var oldColor = '0x' + bgdiv.replace(/#/g, '');
let str = '000000' + (0xFFFFFF - oldColor).toString(16);
var tgdiv = '#' + str.substring(str.length - 6, str.length);
var orstr = "
";
var nrstr = "
";
var divObj = document.createElement("div");
divObj.id = "magbtn";
divObj.style.position = "fixed";
divObj.style.right = "1%";
divObj.style.top = "95%";
divObj.style.width = "20px";
divObj.style.height = "20px";
divObj.style.lineHeight = "20px";
divObj.style.margin = "auto";
divObj.style.borderRadius = "8px";
divObj.style.zIndex = "1888";
divObj.style.boxShadow = "0px 0px 8px 8px " + tgdiv;
divObj.style.backgroundColor = bgdiv;
divObj.style.color = tgdiv;
document.body.appendChild(divObj);
document.getElementById("magbtn").innerHTML = orstr;
function getmag() {
if (self != top) {
return
}
if (document.getElementById("showmagnet")) {
copy2brd();
return
}
var divObj = document.createElement("div");
divObj.id = "showmagnet";
divObj.style.position = "fixed";
divObj.style.left = "25%";
divObj.style.top = "75px";
divObj.style.textAlign = "center";
divObj.style.width = "50%";
divObj.style.margin = "auto";
divObj.style.zIndex = "999";
divObj.style.background = "#" + ("00000" + (Math.random() * 0x1000000 << 0).toString(16)).substr( - 6);
divObj.style.display = "block";
divObj.style.whiteSpace = "nowrap";
divObj.style.boxShadow = "0px 0px 8px 8px #" + ("00000" + (Math.random() * 0x1000000 << 0).toString(16)).substr( - 6);
divObj.style.borderRadius = "10px";
divObj.addEventListener("dblclick",
function() {
this.remove()
});
document.body.appendChild(divObj);
try {
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("magbtn").innerHTML = nrstr
} catch(e) {
tarstr = "
";
document.getElementById("magbtn").innerHTML = nrstr
}
document.getElementById("showmagnet").innerHTML = tarstr;
document.getElementById("clipbrdbtn").addEventListener("click",
function() {
copy2brd()
})
}
function copy2brd() {
var text = document.getElementById("clipboard").value;
if (text !== "没有找到磁力链") {
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("magbtn").innerHTML = orstr
} else {
document.getElementById("showmagnet").remove();
document.getElementById("magbtn").innerHTML = orstr
}
}
document.getElementById("magbtn").addEventListener("mousedown",
function() {
var Drag = document.getElementById(this.id);
Drag.onmousedown = function(event) {
Drag.style.userSelect = "none";
var ev = event || window.event;
event.stopPropagation();
var disX = ev.clientX - Drag.offsetLeft;
var disY = ev.clientY - Drag.offsetTop;
document.onmousemove = function(event) {
var ev = event || window.event;
Drag.style.left = ev.clientX - disX + "px";
Drag.style.top = ev.clientY - disY + "px";
Drag.style.cursor = "move"
}
};
Drag.onmouseup = function() {
document.onmousemove = null;
this.style.cursor = "default";
Drag.style.userSelect = "";
return false
}
});
document.getElementById("magbtn").addEventListener("click",
function() {
getmag()
});
document.getElementById("magbtn").addEventListener("mouseover",
function() {
document.getElementById("magbtn").style.backgroundColor = tgdiv;
document.getElementById("magbtn").style.color = bgdiv;
document.getElementById("magbtn").style.boxShadow = "0px 0px 8px 8px " + bgdiv;
document.getElementById("magbtn").style.fontWeight = "bold";
document.getElementById("magbtn").style.cursor = "pointer"
});
document.getElementById("magbtn").addEventListener("mouseout",
function() {
document.getElementById("magbtn").style.backgroundColor = bgdiv;
document.getElementById("magbtn").style.color = tgdiv;
document.getElementById("magbtn").style.boxShadow = "0px 0px 8px 8px " + tgdiv;
document.getElementById("magbtn").style.fontWeight = ""
})
})();