Show CSS background images from a page
Posted by: JohnHell
Date: July 16, 2012 04:45AM

As I needed this because more and more sites use background images via CSS (that don't let much interaction with K-meleon) I made an slightly change to the DocInfo_lstImages macro.

Before continue reading I warn that the following code is from the previous versions of K-meleon as I'm still those old and functional macros. There are few (very few) differences with the newer, as variables and some statements declarations changes, but the functionality is exactly the same. Indeed the code for this macro, almost all, has been carried from previous versions.

Why I tell this?, because if you want to adapt it to the new macro code (I mean from 1.x) would be better than me (that is the reason why I publish it here). Anyway, the difference, as it is added code, not modifications, can be added to the new macro without much dig, and is show in bold (in other color some styling changes, but not necessary for functionality) and all is inside the JSdoit declaration:


$JSdoit="var belem; var bgelem; var bgelema; var bgelurl; var bgtmpurl; var bgtmpurlL; if(getElementsByTagName('body')[0]){txt+='\\n<fieldset><legend>'+((title)?title:unescape(URL)).link(URL)+'</legend><ol>';cnt+=images.length;if(images.length){for(var j=0;j<images.length;j++){txt+='<li style=\"margin-top: 5px; padding: 10px; border-top: 1px solid green; border-left: 1px dotted orange\"><img src=\"'+(images[j].src)+'\"><br><a target=\"blank\" href=\"'+(images[j].src)+'\">'+(images[j].src)+'</a></li>\\n';}}cnt+=document.getElementsByTagName('*').length; if(document.getElementsByTagName('*').length){bgelem = document.getElementsByTagName('*').length; txt+='<br><b>BACKGROUND IMAGES</b>'; for(belem = 0 ; belem < bgelem; belem++){ bgelema = getComputedStyle(document.getElementsByTagName('*')[belem],null); if(bgelema.backgroundImage&&bgelema.backgroundImage!='none'){bgtmpurl = bgelema.backgroundImage; bgtmpurlL = bgelema.backgroundImage.length; bgelurl = bgtmpurl.substr(4, bgtmpurlL-5); txt+='<li style=\"margin-top: 5px; padding: 10px; border-top: 1px solid green; border-left: 1px dotted orange\"><img src=\"'+(bgelurl)+'\"><br><a target=\"blank\" href=\"'+(bgelurl)+'\">'+(bgelurl)+'</a></li>\\n';}}}}else{txt+='<p>'+nif+'</p>';txt+='</ol></fieldset>'}";

(it has been quoted to avoid forum deformation, remember to re-join each line)

Remember, in color, styling and just in bold the added code.

There are, also, several corrections with missing brackets '{' & '}' that also have been carried to the new macro. Maybe this can cause problems as caused to me this afternoon.

Edited 1 time(s). Last edit at 07/16/2012 04:50AM by JohnHell.

K-Meleon forum is powered by Phorum.