室友推荐了个chrome的插件,我就发现了这东西好像有毒,原来网页还能加东西呢,就有了一个想法:
让每个网页都显示对应网址的IP地址和其他详细的信息。
第一件事就是给chrome添加Tampermonkey插件,然后添加脚本,虽然网上有挺多大神的脚本,但是本着发扬光大的思想......
来,我们看看添加新的脚本:
// ==UserScript==
// @name         New Userscript //插件名字
// @namespace    http://tampermonkey.net/  //插件所属名
// @version      0.1  //版本
// @description  try to take over the world!
// @author       You
// @match        http:/// //地址范围
// @grant        none  //
// ==/UserScript==
(function() {
'use strict';
// Your code here...})();
再添一个jQ库,方便:
// @require http://code.jquery.com/jquery-1.11.0.min.js
在// your code here写我们想写js代码
先测试一下,在网页中加个文字:
// ==UserScript==
// @name         test
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        *
// @grant        none
// ==/UserScript==
(function() {
'use strict';
var div_test = document.createElement("div");
div_test.setAttribute("id", "id_test");
var a = document.body;
a.insertBefore(div_test, a.firstChild);
document.getElementById('id_test').innerHTML = 'test';})();

继续,那就直接去实现前面的想法,把比较详细的IP信息显示在浏览器的右下角,并且是透明的。