Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 :)

like image 322
Nope Avatar asked Mar 02 '23 03:03

Nope


2 Answers

If you want to disable images downloading for all websites (which I guess you might not be doing) and are using firefox, why not just disable them in preferences? Go to the content tab and switch off "Load images automatically".

like image 114
GaryF Avatar answered Mar 12 '23 09:03

GaryF


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      http://stackoverflow.com/questions/387388
// @include        http://flickr.com/*
// ==/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.

like image 36
jfs Avatar answered Mar 12 '23 08:03

jfs