[Greasemonkey] Newbie Simple (Should Be) Question about Replacing
CSS
Lenny Domnitser
ldrhcp at gmail.com
Sun Sep 4 03:49:37 EDT 2005
On 9/4/05, Eris Siva <erissiva at gmail.com> wrote:
> I would like to GM script to replace the CSS calls on the
> page so that the browser doesn't spend time loading 2 CSS files.
As already mentioned, Greasemonkey acts too late in the page load to
prevent loading CSS. The browser will probably have already started
loading the CSS when GM injects your script, but depending on the
speed of the net connection and the computer, the CSS might not have
loaded completely. The following code will remove all linked CSS,
which clears all of the associated styling, and might, but probably
won't, save a bit of time and bandwidth.
var links=document.getElementsByTagName('link');
for(var c = 0, link; link = links[c]; c++) {
if(/\bstylesheet\b/i.test(link.rel)) {
link.parentNode.removeChild(link);
}
}
More information about the Greasemonkey
mailing list