Last active
January 25, 2021 05:21
-
-
Save xNihil0/c605ad3758cb596224863d0bbe9db7be to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Based on DieNacht's version | |
// All credit goes to c0re100 | |
// Reference: https://gist.github.com/c0re100/3dea464145bf6abc8b1332a463fed525/raw/U2PeerLocation.user.js | |
// ==UserScript== | |
// @name U2 Show Peer location | |
// @namespace https://u2.dmhy.org | |
// @version 1.2.1-SD | |
// @description Show Peer location | |
// @author xNihilo | |
// @original author Husky DieNacht | |
// @match https://u2.dmhy.org/details.php?id=* | |
// @match https://u2.dmhy.org/userdetails.php?id=* | |
// @grant none | |
// @require https://unpkg.com/xhook@latest/dist/xhook.min.js | |
// @run-at document-start | |
// ==/UserScript== | |
xhook.after(function(request, response) { | |
if (request.url.match(/(btclients|viewpeerlist).php\?id=\d+/)) { | |
let resp = response.text | |
console.log(resp) | |
let parser = new DOMParser() | |
let clientRes = parser.parseFromString(resp, 'text/html') | |
let clientSpan = clientRes.getElementsByTagName('span') | |
console.log(clientSpan) | |
for (let i = 0; i < clientSpan.length; i++) { | |
if (clientSpan[i].title.match(/中国/)) { | |
clientSpan[i].title = 'GeoIP: 亚洲:中国大陆' | |
} | |
if (clientSpan[i].title.match(/中华民国/)) { | |
clientSpan[i].title = 'GeoIP: 亚洲:中华台北' | |
} | |
if (clientSpan[i].title.match(/香港/)) { | |
clientSpan[i].title = 'GeoIP: 亚洲:中国香港' | |
} | |
if (clientSpan[i].title.match(/澳门/)) { | |
clientSpan[i].title = 'GeoIP: 亚洲:中国澳门' | |
} | |
if (clientSpan[i].className.match(/ipv6_teredo/)) { | |
clientSpan[i].innerHTML = clientSpan[i].title | |
} | |
if (clientSpan[i].className.match(/ipv6_6to4/)) { | |
clientSpan[i].innerHTML += '隧道' | |
} | |
/*if (clientSpan[i].className.match(/ipv4_native/)) { | |
if (clientSpan[i].title.match(/大陆/)) { | |
clientSpan[i].style.backgroundColor = 'orange' | |
} | |
if (clientSpan[i].title.match(/法国/)) { | |
//clientSpan[i].style.color = 'white' | |
clientSpan[i].style.backgroundColor = 'yellow' | |
} | |
if (clientSpan[i].title.match(/德国/)) { | |
clientSpan[i].style.color = 'white' | |
clientSpan[i].style.backgroundColor = 'blue' | |
} | |
if (clientSpan[i].title.match(/荷兰/)) { | |
clientSpan[i].style.color = 'white' | |
clientSpan[i].style.backgroundColor = 'grey' | |
} | |
if (clientSpan[i].title.match(/芬兰/)) { | |
clientSpan[i].style.color = 'white' | |
clientSpan[i].style.backgroundColor = 'blue' | |
} | |
// clientSpan[i].style.backgroundColor = 'orange' | |
} | |
if (clientSpan[i].className.match(/ipv6_native/)) { | |
clientSpan[i].style.backgroundColor = 'white' | |
}*/ | |
if (clientSpan[i].className.match(/ipv4_box/)) { | |
clientSpan[i].style.color = 'white' | |
// clientSpan[i].style.backgroundColor = 'pink' | |
clientSpan[i].innerHTML = clientSpan[i].title.split('洲:')[1] | |
} | |
if (clientSpan[i].className.match(/ipv4_native|ipv6_native/)) { | |
clientSpan[i].style.color = 'white' | |
clientSpan[i].innerHTML = clientSpan[i].title.split('洲:')[1] | |
} | |
if (clientSpan[i].title.match(/feralhosting/)) { | |
clientSpan[i].style.color = 'white' | |
clientSpan[i].innerHTML = 'Feral Hosting' | |
} | |
if (clientSpan[i].title.match(/seedhost/)) { | |
clientSpan[i].style.color = 'white' | |
clientSpan[i].innerHTML = 'SeedHost Shared' | |
} | |
if (clientSpan[i].title.match(/seedhost/)) { | |
if (clientSpan[i].title.match(/server/)) { | |
clientSpan[i].style.color = 'white' | |
clientSpan[i].innerHTML = 'SeedHost Dedicated' | |
} | |
} | |
} | |
console.log(clientSpan) | |
for (const a of clientRes.querySelectorAll("b")) { | |
if (a.textContent.includes(" 下载者")) { | |
console.log("Leechers Found.") | |
const getCellValue = (tr, idx) => tr.children[idx].innerText || tr.children[idx].textContent | |
const comparer = (idx, asc) => (a, b) => ((v1, v2) => | |
v1 !== '' && v2 !== '' && !isNaN(v1) && !isNaN(v2) ? v1 - v2 : v1.toString().localeCompare(v2) | |
)(getCellValue(asc ? a : b, idx), getCellValue(asc ? b : a, idx)) | |
const table = a.nextElementSibling; | |
if (table != null) { | |
Array.from(table.querySelectorAll('tr:nth-child(n+2)')) | |
.sort(comparer(7, 0)) | |
.forEach(tr => table.appendChild(tr)) | |
} | |
} | |
} | |
response.text = clientRes.body.innerHTML | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment