[Greasemonkey] a css cleaner class

Mor Roses moroses at gmail.com
Fri Oct 14 17:19:24 EDT 2005


i made a css cleaner class in js but it has a really weird side effect if
you can take a look and tell me why i would like it.

the class:

function CSSCleaner(doc) {
var iframe=doc.createElement('iframe');
iframe.style.position='absolute';
iframe.style.visibility='hidden';
doc.body.appendChild(iframe);
var iDoc=iframe.contentDocument;
var iWin=iframe.contentWindow;
this.cleanCSS=function(elm) {
if(elm.nodeType!=Node.ELEMENT_NODE)
return;
var cleanElm=iDoc.createElement(elm.tagName);
iDoc.body.appendChild(cleanElm);
var cleanStyle=iWin.getComputedStyle(cleanElm,'');
for(var i=0,pName='';pName=cleanStyle.item(i);++i) {
if(pName=='-moz-user-select' || pName=='marker-offset') continue;
try {
elm.style.setProperty(pName,cleanStyle.getPropertyValue(pName),'');
} catch(e) { };
}
};
this.cleanSelf=function() { iframe.parentNode.removeChild(iframe); };
}


i have included a test page
-------------- next part --------------



More information about the Greasemonkey mailing list