Συζητήσεις » Αιτήματα Δημιουργίας

[Request] Replace a single specific image on a site.

§
Δημοσιεύτηκε: 15/02/2016
Επεξεργάστηκε: 17/02/2016

[Request] Replace a single specific image on a site.

First of all i would like to explain that i have almost zero knowledge about web design and scripting. I have no real idea how Greasemonkey works and maybe i'm way off on this.

To no avail I've been looking for a FF and/or Chrome plugin, that would replace a single specific image on a website with a custom one. For example when i open www.my-page.com/* which somewhere contains an image, lets say www.my-page.com/public/style_images/logo1.gif would like for the browser to display an image i uploaded to a hosting somewhere www.some-image-host.com/images/923467304/fakelogo.gif. The image would be of the same size (resolution) so it shouldnt breake the page in anyway.

While googling for such a plugin i came across Greasemonkey which i suppose should have no problem doing this, but i dont know how.

I installed Greasemonkey and "made" a script but it doesn't do what i think it should:

// ==UserScript==
// @name Name of my script
// @namespace don't know what to put there
// @description My script description
// @include *www.my-page.com*
// @version 1
// @grant none
// ==/UserScript==
src.replace('www.my-page.com/public/style_images/logo1.gif', 'www.some-image-host.com/images/923467304/fakelogo.gif');

What am i doing wrong or what am i missing?

Thank you in advance for your help.




edit:
A user on reddit posted this script:
https://gist.github.com/Farow/330b58980badc5036743

For me it works like a charm. just posting it if anyone else needed it.

§
Δημοσιεύτηκε: 15/02/2016

You really need to learn JavaScript.

You won't be able to create GreaseMonkey scripts without it.

Check this link to see why the code you've written cannot work:
http://www.w3schools.com/jsref/jsref_replace.asp
- src is null (you need to put the page source code into the src variable
- .replace function returns the result, but you are not saving it anywhere
- etc...

PS: @namespace should be a unique url to determine who made the script.
for ex.: you can use your GreaseFork profile URL.

§
Δημοσιεύτηκε: 16/02/2016

OK, i understand why my script doesn't make sense, i'd have to define the variable "src" firs and probably do a loop to check al images or something.

The problem is i'm not a coder/programmer, i don't need this for work or school or anything, its just something i would like to use for myself and i just don't see myself learning javasript just for that. I thought it was much simpler, just a matter of few lines of code but it seems like it's more complicated than that.

§
Δημοσιεύτηκε: 17/02/2016

A user on reddit posted this script:
https://gist.github.com/Farow/330b58980badc5036743

For me it works like a charm. just posting it if anyone else needed it.

§
Δημοσιεύτηκε: 19/02/2016
Επεξεργάστηκε: 20/02/2016
A user on reddit posted this script:
https://gist.github.com/Farow/330b58980badc5036743

For me it works like a charm. just posting it if anyone else needed it.

Gubangu, how do you use it? Edit: nevermind :smile:

if i want to replace, just for example, greasyfork's logo on the home page with a shared uploaded pic, editing the lookup table like this does work:

let lookup_table = {
'https://greasyfork.org/assets/blacklogo96-941a633c971b25c0c9e982ed499b5d8c.png':'http://fap.to/images/thumb/53/741/74199004.jpg',
};

I don't know why a dozen tries didn't work but this does. voilà! I too have wanted a script like this, to replace a little grey arrow, say, with a bigger green arrow. I'll see if this does the trick. Thanx for your request!

Δημοσίευση απάντησης

Συνδεθείτε για να δημοσιεύσετε μια απάντηση.