>
> @Booboo
>
thank you, but your two solutions seems to be rather uncomfortable.
Suddenly I remembered a solution for another GM javascript problem
someone passed me a time ago:
5 seconds delayed execution!!!
So I investigated the former code and tried it out for IMG shrinking:
It works great!!!
Have a look at my final code below. It seems to me that delayed execution
is a real excellent multi-purpose tool and should be more propagated for GM
script problems.
Anyway, thank you for your help.
window.setTimeout(
function () {
var imgNodes = document.getElementsByTagName("img"),
imgNode,
i = imgNodes.length,
imgWidth,
imgHeight,
newWidth = 0,
newHeight = 0;
for (;i;) {
imgNode = imgNodes[--i];
imgWidth = imgNode.clientWidth;
imgHeight = imgNode.clientHeight;
if (imgWidth >= 200){
newWidth = Math.round(imgNode.clientWidth * 0.7);
newHeight = Math.round(imgNode.clientHeight * 0.7);
imgNode.style.width = newWidth + "px";
imgNode.style.height = newHeight + "px";
console.log("Image with client width / height: " + imgWidth + "px /
" + imgHeight + "px modified to width / height: "
+ imgNode.clientWidth + "px (" +
Math.round(imgNode.clientWidth / imgWidth * 100) + "%) "
+ imgNode.clientHeight + "px (" +
Math.round(imgNode.clientHeight / imgHeight * 100) + "%)");
}
}
}
,5000);
--
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/d/optout.