Prepare!

Lee Harvey's Zombie Hit Parade

UserJS to Hide Filtered Elements

, , , ,

Do you use Opera's filter.ini feature, or a HOSTS file to block certain content? Do you hate to see web pages rendered with large amounts of unused white-space when your filtering works? If so, then these pair of scripts may help.

As mentioned in my previous post, I use Opera's filter.ini feature. Because of this, Opera effectively blocks many third-party images, iframes, and JavaScripts. Effectively, this often results in large rectangular regions of unused white-space on websites that host advertisements. To compensate for this, I have developed a pair of User JS files that hide non-loaded images and iframes...


Download/view imgload.js
document.addEventListener("load",
        function(e) {
                var imgs = document.images;
                for (var i = 0, o; o = imgs[ i ]; i++) {
                        if (!o.complete) o.style.display = "none";
                }
        }, false);

-and-

Download/view iframeload.js
document.addEventListener("load",
        function(e) {
                var ifrms = document.getElementsByTagName("iframe");
                for (var i = 0, f; f = ifrms[ i ]; i++) {
                        // if (!f.location) f.style.display = "none"; // Version 1.0
                        if (!f.src) f.style.display = "none"; // Version 1.1
                }
        }, false);

As an added bonus to webpage readability, these scripts can also improve mouse gesture usability -- which don't work so well over blank/filtered-out inline frame elements.

Enjoy.

Update 2009/12/07 - Changed f.location to f.src in iframeload.js

My filter.ini entriesUserJS for MegaMillions.com

Comments

dapxin Tuesday, March 3, 2009 6:33:31 AM

hope this doesn't add unnecessary load to page rendering ?

Lee HarveyLee_Harvey Tuesday, March 3, 2009 1:20:04 PM

Nope.

Of course, if you visit a page that contains a ton of non-loadable images, then you're going to wait a very long time for the document.load event to kick-in (after the page has loaded) anyhow. Meaning: These scripts don't run until /after/ the page has loaded. They then filter-out (hide) any non-displayed images and silly inline frames with no location specified.

dapxin Tuesday, March 3, 2009 6:05:54 PM

Tx. I will keep it alive then smile

JIsildur Monday, April 27, 2009 4:27:26 PM

Nice idea.

Brent B. Powersb2pi Wednesday, October 21, 2009 7:29:01 PM

It's taken quite a while, but I've tracked down at least one problem with Opera 10 and either iGoogle or eBay, at least. For some reason, in some circumstances, this js blocks gmail and google calendar widgets, or (on eBay), the description frame.

Unfrotunately, my java script fu is weak, at best, but I'll let you know if I find anything else...

dapxin Friday, October 30, 2009 11:47:52 PM

Causes a couple of problems I have noticed
e.g http://tinypaste.com/261fe14

How can this be stopped?

dapxin Wednesday, November 18, 2009 10:13:15 AM

Hello ! smile

dapxin Wednesday, November 18, 2009 10:24:54 AM

well, after a little thinking, I fixed it by adding

// @exclude http://*tinypaste.com/*

To the header files. nice.

Lee HarveyLee_Harvey Monday, December 7, 2009 1:32:28 PM

I confirmed an issue with iframeload.js In essence, the old frame.location object reference no longer seems to be valid (Opera security fix?). Anyhow, I have changed it to frame.src, but this may have other side-effects. If you run into any sites where the new code misbehaves, please let me know. I'll run with this new version for now, and will keep you posted if I run into any, as well.

dapxin Sunday, February 7, 2010 11:41:07 PM

some sites are simply un-useable.
eg.

http://www.moneysupermarket.com/

Has that got todo with the same problem ? Isn't it possible to implement a whitelist system using cookies ?

dapxin Sunday, May 16, 2010 7:14:48 PM

Also see this:
http://craighickmanontennis.blogspot.com/2010/05/madrid-final-open-thread.html

the comments by disqus is blocked off It seems.

Write a comment

You must be logged in to write a comment. If you're not a registered member, please sign up.