你可以把他拖(放)在浏览器的收藏夹栏里,打开一个网站,点击这个收藏的链接后,几百毫秒后,浏览器的右上角就会弹出一个框,带有IP-IP归属地-ip延迟等信息的一个东西。
将下面的代码保存成一个收藏即可,使用时打开网站点击一下这个收藏即可。
javascript:with(document)0[body.appendChild(createElement('script')).src='http://你的域名/xx.js'];
下面发一下js代码,你也可以自己把js放到自己本地使用。
/*获取网站域名*/
var url = window.location.host;
/*ajax获取数据*/
var ajax = new XMLHttpRequest();
ajax.open('get','https://api.yum6.cn/ping.php?host='+url);
ajax.send();
ajax.onreadystatechange = function () {
if (ajax.readyState==4 &&ajax.status==200) {
console.log(ajax.responseText);
var obj = JSON.parse(ajax.responseText);
var ip = obj.ip;
var loca = obj.location;
if (obj.state=='1002') {
var code = '<div>状态:禁PING</div>';
}else if(obj.state=='1000'){
var code = '<div>最小延迟:'+obj.ping_time_min+'</div><div>平均延迟:'+obj.ping_time_avg+'</div><div>最高延迟:'+obj.ping_time_max+'</div>';
}else{
var code = '';
}
/*创建div*/
var d = document.createElement("div"),
x = document.createElement("div");
/*导入数据*/
var arr = ['域名:'+url,'地区:'+loca,'IP:'+ip,code];
d.innerHTML = arr.join("<br>");
d.style["z-index"] = 199710;
d.style.textAlign = "canter";
d.style.display = "block";
d.style.position = "fixed";
d.style.top = d.style.right = "5px";
d.style.padding = "5px 20px 5px 10px";
d.style.background = "#fff";
d.style.color = "#000";
d.style.font = "12px Arial";
d.style.lineHeight = "18px";
d.style.border = "1px solid #ccc";
x.innerHTML = "x";
x.title = "关闭";
x.style.position = "absolute";
x.style.color = "red";
x.style.padding = "3px";
x.style.cursor = "pointer";
x.style.font = "14px Arial";
x.style.top = x.style.right = 0;
x.onclick = function() {
d.style.display = "none";
};
d.appendChild(x);
window.showAddressInfoWin = d;
document.body.appendChild(d);
}
}
!评论内容需包含中文