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 :)
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 :)
Share Improve this question asked Dec 22, 2008 at 20:28 NopeNope 36k42 gold badges100 silver badges119 bronze badges6 Answers
Reset to default 3Almost 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./questions/387388
// @include http://flickr./*
// ==/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.
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".
I believe greasemonkey script are executed after the loading of the page, so I guess the images are loaded too.
Not entirely related, but I use this bit of code to toggle displaying of images in Firefox in the EasyGestures plugin. I am not sure if this can be translated to greasemonkey, but it might be a starting point.
var prefs = Components.classes["@mozilla/preferences-service;1"].
getService(Components.interfaces.nsIPrefBranch);
var nImgPref = prefs.getIntPref("permissions.default.image");
if (nImgPref == 1) {
prefs.setIntPref("permissions.default.image",2)
alert('Images off.');
} else {
prefs.setIntPref("permissions.default.image",1)
alert('Images on.');
}
I know it's not greasemonkey, but you could try the "IMG Like Opera" extension. It definitely keeps the files from downloading, and has more flexibility than just on/off.
Do you know that the images still load? Maybe you should assert it using Firebug or some such?