javascript - Redirecting multiple values in URL with Greasemonkey -
i'm trying greasemonkey automatically redirect page when hits url, , redirect page 2 of same values. instance:
http://www.google.com/page=438985&view=49834 into: http://www.google.com/document/page=438985/field&view=49834&done
i've tried following:
var links,thislink; links = document.evaluate("//a[@href]", document, null, xpathresult.unordered_node_snapshot_type, null); (var i=0;i<links.snapshotlength;i++) { var thislink = links.snapshotitem(i); thislink.href = thislink.href.replace(regexp('http://www.google.com/page=($1)&view=($2)'), 'http://www.google.com/document/page=$1/field&view=$2&done'); }
var links = document.getelementsbytagname('a'); for(var = links.length - 1; >= 0; i--) { if(links[i] && links[i].href) { links[i].href = links[i].href.replace(/http:\/\/www\.google\.com\/page=(\d+)&view=(\d+)/, 'http://www.google.com/document/page=$1/field&view=$2&done'); } }
Comments
Post a Comment