Using JS to add to URL's displayed onscreen

Discussion in 'JavaScript' started by jmhyer123, Jul 8, 2007.

  1. #1
    Hey,

    I am writing a Grease Monkey script that rewrites url's. I need it to take the url's displayed on screen and add ?XX=XXXXXXX to the middle/end of the url's

    This is what I am going off of (An existing GM script but I need to modify it because I don't want to replace anything I just want to add a string to the middle or end.)

    
    var link;
    
    link = document.body.getElementsByTagName("a")
    
    for (var i = 0; i < link.length; i++) {
         link[i].href = link[i].href.replace(/php\/movies.php\?file=/,'')
    }
    
    Code (markup):
    If anybody has any ideas they would be greatly appreciate!

    Thanks in advance,
    Jeffrey
     
    jmhyer123, Jul 8, 2007 IP
  2. smalldog

    smalldog Peon

    Messages:
    66
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    What does it mean to the middle? This way you can add your string to the end:

     
    smalldog, Jul 9, 2007 IP