Ad

Greasemonkey Change Javascript Test

I'd like to change a test made by a javascript on a website

<img src="https://img_small.jpg" class="pictures_load" of="true" onclick="var src='https://img_big.jpg';
    if(this.readAttribute('of')) src='/noimagehown.gif';
    

the idea is to remove each javascript test line :

if(this.readAttribute('of')) src='/noimagehown.gif';

so I could see the big image version onclick, I tried it by removing the ligne when inspecting the page code and it worked.

Thanks

Ad

Answer

Based on what you have provided so far, the intension is to prevent the function of the following onclick.

if(this.readAttribute('of')) src='/noimagehown.gif';

Since above is dependent on this.readAttribute('of'), then the goal can be achieved easily be removing of="true"

Here is an example:
Look for all images with of="true" and remove of attribute

document.querySelectorAll('img[of="true"]').forEach(item => item.removeAttribute('of'));
Ad
source: stackoverflow.com
Ad