“It seems to me that the width attribute must be present to be accessible from 
GM script.
Can this be?”


No. It makes no sense.



“Can your script somehow be modified to cover <img> with NO width=   attribute?”


Not necessary because it was ment to do so…


The problem was as i could see that the page fails to download the images in 
the time the script runs.

So i attached it to the onload event, now it works for me at least.


// ==UserScript==
// @name        ChangeLayoutHowtogeek
// @namespace   nsChangeLayoutHowtogeek
// @description Change Layout HowToGeek
// @include     http://*.howtogeek.com/*
// @version     1.2.2
// @grant       none
// ==/UserScript==


document.addEventListener("load", 
  function (){
    var imgNodes = document.getElementsByTagName("img"),
        imgNode,
        i = imgNodes.length,
        imgWidth;


    for (;i;) {
      imgNode = imgNodes[--i];
      imgWidth = imgNode.clientWidth;
      if (imgWidth >= 600){
        imgNode.style.width = "70%";
        imgNode.style.height = "70%";
        console.log('Image with client width: ' + imgWidth + 'px modified to 
70%');
      }
    }
  }, true
);






Ákos





Feladó: [email protected]
Elküldve: ‎csütörtök‎, ‎2015‎. ‎január‎ ‎8‎. ‎10‎:‎55
Címzett: [email protected]





@Booboo: Great idea, thank you, but it does not work (or only partially).

Have a look at another, related webpage:

http://www.howtogeek.com/186842/6-ways-to-use-microsoft-office-for-free/

There almost all <img> picture have a width=....  attribute
- all but one (!) which has NO such specification.
I mean the second last from the bottom which shows a text "Thanks for your 
interest in Office ...."

Have a look at the attached snapshot.

Here the resize to 70% from your script does NOT work (when I print it out to 
pdf).
In the resulting pdf doc this picture is BIG. All otherimages were shrinked 
successfully.

It seems to me that the width attribute must be present to be accessible from 
GM script.

Can this be?

Can your script somehow be modified to cover <img> with NO width=   attribute?

Ben

>Ok. 

>As for your questions 1 and 2 my answer is yes. And I refined a bit the 
>previous script so it can check on the actual 
>sizes and shrink them if they are more than 600px.

>And for question 3, if they are already loaded into the page, why do we want 
>to  pre -load them again?

>And the script:

>// ==UserScript==
>// @name        ChangeLayoutHowtogeek
>// @namespace   nsChangeLayoutHowtogeek
>// @description Change Layout HowToGeek
>// @include     http://*.howtogeek.com/*
>// @version     1.2.1
>// @grant       none
>// ==/UserScript==




>(function (){
>  var imgNodes = document.getElementsByTagName("img"),
>      imgNode,
>      i = imgNodes.length -1,
>      imgWidth;
>  
>  for (;;i--) {
>      imgNode = imgNodes[i];
>      imgWidth = imgNode.clientWidth;
>      if (imgWidth >= 600){
>          imgNode.style.width = "70%";
>          imgNode.style.height = "70%";
>          console.log('Image with client width: ' + imgWidth + 'px modified to 
> 70%');
>      }
>  }
>})();


>Ákos

>Feladó: [email protected]
>Elküldve: ?szerda?, ?2015?. ?január? ?7?. ?8?:?36
>Címzett: [email protected]




-- 
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.

-- 
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.

Reply via email to