Retaining one's sanity, or removing lightboxes with user JavaScript
Wednesday, 10. September 2008, 22:23:45
Initially I thought of removing the markup hooks which trigger the lightbox functionality, but as I brushed up on user JS functionality I realised I could easily suppress the lightbox script entirely. Thus, I did this, preventing "slimbox.js" from executing, and "lightbox.js" along with it. But still not satisfied I searched for other variants of the lightbox concept and in due course found the Lightbox Clone Matrix which allowed me to block nearly all of them, many of which I'd never even heard of.
The code I finally came up with is this:
// remove lightboxen
// See http://planetozh.com/projects/lightbox-clones/ for list.
// Script handles all as of 2008-09-06 except Prototype Window and Control Window
window.opera.addEventListener('BeforeExternalScript', function(ev)
{if(ev.element.src.match(/((light|slim|grey|thick|lite|awesome|face|fancy|float|image|lyte|milk|moo?dal|multi|roe|shadow|smooth|swf|tiny|talci|weeb|i)box|enlargeit|fancyzoom(html)?|highslide|light(view|window)|(sub|nyro)modal|prettyphoto)([\.\-_](new|plus|[\d\.]*\d)|\+\+)?([\.\-_](uncompressed|compressed|pack))?\.js\b/i))
ev.preventDefault();
}, false);
Very little testing has gone into this, but it seems to work well enough for me. I know my colleague Dustin Wilson has found it a godsend (does that make me god?), so hopefully it will be useful for others as well!















