pedro22 Posted July 21, 2017 Share Posted July 21, 2017 I need to use a user script to replace one link to another http://www.site.com/index.php?page=tnap&action=outgoingLink&out_url=http://www.somesite.com/tour/content/agn001&class=pages - to: http://www.somesite.com/index/archive/agn001 For now i got: http://www.somesite.com/index/archive/agn001&class=pages but how to remove "&class=pages" on the end? Spoiler // ==UserScript== // @name script // @namespace http://www.site.com/ // @version 1.0 // @description try to take over the world! // @author You // @match www.site.com/* // @include www.site.com/* // @exclude // @grant none // ==/UserScript== var links,thisLink; links = document.evaluate("//a[@href]", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); for (var i=0;i<links.snapshotLength;i++) { var thisLink = links.snapshotItem(i); thisLink.href = thisLink.href.replace('http://www.site.com/index.php?page=tnap&action=outgoingLink&out_url=http://www.somesite.com/tour/content/agn001&class=pages', 'http://www.somesite.com/index/archive/'); } Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.