Quote
$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>'}";
Quote
siria
There is one catch, it lists ALL images on a page, not just background images, but especially all duplicates are listed x times too, which can get a bit much. If anyone finds a solution? :cool: I suspect you could, just didn't bother as long as it was only for yourself :-)
$lstdoitfile = readfile(getfolder(ProfileFolder)."\\macros\\listimages.js"); $JSdoit=$lstdoitfile;(listimages.js is the file I use myself )
$lstdoitfile = readfile(getfolder(ProfileFolder)."\\macros\\".$imgesjsfile); imgswitcher1{ $imgesjsfile = "listimages_img.js"; &_DocInfo_lstImages; } imgswitcher2{ $imgesjsfile = "listimages_css_img.js"; &_DocInfo_lstImages; } imgswitcher3{ $imgesjsfile = "listimages_complete.js"; &_DocInfo_lstImages; }
Quote
JohnHell
I was going to edit your macro to avoid you some work and it replied:
"Permission denied: links to files in the forum are only allowed from the forum itself."
Quote
(Update: Old version => deleted)
Quote
siria
Just a thought: perhaps decide automatically with a counter?
If <30 pics => show ALL
If 30+ pics => ask user
Would the <img> macro show the same as the native macro?
Because the native one eliminates duplicates...
Quote
siria
Well it does work to show definitely more images that otherwise I couldn't access at all For Bing there might be a workaround via UA, but doesn't help everywhere, e.g. not here - this needs your script to work:
www.piper.de/buecher/neuerscheinungen
And hey, there's no obligation to use hndlDocs if you prefer to use some other code instead. Just injectJS(code) can use the complete code.
Quote
JohnHell
The second is because of how the JS_hndlDocs/hndlDocs work. Can't do anything there.
Quote
siria
Glad you're doing the really complicated part
Quote
JohnHell
The second is because of how the JS_hndlDocs/hndlDocs work. Can't do anything there.
But that I still don't understand. Of course you can do it different, if you know a better code for this case. Why insist in using hndlDocs instead of just merging the definition and execution together, like a bookmarklet just multi-lines?
Quote
(Update: Old version => deleted)
Quote
siria
We both just want things to be cleanly organised
How about a compromise for the mind health of both, the developer and the user? Lets say we have the macro first try to read a js-file, for testing and understanding the code, and only if that's not found it uses the fallback code inside the kmm, for which the "complete" script would suffice IMO (=be enough)?
Quote
siria
With automatic exchange of the two numbers depending on the version (1.7 and earlier still had their version hardcoded in the readme-page, can readfile-it at startup for checking). After looking at your code, all lines end either with } or with ; so no prob at all to combine it
Quote
siria
Or better - just use a hardcoded switch in the kmm for decision of import and triple popup menu (vs no import and only 1 menu option "complete"):
$_DIM_extFiles=true/false ?
Thinking further about it, it now works so nicely, perhaps Dorian could just replace the native command with it??
Quote
You want easy to use and are thinking about telling an user to change a hardcoded value to avoid import?
#ß UTF-8 / K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage2) # ---------------------- DocInfoMore_multiversion.kmm v4 ---------------------- # Version: v4 / 2014-10-06 (CODE by JohnHell and KM / kmm by siria, copies from docinfo_more.kmm) # Forum/Web: http://kmeleonbrowser.org/forum/read.php?2,123209 # Menu : View > Images + Background (and context menu on page etc.) # KM version : KM74 (for KM1.6 use DocInfoMore16.kmm) # Dependencies : DocInfoMore_imgALL.js / DocInfoMore_imgCSS.js / DocInfoMore_imgIMG.js (macros folder) # Resources : [MacroFolder]\docinfo\docinfo.css # Preferences : kmeleon.plugins.macros.docinfo.forceTab.images # ----------------------------------------------------------------------------- # Shows the normal images in a page plus background images, all with URL. # Duplicates are in this version not removed. # ----------------------------------------------------------------------------- $_DocInfoMore_code_var_top_frag = "var belem; var bgelem; var bgelema; var bgelurl; var bgtmpurl; var bgtmpurlL; var imgarray = new Array(); var css_imgarray = new Array(); if(getElementsByTagName('body')[0]){ txt+='\\n<fieldset><legend>'+((title)?title:unescape(URL)).link(URL)+'</legend><ol>';"; $_DocInfoMore_code_IMG_frag = "cnt+=document.images.length; if(document.images.length){ imgarray.length = cnt; for(var j=0;j<document.images.length;j++){ if(imgarray.indexOf(document.images[j].src) == -1){ imgarray[j] = document.images[j].src; txt+='<li style=\"margin-top: 5px; padding: 10px; border-top: 1px solid green; border-left: 1px dotted orange\"><img src=\"'+(document.images[j].src)+'\"><a target=\"blank\" href=\"'+(document.images[j].src)+'\">'+(document.images[j].src)+'</a></li>\\n'; } } }"; $_DocInfoMore_code_CSS_frag = "cnt+=document.getElementsByTagName('*').length; if(document.getElementsByTagName('*').length){ bgelem = document.getElementsByTagName('*').length; css_imgarray.length = bgelem; txt+='<b>BACKGROUND CSS IMAGES</b>'; for(belem = 0 ; belem < bgelem; belem++){ bgelema = getComputedStyle(document.getElementsByTagName('*')[belem],null); if(bgelema.backgroundImage&&bgelema.backgroundImage != 'none'){ bgtmpurl = bgelema.backgroundImage; /* alert(bgtmpurl); */ bgtmpurlL = bgelema.backgroundImage.length; /* alert(bgtmpurlL); */ bgelurl = bgtmpurl.substr(5, bgtmpurlL-7); /* alert(bgelurl); */ if(css_imgarray.indexOf(bgelurl) == -1){ css_imgarray[belem] = bgelurl; txt+='<li style=\"margin-top: 5px; padding: 10px; border-top: 1px solid green; border-left: 1px dotted orange\"><img src=\"'+(bgelurl)+'\"><a target=\"blank\" href=\"'+(bgelurl)+'\">'+(bgelurl)+'</a></li>\\n'; } } } }"; $_DocInfoMore_code_bottom_frag = "} else { txt+='<p>'+nif+'</p>'; txt+='</ol></fieldset>';}"; _1_6fix{ $_readmecheck = readfile(getfolder(RootFolder)."\\readme.html"); if($_readmecheck != ""){ if(index($_readmecheck, "1.7") == -1){ $_DocInfoMore_code_CSS_frag = gsub("bgtmpurl.substr(5, bgtmpurlL-7);", "bgtmpurl.substr(4, bgtmpurlL-5);", $_DocInfoMore_code_CSS_frag); } } } DocInfoMore_imgIMG{ macroinfo=_("View all <img> images in the current page"); $_code = $_DocInfoMore_code_IMG_frag; &_1_6fix; &_DocInfoMore_Page; } DocInfoMore_imgCSS{ macroinfo=_("View all CSS-images in the current page"); $_code = $_DocInfoMore_code_CSS_frag; &_1_6fix; &_DocInfoMore_Page; } DocInfoMore_imgALL{ macroinfo=_("View all images in the current page"); $_code = $_DocInfoMore_code_IMG_frag.$_DocInfoMore_code_CSS_frag; &_1_6fix; &_DocInfoMore_Page; } DocInfoMore_Frame{ macroinfo=_("View all images in the current frame"); $_code = $_DocInfoMore_code_IMG_frag.$_DocInfoMore_code_CSS_frag; &_1_6fix; &_DocInfoMore_lstImages; $ExecMacros="JS_hndlDoc"; $ForceTab=$_DocInfo_ForceTab; $JS_doit==""?0:&ExecMacros_Popups; } #------------------ _DocInfoMore_Page{ &_DocInfoMore_lstImages; $ExecMacros="JS_hndlDocs"; $ForceTab=$_DocInfo_ForceTab; $JS_doit==""?0:&ExecMacros_Popups; } _DocInfoMore_lstImages{ $_DocInfo_ForceTab=getpref(BOOL,$macroPrefBranch."docinfo.forceTab.images"); $JS_func="with(document)var cnt=0,nif='"._("No images found.")."',tit='"._("Images: %s")."'.replace(/%s/,(title)?title:unescape(URL)),txt='';"; # $JS_doit = $_DocInfoMore_code_var_top_frag.$_code.$_DocInfoMore_code_bottom_frag; # $JS_last="if(cnt){var imgWin=open('','kmIMG'+Math.floor(Math.random()*1000),'".$_DocInfo_PopupStyle."'); with(imgWin.document) {open(); write('<html><head><title>'+tit+'</title> <style type=\"text/css\">\\n".gsub("\n","\\n",readfile($_DocInfo_StyleSheet))."\\n</style> </head>\\n <body class=\"km_DocInfo_lstImages\">'+txt+'\\n</body></html>'); close()}} else alert(nif)"; $JS_fail=$_DocInfo_FrameError; $_code = ""; } _DocInfoMore_BuildMenu{ $_menu="Images + Background"; setmenu($_menu,macro,"IMG Images",DocInfoMore_imgIMG); setmenu($_menu,macro,"CSS images",DocInfoMore_imgCSS); setmenu($_menu,macro,"ALL Images",DocInfoMore_imgALL); # # In "View" and in context menus) setmenu(ImageProperties,popup,$_menu,"&Background Image"); setmenu("Page Pro&perties",popup,$_menu,"Im&ages"); setmenu("Page &Properties",popup,$_menu,"Im&ages"); # setmenu("Frame &Properties",macro,"Images + Background","DocInfoMore_Frame","Im&ages"); } # ----------------------------------------------------------------- $OnInit=$OnInit."_DocInfoMore_BuildMenu;"; $macroModules=$macroModules."DocInfoMore74;";
Quote
(Update: Old version => deleted)