greasemonkey修改网页url

 1 // ==UserScript==
 2 // @name        JSHE_ModifyFunction
 3 // @namespace   jshe
 4 // @include     http://localhost/*
 5 // @version     1
 6 // @grant       none
 7 // ==/UserScript==
 8 
 9 alert("hello2");
10 
11 function embed() {
12     var cells =document.getElementsByTagName("a");
13     for (var i = 0; i < cells.length; i++) 
14     {
15         var href = cells[i].getAttribute("href"); 
16         cells[i].setAttribute("href", href + "/dummy"); 
17     }
18 }
19 
20 
21 var script = document.createElement('script'); 
22 script.type = "text/javascript"; 
23 //script.innerHTML = "(" + embed + ")()";
24 script.innerHTML = embed + "\nembed();";
25 document.getElementsByTagName('body')[0].appendChild(script);
26 
27 alert("hello3");
View Code

 

posted on 2014-12-01 00:11  cutepig  阅读(449)  评论(0编辑  收藏  举报

导航