查了一些谷歌浏览器插件开发文档和资料,简单搞了个随机跳转插件,伪造网站来路地址。

/* manifest.json */
{
  "manifest_version": 2,

  "name": "随机跳转",
  "description": "Author zkx",
  "version": "1.0",

  "icons": {
    "128" : "icon.png"
  },
  "permissions": [
    "tabs", "http://*/*","https://*/*"
  ],
  "background": {
    "scripts": ["z.js"],
    "persistent": false
  },
  "browser_action": {
    "default_title": "随机跳转"
  },
  "manifest_version": 2
}
/* z.js */
chrome.browserAction.onClicked.addListener(function(tab) {
  /* No tabs or host permissions needed! */
  console.log('Turning ' + tab.url + ' 随机跳转');
  chrome.tabs.executeScript(null, {file: "x.js"});
});
/* x.js */

/* 指定跳转 */
document.writeln("<script>window.location.href=\'http://www.abc.com\';</script>");

/* 随机跳转 */
document.writeln("<script language=\'javascript\'>");
document.writeln("setTimeout(function(){");
document.writeln(" var arr=[\'http://www.a.com/?id=1\',\'http://www.a.com/?id=2\',\'http://www.dlshoushengqi.com/?id=3\'];");
document.writeln("window.location.href=arr[parseInt(Math.random()*arr.length)];");
document.writeln("},5000);");
document.writeln("</script>");

http://open.chrome.360.cn/extension_dev/content_scripts.html

http://www.cnblogs.com/bdstjk/p/3180925.html

Last modification:April 12, 2022
如果觉得我的文章对你有用,请随意赞赏