// ==UserScript==
// @name fofa IP查询延迟并且切换ip
// @match https://fofa.info/result*
// @grant none
// @version 1.2
// @author songsong
// @description 2024/11/02 22:49:35
// @license MIT
// @namespace Violentmonkey Scripts
// ==/UserScript==
(function () {
"use strict";
// body="Backend not available" && region="TW"
// body="Backend not available" && country="US"
createEle("div", "go!", {
backgroundColor: "#00ab7a",
position: "fixed",
top: "80px",
right: "50%",
padding: "10px 20px",
borderRadius: "5px",
boxShadow: "0px 0px 10px rgba(0, 0, 0, 0.2)",
cursor: "pointer",
color: "#fff",
zIndex: "9999",
}).addEventListener("click", startQueryIps);
document
.querySelector(".hsxa-meta-data-list")
.addEventListener("click", (e) => {
let ip = e.target.getAttribute("ip");
if (!ip) return;
let type = e.target.getAttribute("type");
editConfig(type, ip);
});
})();
function startQueryIps() {
let nodes = document.querySelectorAll(".hsxa-host");
nodes.forEach((l) => {
let a = l.querySelector("a");
a.setAttribute("target", "_blank");
a.href = "https://www.netflix.com/search?q=%E5%91%A8%E6%98%9F%E9%A9%B0";
fetch("https://api.v50.baby/port/check?ip=" + a.innerText.trim())
.then((response) => response.json())
.then((res) => {
if (res.data.http && res.data.https) {
["", "netflix", "openai", "disney"].forEach((l) => {
createEle(
"span",
l || res.data.time,
{
color: "#fff",
padding: "10px",
marginLeft: "20px",
borderRadius: "6px",
backgroundColor: "#00ab7a",
cursor: "pointer",
},
a.parentElement,
(ele) => {
if(!l) return;
ele.setAttribute("ip", a.innerText.trim());
ele.setAttribute("type", l);
}
);
});
}
});
});
}
function createEle(
type,
title,
styleObject,
parentElement = document.body,
cb
) {
const ele = document.createElement(type);
ele.textContent = title;
Object.assign(ele.style, styleObject);
cb && cb(ele);
(parentElement || document.body).appendChild(ele);
return ele;
}
function editConfig(type, ip) {
fetch(`https://api.v50.baby/port/editConfig?${type}=${ip}`)
.then((rr) => rr.json())
.then((rr) => {
let typeMap = {
netflix: "https://www.netflix.com/search?q=%E5%91%A8%E6%98%9F%E9%A9%B0",
openai: "https://chat.openai.com",
disney: "https://www.disneyplus.com/zh-hans/home",
};
setTimeout(() => {
window.open(typeMap[type], "_blank");
}, 2000);
});
}