Nope Nope - 1 year ago 98
Javascript Question

Removing images with Greasemonkey?

I would like to stop images from loading, as in not even get a chance to download, using greasemonkey. Right now I have

var images = document.getElementsByTagName('img');

for (var i=0; i<images.length; i++){
images[i].src = "";

but I don't think this actually stops the images from downloading. Anyone know how to stop the images from loading?

Thanks for your time and help :)

Answer Source

Almost all images are not downloaded. So your script almost working as is.

I've tested the following script:

// ==UserScript==
// @name           stop downloading images
// @namespace
// @include*
// ==/UserScript==

var images = document.getElementsByTagName('img');
for (var n = images.length; n--> 0;) {
  var img = images[n];
  img.setAttribute("src", "");

Use a dedicated extension to manage images (something like ImgLikeOpera).

If you'd like to filter images on all browser then a proxy with filtering capabilities might help e.g., Privoxy.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download