Am 07.07.2013 07:43, schrieb Ben Stover:
On certain webpages I have embedded images with a spec like:
<img width="640" height="405" src="/.....">
I want to reduce the dimensions of this picture to
<img width="320" height="203" src="/.....">
In order to achieve this I added the following statements to a corresponding GM
script:
document.querySelector('img[width="600"]').setAttribute('style', 'width: 50%;');
document.querySelector('img[height="405"]').setAttribute('style', 'height:
50%;');
It's not clear from the context whether this is about one or multiple
pictures per page, but querySelector selects only the first matching node.
To get all, you need to use querySelectorAll and iterate over the list
by index:
var imgList = document.querySelectorAll(...);
for (var i = 0; i < imgList.length; ++i) {
var img = imgList[i];
img.setAttribute(...);
}
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/greasemonkey-users.
For more options, visit https://groups.google.com/groups/opt_out.