Ben,
How can I write a script which let me modify some html/css values?
There are a couple of web pages from certain sites which have an ugly
font, or a BIG line height or a small width value. Before printing I
want to change them.
If it's something you're going to want to do "on demand", as before
printing, then a bookmarklet may be more what you're looking for. This
is not to disrespect GM — an old friend for half a decade — but to try
to answer your question as helpfully as I can.
You can inject a little CSS in a page from a bookmarklet very easily:
javascript:p=document.createTextNode("p{width:
400px
;}");s
=
document
.createElement
("style");s.appendChild(p);b=document.getElementsByTagName("head")
[0];void(b.appendChild(s))
This very, very simple one is called "Narrographs" on my machine: it
forces all paragraphs on a page (usually a news page, which tend to be
long stories set way too wide for easy reading). You can put whatever
CSS you'd like in the textnode "p".
Of course, this is just one way to do it. Others may look at this and
shake their heads, sadly, wondering why I did it this way. But it
gets the job done. It's a pattern I've used with success for years.
A geekier, version prompts you for whatever CSS you might want to insert
in the page. If you cancel, it doesn't insert anything. If you just
click "OK" or press Enter, it does exactly what the script above does,
if you edit the CSS, you can do whatever you want.
javascript:if(c=prompt("CSS to insert:","p{width:400px;}")
{p
=
document
.createTextNode
(c
);s
=
document
.createElement
("style");s.appendChild(p);b=document.getElementsByTagName("head")
[0];void(b.appendChild(s))}
Of course, exactly what CSS you need depends on the page you're
fixing.
Dave
--
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.