Miscellaneous > Programming & Networking
Web bug detecting script for Firefox
H_TeXMeX_H:
--- Quote from: worker201 ---Uhm, except for the fact that many websites still use 1x1 images for preloading purposes. Loading a 45k image at 1x1 pixel places it into cache, so it can be loaded quickly when needed, at which time it can be displayed at its proper size. With the increase of broadband, this isn't so much of a problem anymore. But you still might be interfering with site loading.
--- End quote ---
hmmm ... so is there anything that differentiates web bugs from these pre-loading ones ? Is it a size difference byte wise (not width or length obviously) ? There might be a way to exclude them ?
worker201:
I guess if you were to determine how big a 1x1 pixel image is, and then set some kind of threshold, like 2k or something. Nobody would bother to preload a really small image, and even if they did, it would probably take just as long to pull it from cache as it would to download it.
H_TeXMeX_H:
Ok, here is the new and improved code that looks at the normal height and width of an image before any type of modification, which allows for pre-loaded images (no, unfortunately there is no img.fileSize function (like with IE or Opera) for Mozilla, but they have naturalHeight and naturalWidth that makes up for it)
And, I changed the border to 11 pixels because of this site ... there is a barely noticible bug in the upper left-hand corner that is much more visible with 11 pixel border
Thanks for pointing that out ... it was a rather simple fix too :thumbup:
--- Code: ---( function()
{
window.addEventListener("load", function(e)
{
var imgList = document.getElementsByTagName("img");
for (i=0; i < imgList.length; i++)
{
if (imgList[i].src != "" && imgList[i].naturalWidth == 1 && imgList[i].naturalHeight == 1)
{
imgList[i].width = "101";
imgList[i].height = "101";
imgList[i].alt = "WeB BuG";
imgList[i].border = "11";
imgList[i].style.borderColor = '#ff0000';
imgList[i].style.backgroundColor = '#00ff00';
}
}
return;
}, false);
})();
--- End code ---
H_TeXMeX_H:
Here is an alternative ... a script that stops bugs from loading ... you'll just have to trust me that it does work :D
--- Code: ---
( function()
{
window.addEventListener("load", function(e)
{
var imgList = document.getElementsByTagName("img");
for (i=0; i < imgList.length; i++)
{
if (imgList[i].naturalWidth == 1 && imgList[i].naturalHeight == 1)
{
imgList[i].style.display = "none";
}
}
return;
}, false);
})();
--- End code ---
Navigation
[0] Message Index
[*] Previous page
Go to full version