Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// ==UserScript==
// @name U2 Show Peer location
// @namespace https://u2.dmhy.org
// @version 1.2.1
// @description Show Peer location
// @author Husky
// @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].className.match(/ipv4_native|ipv6_native/)) {
clientSpan[i].innerHTML += ' ' + clientSpan[i].title.split('GeoIP: ')[1]
}
if (clientSpan[i].className.match(/ipv6_teredo/)) {
clientSpan[i].innerHTML += ' ' + clientSpan[i].title
}
if (clientSpan[i].className.match(/ipv4_box/)) {
clientSpan[i].style.color = 'white'
clientSpan[i].style.backgroundColor = 'red'
clientSpan[i].innerHTML += ' ' + clientSpan[i].title.split('GeoIP: ')[1]
}
}
// console.log(clientSpan)
response.text = clientRes.body.innerHTML
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment