How to overwrite in GM script all inner "style" attributes?

29 views
Skip to first unread message

Ben Stover

unread,
Jun 10, 2015, 2:20:05 AM6/10/15
to Greasemonkey Users
Assume I have html pages with the following schema:

<div class="aaa">
...
<pre style="line-height:120%">
<span style="font-family:verdana">
<span style=font-size:11pt;">...
</span>
...
</span>
....
</pre>
...
<pre style="line-height:110%">
<span style="font-family:verdana">
<span style=font-size:12pt;">...
</span>
...
</span>
....
</pre>
...
</div>

I want to set for ALL elements inside <div class="aaa"> a new font-family, a new font-size and a new line-height.
Normally more specific attributes overwrite more general attributes.

So if I assign a global font-family,font-size and line-height to class="aaa" I need an additional way to tell from GM script
to disable all deeper/special corresponding attributes inside this class element.

How can I achieve this?

Thank you
Ben








janekptacijarabaci

unread,
Jun 10, 2015, 7:09:03 AM6/10/15
to greasemon...@googlegroups.com
e.g.


var elms = document.querySelectorAll("div.aaa *");

for (var i = 0, count = elms.length; i < count; i++) {
  elms
[i].style.lineHeight = "150%";
  elms
[i].style.fontFamily = "Tahoma";
  elms
[i].style.fontSize = "20pt";  
}




Dne středa 10. června 2015 8:20:05 UTC+2 Ben napsal(a):

Méhész György Ákos

unread,
Jun 10, 2015, 5:22:58 PM6/10/15
to greasemon...@googlegroups.com
Or maybe just use the !important directive. ;)

--
You received this message because you are subscribed to the Google Groups "greasemonkey-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to greasemonkey-us...@googlegroups.com.
To post to this group, send email to greasemon...@googlegroups.com.
Visit this group at http://groups.google.com/group/greasemonkey-users.
For more options, visit https://groups.google.com/d/optout.

janekptacijarabaci

unread,
Jun 11, 2015, 2:35:49 AM6/11/15
to greasemon...@googlegroups.com

There are plenty of options, we do not know the exact example. Or what is the best.

Dne středa 10. června 2015 23:22:58 UTC+2 Booboo napsal(a):

Ben

unread,
Jun 14, 2015, 3:00:39 AM6/14/15
to greasemon...@googlegroups.com
This works.
Thank you
Reply all
Reply to author
Forward
0 new messages