Rewrite Parts Of Links Using Greasemonkey And FireFox
A friend of mine uploaded about 20 or so galleries of nature shots she's done over the past year or so onto webshots.com, however, I just purchased a paid Flickr account for her as
Solution 1:
var links = document.getElementsByTagName("a"); //array
var regex = /^(http:\/\/)([^\.]+)(\.webshots\.com\/photo\/)(.+)$/i;
for (var i=0,imax=links.length; i<imax; i++) {
links[i].href = links[i].href.replace(regex,"$1community$3fullsize/$4");
}
ought to do the trick
Solution 2:
Your code was fine but for a typo:
links[i].href =
liks[i] .href.replace(regex,"$1community$3fullsize/$4");
Replace liks with links and it works.
Open up the Firebug console, turn most of the warnings on, and reload the page. You can see errors your script might cause (plus a metric ton of errors from the site itself).
Solution 3:
Quite late answer, but I'll post anyway in case it'll do some good.
I'm kind of newb to this stuff myself, but I don't think it will help to assign a value to links[i].href since it's just a variable. You won't change anything on the page by doing so. I think you should replace this:
links[i].href = links[i].href.replace(regex,"$1community$3fullsize/$4");
with this:
document.getElementsByTagName("a")[i].href = links[i].href.replace(regex,"$1community$3fullsize/$4");
Post a Comment for "Rewrite Parts Of Links Using Greasemonkey And FireFox"