Jump to content

How to do it - userscript change one link to another


pedro22

Recommended Posts

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


  • Views 761
  • Created
  • Last Reply

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...