Changing the url of image src

825 Views Asked by At

I'm trying to change to source of the images shown in a page.

I've got this code:

function replaceSRC(){
    var allImg=document.getElementsByTagName('img'), i=0, img;
    while(img=allImg[i++]){
        img.src=img.src.replace(\'//dyncdn.me/static/over/, "\'//dyncdn.me/static/poster/3/");
    }
}

Not sure what to do next, im not really a script person i just wanted to make a site that uses to many small preview images to be seen bigger thats all.

the original source is:
dyncdn.me/static/over/random numbers.jpg
the source i want to use is:
dyncdn.me/static/poster/3/same random numbers.jpg

anyone can help out? thanks!

edit #1: seems the site is using onmouseover string to get the image source, while mouseout nothing shows. (only when my mouse is over the title the image is shown).

2

There are 2 best solutions below

4
On

Your string syntax is wrong. The replace line should be:

img.src=img.src.replace("//dyncdn.me/static/over/", "//dyncdn.me/static/poster/3/");
1
On

Create a bookmark and change the URL to this

javascript:(function(){var imgs = document.getElementsByTagName("img"); for (var i=0;i<imgs.length;i++) { var src=imgs[i].src; if (src.indexOf('static/over')!=-1) imgs[i].src=src.replace("/over/","/poster/3/")}})()

Now click F12 to open the console, click the bookmark on the page you need to change and report any errors you see