[Greasemonkey] greasemonkey and changing css properties.

John Plsek gm at plsek.id.au
Thu Aug 11 16:07:35 EDT 2005


Shaya Potter wrote:

>I'd like to learn how to write a simple greasemonkey script to change
>css properties.
>
>namely, a site I go to has a css file which sets regular html properties
>via css to use text-align:justify ala
>
>p {font-size:165%;text-align:justify;}
>p.m {font-size:120%;text-align:justify;}
>p.s {font-size:100%;text-align:justify;}
>
>the problem is, firefox (unlike IE) can't display UTF8 combining
>characters well when used w/ text-align:justify.  If I remove the
>text-align:justify it displays well enough to read (not perfect, but
>usable).  (Yes, a bug has been filed for a long time)
>
>there should be an easy way to change this.  If those were styles that
>were used by a div, I could just do a getElementById() on the div type,
>but they aren't, so any reccomendations on how to change them?
>
>thanks,
>
>shaya
>
>_______________________________________________
>Greasemonkey mailing list
>Greasemonkey at mozdev.org
>http://mozdev.org/mailman/listinfo/greasemonkey
>
>
>  
>

// ==UserScript==
// @include       http://whatever.the.url.is/* ... change this 
(obviously) to the url of the site
// ==/UserScript==
    var style="p,p.m,p.s{text-align:left;}";
    var head=document.getElementsByTagName("HEAD")[0];
    var el=window.document.createElement('link');
    el.rel='stylesheet';
    el.type='text/css';
    el.href='data:text/css;charset=utf-8,'+escape(style);
    head.appendChild(el);

That may work ;)

John


More information about the Greasemonkey mailing list