Extensions :  K-Meleon Web Browser Forum
All about K-Meleon extensions. 
Pages: 1234Next
Current Page: 1 of 4
Show CSS background images from a page
Posted by: JohnHell
Date: July 15, 2012 09:45PM

2019-10-05:
- left dumb bug with hashed about blank, new 11.1

2019-10-03:

- new version 11 to fix K-meleon 76 compatibility
- full rework of the JavaScript script with new SVG, and "data:" images capturing

2015-04-07:

- Minor cosmetic change
- Readme change to reflect K-meleon 75 compatibility and above.

(I know I shouldn't name it version 10 but "I live in the edge", as actual versioning standards work (minor upgrade = high number change) xD)


2014-11-25:

- Fixed duplicated images results when iframes are found
- Fixed nested images from different iframes
- Fixed display correct images when iframes are found
- Fixed display correct CSS images from iframes
- Changed the way "Bacground CSS images" title is shown. Now only when there is at least 1 CSS bacground image.


2014-10-25: Fixed a minor error en MacroModule line.


2014-10-07: DocInfoMore.kmm version 8. The most updated version is attached to this post.





THE FOLLOWING TEXT IS THE ORIGINAL POST, LEFT FOR LEGACY PURPOSES


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:

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>'}";

(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 12 time(s). Last edit at 10/06/2019 12:11AM by JohnHell.

Attachments: DocInfoMore_public_v10.zip (3.5 KB)   DocInfoMore_public_v11.2.zip (5.7 KB)  
Options: ReplyQuote
Re: Show CSS background images from a page
Posted by: siria
Date: October 04, 2014 03:51PM

Thanks for the script! Very handy really.
Actually just lately I had serious probs myself with getting access to background images, so did now as you wished and embedded it in a macro grinning smiley
Struggled again with much trial&error, until I finally studied word for word your detailed instructions, should have done it first, hehe.

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 :-)

So far only tested it in KM1.6. Does it work in KM74 too??
(Test page: bing.com with UA Firefox)

DOWNLOAD:
(Update: Old version => deleted)
This is just a renamed kmm file, because kmm is not allowed to upload.
Just rename again to DocInfoMore.kmm and throw into macros folder.

Menu: View > Images + Background

PS: Could we move this thread into extensions subforum, for attachments?



Edited 1 time(s). Last edit at 10/06/2014 10:36PM by siria.

Options: ReplyQuote
Re: Show CSS background images from a page
Posted by: JohnHell
Date: October 04, 2014 04:43PM

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 :-)

Yes, I know smiling smiley, but it is the big problem with CSS sprites: showing portions of an image with css coordinates.

I thought of a workaround. I think about it each time I find a page with loads of use of a sprite.

But let's see an example (enlarge it if you want):



Here we have a sprite of about 900 possible icons/calls to it inside in a page.

I could try add the name of the sprite in an array, but then I'd have to check the name against the array.

Now imagine that in a page, not only that image with 900 possible icons, and with tons of additional images and sprites, the CPU cycles lost on calculating it would be crazy.

Let's go now to a real use of the macro. Go to YouTube front page and use the macro.

We face over 2500 image references and look how long it takes. In my Pentium 4 that means the the stop script window appears 2 times.

And the script is only retrieving the images. Now add a check for each of the 2500 image references.

Crazy, isn't it? winking smiley

What could be done is make the macro switchable or split the code in two or three macros:

- one for normal <img>
- one for CSS background images
- one for both

Options: ReplyQuote
Re: Show CSS background images from a page
Posted by: siria
Date: October 04, 2014 07:34PM

YIKES.... *dropdead*

Yeah a split into several macros would certainly be best...

Options: ReplyQuote
Re: Show CSS background images from a page
Posted by: JohnHell
Date: October 04, 2014 09:02PM

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

:-?

Anyway, these are the standalone files.

I preferred the use of js files and K-meleon readfile and getfolder functions for the health of our minds. It is easier to read the files this way instead all the code in one line (thanks for your past tip smiling smiley)

With these links you won't be able to view the files directly in 1.6 but you can use the download button at the top right. If you have problems, tell
Show only <img> tag images (as it was the original macro javascript code)
Show only the images displayed with CSS (background-images)
Show all, as the code at the beginning of this thread

To combine this with the readile and getfolder functions I added/replaced the following, choosing for getfolder the profile folder, as is were I place my macros, but you could use other:

$lstdoitfile = readfile(getfolder(ProfileFolder)."\\macros\\listimages.js");

$JSdoit=$lstdoitfile;
(listimages.js is the file I use myself confused smiley)

And I think I haven't left anything...

EDIT: yes, I forgot about a pref to save the options to switch too...

Better if I could see/edit your code.



Edited 3 time(s). Last edit at 10/04/2014 09:07PM by JohnHell.

Options: ReplyQuote
Re: Show CSS background images from a page
Posted by: JohnHell
Date: October 04, 2014 09:30PM

Easier for options.

Each of the three switchers is a menu entry.

The first line is to replace what I posted above inside _DocInfo_lstImages;



$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;
}


Options: ReplyQuote
Re: Show CSS background images from a page
Posted by: siria
Date: October 04, 2014 10:08PM

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

Huh?? Not sure what you're saying - can you not download it? Just tested again and it works without any probs, since of course this is an inside-forum-link... Or what else....? *riddling*

@Mods: can anyone please move this to extensions forum?

Options: ReplyQuote
Re: Show CSS background images from a page
Posted by: JohnHell
Date: October 04, 2014 10:11PM

Yep, the forum doesn't let me to download it :-?

Guenter, we call you, appear and change this to extensions winking smiley

EDIT: another facepalm... right clicking ....



Edited 1 time(s). Last edit at 10/04/2014 10:23PM by JohnHell.

Options: ReplyQuote
Re: Show CSS background images from a page
Posted by: siria
Date: October 04, 2014 10:23PM

That is absolutely weird. Could it be something with your browser, or could it have to do with a renamed 7z file?? Anyway, try if you can download the attachment from the direct post here, at the end:
http://kmeleonbrowser.org/forum/read.php?10,129652

With mediafire I in turn have probs, not possible with js blocked and I hate it to open such sites all doors wide open tongue sticking out smiley
You know we can also post code directly in a posting?
Tsss.... or I can of course do that as well!

EDIT: LOL! Thanks for restoring my faith in forum downloads grinning smiley grinning smiley
EDIT-3: This version only works in KM1.6, renamed the macro and commands. This version is complete, no additional js-files needed.

Quote

(Update: Old version => deleted)



Edited 5 time(s). Last edit at 10/06/2014 10:37PM by siria.

Options: ReplyQuote
Re: Show CSS background images from a page
Posted by: siria
Date: October 04, 2014 10:49PM

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

Options: ReplyQuote
Re: Show CSS background images from a page
Posted by: JohnHell
Date: October 04, 2014 11:15PM

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


I'm discovering that the original script has been changed somewhere between my initial post in 2012 and now so, my script isn't being handled correctly.

The problem is that I'm using the old macros that didn't give me these headaches. I'll have to review the code again U_U, but not today.

I see now that there is an array to add the urls too for further check. I didn't see that :/

Even I'm seeing getting input elements O_O don't know why...

EDIT: in a quick look...
why who did this code can't add brackets {} where they should? really? the old code was a nightmare and this is worst.



Edited 2 time(s). Last edit at 10/04/2014 11:23PM by JohnHell.

Options: ReplyQuote
Re: Show CSS background images from a page
Posted by: siria
Date: October 04, 2014 11:29PM

Well it does work to show definitely more images that otherwise I couldn't access at all smiling smiley 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.



Edited 1 time(s). Last edit at 10/04/2014 11:37PM by siria.

Options: ReplyQuote
Re: Show CSS background images from a page
Posted by: JohnHell
Date: October 05, 2014 12:03AM

Quote
siria
Well it does work to show definitely more images that otherwise I couldn't access at all smiling smiley 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.

In fact the bigger problem is the JS_hndlDocs.

The old definition is this:

injectJS($JSfunc.$JSurlencode."function hndlFrm(w){try{with(w.document){".$JSdoit."}}catch(e){".$JSfail."}for(var j=0,f=w.frames;j<f.length;j++)hndlFrm(f[j])}hndlFrm(window);".$JSlast);

The new is this:

injectJS("(function(){".$JS_func.$_JS_urlencode."function hndlFrm(w){try{with(w.document){".$JS_doit."}}catch(e){".$JS_fail."}for(var j=0,f=w.frames;j<f.length;j++)hndlFrm(f[j])}hndlFrm(window);".$JS_last."})()");


Can you see the difference? there is an autoexec function. That, and to be fair, I don't know why, breaks everything. That little change.

I could add the old hndlDocs and forget about this one, but that will trash a little the code.

And the funny thing is that it doesn't need it because hdnlDocs and injectJS already autoexecs

I'm not trying to throw trash to who did this (probably Dorian) but for me is quite confusing.

Options: ReplyQuote
Re: Show CSS background images from a page
Posted by: JohnHell
Date: October 05, 2014 12:27AM

And Siria, how is it that the macro modification you posted works for you?

I run in a clean profile and it doesn't display the images. Also it doesn't make the links with a working link. The text link is correct. The link itself not.





Edited 1 time(s). Last edit at 10/05/2014 12:27AM by JohnHell.

Options: ReplyQuote
Re: Show CSS background images from a page
Posted by: siria
Date: October 05, 2014 12:50AM

AAARGH.... you're right, it only works in KM1.6, not 1.7, so probably not in KM74 either! sad smiley sad smiley

In fact I noticed some time back, while struggling with my stylescriptia macro that some js-codes in KM1.7 needed such an additional function-wrap around it, or didn't work at all. In KM1.6 all was fine without it.
Houston...

Ah yes, and with other scripts it was exactly the other way around in KM1.7 - those did only work WITHOUT that function!! Really drove me crazy and couldn't find a real solution for that :-( Only have a toggle-functionwrap command in the stylescriptia-debug-menu, and struggling with such stuff forever.

Basically all those unsolvable JS probs started with KM1.6, since then commands containing JS had to be the last line or the next ones would be executed before, out of order! And KM1.7 was much worse yet.
Still in dire need that macros get executed in correct line order again :-(
If all else fails, a macrocommand that stops the next lines for half a second would already be a giant help.



Edited 1 time(s). Last edit at 10/05/2014 01:01AM by siria.

Options: ReplyQuote
Re: Show CSS background images from a page
Posted by: JohnHell
Date: October 05, 2014 08:17PM

Version 2.

Those who downloaded the separate js files, redownload them again as have been changed.

I need just to confirm if the menus are correctly set as I'm a disaster with setmenu winking smiley For the rest it should work.

I included the array check to avoid duplicates and it amazed it didn't took as long as I thought. Yay!

Known issues:

- won't alert when there aren't any actual CSS background images
- somes pages, with iframes and similar elements force to have repeated lists but it is not the script culprit

The first happens because there isn't an error in the script and therefore, there is no warning at the end.

The second is because of how the JS_hndlDocs/hndlDocs work. Can't do anything there.



Edited 1 time(s). Last edit at 10/05/2014 08:18PM by JohnHell.

Options: ReplyQuote
Re: Show CSS background images from a page
Posted by: siria
Date: October 05, 2014 08:46PM

Glad you're doing the really complicated part smiling smiley

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?

Options: ReplyQuote
Re: Show CSS background images from a page
Posted by: siria
Date: October 05, 2014 09:23PM

I'm starting to see why you think menus were complicated grinning smiley
Guess it would work, but anyway, simplified it:

_DocInfoMore_BuildMenu{
$_menu="Images + Background";
setmenu($_menu,macro,"IMG Images",lst_option_img);
setmenu($_menu,macro,"CSS images",lst_option_css);
setmenu($_menu,macro,"ALL Images",lst_option_complete);
#
# 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",popup,$_menu,"Im&ages");
}

The frame variant is lost at the moment, will add it again somehow.



Edited 1 time(s). Last edit at 10/05/2014 09:24PM by siria.

Options: ReplyQuote
Re: Show CSS background images from a page
Posted by: JohnHell
Date: October 05, 2014 09:35PM

Quote
siria
Glad you're doing the really complicated part smiling smiley

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?

Because I admit I don't/didn't fully understand the original macro divided in JSfunc, JSdoit, JSfail and JSlast.

Also because hndlDocs also has a check error and I think it is helpful.

Consider me with this code as a child holding his mom hand.

In computing terms, if it works, don't touch it confused smiley I'm fearing of what could happen letting the code running freely.

Even if it looks I know a lot, when errors come I lose too much time searching here and there as I don't have a deep knowledge.

From now, I won't jump that bridge winking smiley

By the way, all my injectJS depending macros work on 74 GRE31.


About the menus, we'll wait to change it. At the moment works, so not harrash for anyone.

Options: ReplyQuote
Re: Show CSS background images from a page
Posted by: siria
Date: October 05, 2014 11:36PM

Of course I have far less clue than you about JS (near zero), but are you sure it would make the code worse if you just copy over the three hndl-docs-lines from main.kmm into this macro and merely insert more brackets?

But guess what?? Now it doesn't work anymore in KM1.6!" sad smiley
I half expected it... sigh, JS stays a nightmare since the gecko in KM1.6
And in KM1.7 both versions don't work at all, as so often.
In KM1.6 the structure looks good, but has empty image placeholders.

Sure glad we still have your first version! smiling smiley
==> Would it be much work if you eliminate the duplicates in v1 too, now that you know how...? :cool:




And here's my version 3 of the macro.
John's 3 script files from above must be added and renamed.

Aside from renaming the commands and files (for better readability, your view may vary grinning smiley) there's now a frame-only command again, and a little error check if the js-file is missing.
Macro+Files work from both macros folders.
When there's a final version, it would be easier to include the full scripts again in the kmm. Half of the script lines could be saved when using a text-variable to puzzle together only the needed parts - or perhaps it would suffice now only the "complete" version? Since there are far less images without the duplicates?

Quote

(Update: Old version => deleted)



Edited 4 time(s). Last edit at 10/06/2014 10:39PM by siria.

Options: ReplyQuote
Re: Show CSS background images from a page
Posted by: JohnHell
Date: October 06, 2014 12:32AM

Suffer? Won't suffer to split it and then rejoin with $1.$2. Anyway, doing it we will be "only" saving 2000 bytes, it isn't a big waste.

But for cleanliness I prefer it in a separate way. It is easier to track the code. After you gave me the candy of external files (that can be with formatted text inside), don't take away from me tongue sticking out smiley Also you have to take care of the use of the different escape characters in one line, what is not needed as it is now.

If fact, the code in one line must be changed again. Minor changes, but more than the waste of space is the waste of time editing the code, than making it single line and again if needed.

I undesrstand why you want it. Just a kmm file without depending on external resources, but can be as the docinfo folder and docinfo.css, placing them in a separate folder to avoid mixing things.

As I said above is for mind health. My mind health tongue sticking out smiley (selfish I know)

1.6: not the new code, but the "new" before I added the duplicate check was being used in 1.6 (I developed it when I was using 1.6). I'll check to see what errors are giving. It's strange.

Options: ReplyQuote
Re: Show CSS background images from a page
Posted by: JohnHell
Date: October 06, 2014 12:58AM

Ok, 1.6 fixed

There was something I barely remember I did.

It bugged me and probably that's the reason I left the three alerts for when I changed to K-meleon 74. Something in the javascript core was changed that added quotes :-?

If you don't want/can't download the files, just replace the text "bgtmpurl.substr(5, bgtmpurlL-7);" with "bgtmpurl.substr(4, bgtmpurlL-5);" without quotes in the files listimages_css_img.js and listimages_complete.js. There is only one reference in both.

listimages_css_img_1.6.js

listimages_complete_1.6.js

EDIT: by the way, as you can see, separate files can help to develop for different versions too winking smiley



Note aside about the above, instead rejoin the code inside kmm, it could be joined the content of the separate files. That could save bytes too.



Edited 1 time(s). Last edit at 10/06/2014 01:11AM by JohnHell.

Options: ReplyQuote
Re: Show CSS background images from a page
Posted by: siria
Date: October 06, 2014 07:39AM

YES it works again! smiling smiley smiling smiley smiling smiley
What a difference a single character can make sometimes.

We both just want things to be cleanly organised grinning smiley
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)? 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 smiling smiley

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



Edited 2 time(s). Last edit at 10/06/2014 07:48AM by siria.

Options: ReplyQuote
Re: Show CSS background images from a page
Posted by: JohnHell
Date: October 06, 2014 11:33AM

Quote
siria
We both just want things to be cleanly organised grinning smiley
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)?

I still don't see the big deal with users health here.

We have loads of extensions that depends on different files with instructions where to place them and I don't see much users complaining/whining.

Why would happen with this one?

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 smiling smiley

Isn't there any version call?

It's not impossible but looks like you like to complicate things LOL tongue sticking out smiley

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

I think I didn't get a word of this tongue sticking out smiley

You want easy to use and are thinking about telling an user to change a hardcoded value to avoid import?


I won't be available til 15:00 (GMT+2) or so, but would be interesting if we contact through, for example, MSN (here I have the same mail as the nickname here), ICQ or Ymsg. It wouldn't take so long to discuss things winking smiley

Options: ReplyQuote
Re: Show CSS background images from a page
Posted by: siria
Date: October 06, 2014 01:14PM

Quote

You want easy to use and are thinking about telling an user to change a hardcoded value to avoid import?

Not normal users, only those who want to inspect or play with the js-code. And those sure are able to switch it in the kmm smiling smiley
Just trying to cover the different wishes and possibilities.
The macro can be shipped incl. the js-files, and read them by default. But if a user loses them somehow because he doesn't remember what they were for and just trashes, or renames or moves them or whatever messed them up, the macro can still work.

And the menu could optionally have lesser submenus to pop up, if the js-files are intentionally disabled and the fallback only uses the "complete" script version. Now that there isn't a flood of duplicate pics anymore, that would be my preferred version by far, and I strongly suspect that of of the vast majority too.
Well have to see how to do it exactly, will do a new demo version later today.

Options: ReplyQuote
Re: Show CSS background images from a page
Posted by: JohnHell
Date: October 06, 2014 01:22PM

I only post the following code to highlight changes. Please, consider to copy it from here because I had to remove code as the forum gave errors: http://www.geocities.ws/jothache/codigov4.html


No files anymore for distribution.

Polish as you wish.

EDIT: I didn't remove the 1.6 reference in the description.

This is a multiversion macro now.


#ß  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;";



Edited 1 time(s). Last edit at 10/06/2014 01:24PM by JohnHell.

Options: ReplyQuote
Re: Show CSS background images from a page
Posted by: JohnHell
Date: October 06, 2014 03:00PM

Latest version and probably the last unless you polish it:

DocInfoMore_multiversionv5.kmm

It includes a workaround to warn when not found CSS background imges.



Edited 1 time(s). Last edit at 10/06/2014 03:01PM by JohnHell.

Options: ReplyQuote
Re: Show CSS background images from a page
Posted by: siria
Date: October 06, 2014 04:09PM

Uff... Of course I was just done with v4 tongue sticking out smiley Okay, hope I caught the differences, but a quick test in KM1.6 still works NICE smiling smiley There is just always some harmless little complaint at the end of the page, but that was before too.

Thanks for letting me play with it. If a macro works and someone else does the nerve-wrecking JS it's just fun grinning smiley

EDIT: Oops - had the old version first, replaced it again!

Quote

(Update: Old version => deleted)



Edited 5 time(s). Last edit at 10/06/2014 10:40PM by siria.

Options: ReplyQuote
Re: Show CSS background images from a page
Posted by: JohnHell
Date: October 06, 2014 06:43PM

You really like to change things or you are just trying to make me go crazy tongue sticking out smiley

What was the complain about?



I fixed a couple of errors you introduced I don't know how or probably it was the forum winking smiley

DocInfoMore_v6.kmm

I also removed the warning for non CSS backround images found. I found an error and I learned a new thing about arrays. And until I found or think any better way (I know a way but I don't like it) for the future, I leave it as it is now. But I swear it worked before I uploaded. Probably some mistake with the tests :-?

Anyway this is final.



Edited 1 time(s). Last edit at 10/06/2014 06:43PM by JohnHell.

Options: ReplyQuote
Re: Show CSS background images from a page
Posted by: siria
Date: October 06, 2014 07:39PM

It's v7 :cool: ;-)

Hmm, not sure what happened. Have only played with macrolanguage, and I see you only modified the javascript again now. But as far as that code is concerned I didn't touch a thing, didn't even waste time studying it, cause I wouldn't understand it anyway. Only removed some whitespace tabulators inside, which have no function anyway, and when the forum complained inserted a blank between < br. Afterwards it still did work perfectly fine. When I now doublecheck the posted code above it's also still identic with my v6, so the forum is innocent.
Anyway, if I did change anything inside the javascript that was by pure accident, sorry, some copy/paste-error or no idea.

Can someone PLEASE move this to extensions now so that the macro can be attached?

PS: You can remove the "1.7 ?" in the header. Just noticed it does work in 1.7 too when not only JS but also Popups are allowed manually before executing the macro.
Don't know about 74 + 74g31, if it also needs one or both first toggled. Perhaps you can make a note about that in the header too?
In 1.6 and earlier JS and Popups can stay blocked, no prob.

Since this is now final the v in the name isn't needed anymore, and I think I'm going to edit my posts above and remove the old versions.



Edited 4 time(s). Last edit at 10/06/2014 08:13PM by siria.

Options: ReplyQuote
Pages: 1234Next
Current Page: 1 of 4


K-Meleon forum is powered by Phorum.