Am 26.02.2012 11:45, schrieb Ben:
Assume I have a HTML code like
<p class="XXNormal" style="line-height:150%">
<span style="font-size:10.0pt; line-height:150%;font-
family:Arial;color:black">
aaaa sample text bbbb</span>
</p>
and a GM user scipt like:
GM_addStyle("element.style { color: black; font-family: Verdana; font-
size: 14px !important; line-height: 16px !important; }");
The name of that function is addStyle - it only adds a CSS-tag to the
page. That "element.style" is a pseudo-class invented by Firebug as
label for the attributes from the style-tag of currently selected
element in Firebug. If you however insert CSS like you did, you add a
style for "element" tags that have a class "style", like <element
class="style">...</element>.
You can either change the added style qualifier to the one that element has
GM_addStyle("p.XXNormal { color: black; font-family: Verdana; ... }");
or if that applies to too many elements you didn't want to affect, you
can add an unique class to that element with JavaScript:
elem = document.getElement... (however you do that)
elem.className += " gm_specialClass1" // Note the space in front of
that class name!
That changes the class attibute value to "XXNormal gm_specialClass1",
and you can refer to that element with the new class name:
GM_addStyle(".gm_specialClass1 { color: black; font-family: Verdana;
... }")
You can also change the CSS in the style attribute directly. Assuming
you've selected your element in the elem variable, use this code:
elem.style.color = "black";
elem.style.fontFamily = "Verdana";
...
And last but not least I think you can also assign a complete new style
attribute value:
elem.setAttribute("style", "color: black; font-family: Verdana; ...");
Except for the first method, these methods all keep working even if the
page decides to rename their classes.
I hope that helps, Chris
--
You received this message because you are subscribed to the Google Groups
"greasemonkey-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/greasemonkey-users?hl=en.