Anne van Kesteren

Letting Firefox pass Acid2 using Greasemonkey

Now I’m sure most people heard of Greasemonkey before. In short, it’s a Firefox extension that lets you modify web pages using javascript. If you want to know more about this extension you might want to read the free online book about it and play with it for a bit. Here is what I’ve done:

// ==UserScript==
// @name            Pass Acid2
// @namespace       tag:annevankesteren.nl,2005:acid2
// @description     Lets Firefox pass the Acid2 test.
// @include         http://www.webstandards.org/act/acid2/test.html*
// @include         http://webstandards.org/act/acid2/test.html*
// ==/UserScript==

(function(){
 var imageDiv = document.getElementsByTagName('div')[1]; 
 imageDiv.innerHTML = "<img src='reference.png' alt='Fail. Images have to be enabled for this test.'>";
 imageDiv.style.padding = "2em";
})();

How is that for innovation! You can also get it as a bookmarklet and make it partially work in Internet Explorer: Fix Acid2. It is still showing a red background there though and I’m sure that is fixable as well, but today’s about Greasemonkey, Firefox and giving Firefox more CSS capabilities.