[Greasemonkey] Trying to change image before browser fetches
Paul Bardo
greasemonkey at otherlies.com
Thu Feb 16 11:41:11 EST 2006
If you are more concerned with showing the replacement image instead
of the original, and not so concerned with requesting the original
from the server, you can do something like this.
for ( i = 0; img = xpr.snapshotItem(i); i++ ) {
img.style.display = "none";
src = img.getAttribute( "src" );
src = src.replace( /http:\/\/www\.someplace\.com\//g,
"http://www.someotherplace.com/");
newimg = document.createElement("IMG");
newimg.src = src;
img.parentNode.insertBefore(rightimg, img);
}
You should probably loop through all of "img" styles and assign them
to "newimg", before you set "img.style.display" to none, if you the
new image to have the same borders and stuff as the old one.
This will still pull the original image off the server, but it will
show your instead (basically stole Anthony's use AdBlock idea, but
without AdBlock)
More information about the Greasemonkey
mailing list