Google Public DNS 查询域名 IPv4 地址的浏览器书签脚本

2017-07-11 01:33:24 +08:00
 c16777216
javascript:x=XMLHttpRequest();x.open("get","https://dns.google.com/resolve?name="+prompt("",""),false);x.send();alert(JSON.parse(x.responseText).Answer.pop().data);
4221 次点击
所在节点    DNS
10 条回复
Showfom
2017-07-11 01:37:59 +08:00
six
kacong
2017-07-11 02:50:27 +08:00
smart bookmark.
lslqtz
2017-07-11 03:19:16 +08:00
Uncaught TypeError: Failed to construct 'XMLHttpRequest': Please use the 'new' operator, this DOM object constructor cannot be called as a function.
lslqtz
2017-07-11 03:22:57 +08:00
javascript:x=new XMLHttpRequest();x.open("get","https://dns.google.com/resolve?name="+document.domain,false);x.send();alert(JSON.parse(x.responseText).Answer.pop().data);
改了个查当前域名的。
c16777216
2017-07-11 03:49:19 +08:00
@lslqtz

#3 IE Mobile 不会报错

#4 很好
autoxbc
2017-07-11 03:49:55 +08:00
挺好。不过现在满世界 CDN,查出来的都不是本地最佳镜像,我直接在路由上架了个查询服务。
shadownet
2017-07-11 06:27:09 +08:00
@autoxbc 求教材
crystone
2017-07-11 09:31:00 +08:00
怎么使用呢
autoxbc
2017-07-11 15:20:06 +08:00
@shadownet 和楼主这个差不多,只是不走 google 的查询,在路由查询并返回,cgi 脚本是这样的

https://gist.github.com/anonymous/febfaa031558684014006da335ec2f0b

用 Web Server 的 cgi 模式运行,不能是 fast-cgi。

然后就是浏览器调用,就是上面这种小书签脚本。我用浏览器本身的私有方法跨域,所以 Web Server 里没有再设置允许跨域的 header。
c16777216
2017-07-11 19:37:31 +08:00
@crystone

#8
代码存为书签后打开

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/374393

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX