I want to write a greasemonkey script/chr开发者_StackOverflow社区ome user script that takes any images with a certain syntax and replace a section of the url and puts it back in the dom.
Namely I have a page full of thumbnails, e.g. www.example.com/small/randomstuff and I want to replace the imades with the equivilant www.example.com/large/randomstuff
How would I do this?
After page was loaded.
var imgs = document.getElementsByTagName('img');
var len =imgs.length;
for(var i=0;i<len;i++){
imgs[i].src=imgs[i].src.replace("small","large");
}
To replace a image source url, you can do something like this:
var imgs = document.getElementsByTagName('img')
imgs[0].src = "http://www.example.com/large/randomstuff"
精彩评论