Discussions » Creation Requests

Simple image replacement script

§
Posted: 2020-12-29

I need a simple script to replace images on a website. I've been googling, but it's a mess with a thousand different rabbot holes.

So here's what I need:
If image url equals http(s)://[wildcard]-thumbnails.specificwebsite.com/thumbnails/[wildcard]-thumb.jpg?bs=blah-blah-blah
Replace with http(s)://[wildcard]-images.specificwebsite.com/images/[wildcard]-full.jpg

So how would I do that change? I don't mind about any of the extra bells and whistles for now. We can worry about resizing the images later. How would I just change that much? If I can get that much, I'll be adequate.

§
Posted: 2020-12-29

As you said, there is a lot of specific things about your request. So you have better to give a concrete website and more concrete example

§
Posted: 2020-12-30

I don't want to open the images. I want them to be replaced right on the page.

§
Posted: 2020-12-30

Let me explain it again:

Let's say, hypothetically, because this is going to remain hypothetical, that I want to replace all thumbnail images on bob.com with full-size images. Thumbnail image urls are as follows:
https://george-thumbnails.bob.com/thumbnails/########-thumb.jpg?extrastuff
Full-size image urls are as follows:
https://george-images.bob.com/images/########-full.jpg
It won't always be "george". It might be "fred" or "simon" or anything. Point is: I want to change only the relevant parts of the image URLs. I want to replace "thumbs" with "images" and remove any extra nonsense. This should be easy, easy, to do if someone knows javascript. I don't. Please, how do I do this?

§
Posted: 2020-12-30

this is going to remain hypothetical

But why?

§
Posted: 2020-12-30

Is the website is really bob.com? Because I can't reach it

§
Posted: 2020-12-31
Edited: 2020-12-31

Please don't keep this being only hypothetical, give us the website, otherwise nobody can really help you.

I already gave you the help you need, my script does exactly what you said, if you really know js you should probably know how to modify this https://greasyfork.org/en/discussions/requests/57659-add-button-to-page-that-opens-the-image-displayed-but-with-small-url-modification#


function replace(){
var ThumbIMG = document.querySelector("img").src;
var urloriginal = ThumbIMG.replace("thumb", "full");
document.querySelector("img").src = urloriginal;
}
replace();

§
Posted: 2020-12-31

Test the code below on this url https://greasyfork.org/en/discussions/requests/71604-simple-image-replacement-script#comment-176702

The greasyfork image (top left) will be replaced


var ThumbIMG = document.querySelector("#site-name > a > img").src;
var urloriginal = ThumbIMG.replace(ThumbIMG, "https://http2.mlstatic.com/frontend-assets/ui-navigation/5.11.0/mercadolibre/favicon.svg");
document.querySelector("#site-name > a > img").src = urloriginal;

Post reply

Sign in to post a reply.