Skip to content

Instantly share code, notes, and snippets.

@Baw-Appie
Created January 6, 2025 01:13
Show Gist options
  • Select an option

  • Save Baw-Appie/4b5564461479aa70f40b12b120dbd082 to your computer and use it in GitHub Desktop.

Select an option

Save Baw-Appie/4b5564461479aa70f40b12b120dbd082 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Minelist Hosting Provider Checker
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://minelist.kr/*
// @match https://mine.page/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=minelist.kr
// @require https://fastly.jsdelivr.net/npm/[email protected]/dist/jquery.min.js
// @grant none
// ==/UserScript==
function onElementInserted(containerSelector, elementSelector, callback) {
var onMutationsObserved = function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.addedNodes.length) {
var elements = $(mutation.addedNodes).find(elementSelector);
for (var i = 0, len = elements.length; i < len; i++) {
callback(elements[i]);
}
}
});
};
var target = $(containerSelector)[0];
var config = { childList: true, subtree: true };
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
var observer = new MutationObserver(onMutationsObserved);
observer.observe(target, config);
}
function isBlacklisted(serverAddress) {
return false
}
function removeTrailingDot(serverAddress) {
return serverAddress.substring(0, serverAddress.length - 1)
}
async function queryDNS(serverAddress, type="A") {
const response = await fetch(`https://dns.google/resolve?name=${serverAddress}&type=${type}`)
const json = await response.json()
return json
}
async function asInfo(serverIP) {
const response = await fetch(`https://ipinfo.io/${serverIP}/json`)
const json = await response.json()
return json
}
async function addAddressElement(v) {
const serverAddress = v.innerText.trim()
const queries = await Promise.all([
queryDNS(serverAddress, "A"),
queryDNS(`_minecraft._tcp.${serverAddress}`, "SRV"),
])
if(queries[1].Answer) queries[0] = {}
const result = []
for(let query of queries) {
if(query.Answer) {
for(let item of query.Answer) {
const datas = item.data.split(" ")
if(datas.length != 1) {
if(isBlacklisted(datas[3])) {
result.push(`${removeTrailingDot(datas[3])}:${datas[2]}`)
} else {
const aQuery = await queryDNS(`${removeTrailingDot(datas[3])}`, "A")
const ip = aQuery.Answer.filter(v => v.type == 1)?.[0]?.data
if(ip) {
if(/^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$/.test(ip)) {
const as = await asInfo(ip)
result.push(`${removeTrailingDot(datas[3])} - ${ip}:${datas[2]} [${as.org}]`)
} else {
result.push(`${removeTrailingDot(datas[3])} - ${ip}:${datas[2]}`)
}
} else {
result.push(`${removeTrailingDot(datas[3])}:${datas[2]}`)
}
}
} else {
if(/^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$/.test(datas[0])) {
const as = await asInfo(datas[0])
result.push(`${datas[0]} [${as.org}]`)
} else {
result.push(datas[0])
}
}
}
}
}
v.innerHTML = `${serverAddress}<ul style="margin:0">${result.map(v => `<li>${v}</li>`).join("")}</ul>`
}
(function() {
'use strict';
console.log("===== Minelist Hosting Provider Checker =====")
onElementInserted('body', '.server-url', v => {
addAddressElement(v)
});
$(".copyable.copyable-ip").each(async (i, v) =>{
addAddressElement(v)
})
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment