Development :  K-Meleon Forum
K-Meleon development related discussions. 
macros.cpp
Posted by: slayer
Date: January 04, 2010 04:47AM

I was looking at this C++ file macros.cpp
case UWM_UPDATEBUSYSTATE:
 3384       {
 3385 		  if (wParam == 0) {
 3386          int index = FindMacro("OnLoad");
 3387          if (index != NOTFOUND)
 3388             ExecuteMacro(hWnd, index);
 3389       }
 3390       }
to see how the OnLoad Event works.
I don't understand much of C++, so I did a search, and I found this KMeleonCCF.
Quote

UWM_UPDATEBUSYSTATE message is send only when loading a page is finished. In K-MeleonSM 1.0 it's also send when loading of a page started with wParam = 1.
So, can we extend the IF condition to something like this?
 if (wParam == 0) && (wParam == 1) {
The idea would be to let the OnLoad Event to catch when a page starts loading too. Is this correct?

Options: ReplyQuote
Re: macros.cpp
Posted by: desga2
Date: January 05, 2010 01:55AM

Quote
slayer
if (wParam == 0) && (wParam == 1) {

You like said this:
if (wParam == 0) || (wParam == 1) {

Because wParam var can be zero (0) or one (1) but it never can't be 0 and 1 to the same time. tongue sticking out smiley

K-Meleon in Spanish



Edited 1 time(s). Last edit at 01/05/2010 01:56AM by desga2.

Options: ReplyQuote
Re: macros.cpp
Posted by: JujuLand
Date: January 05, 2010 02:59AM

What is the interest of the test if the value can be 0 or 1, just remove the test ...

A+


Mozilla/5.0 (x11; U; Linux x86_64; fr-FR; rv:31.0) Gecko/20100101 Ubuntu/12.04 K-Meleon/75.0

Web: http://jujuland.pagesperso-orange.fr/
Mail : alain [dot] aupeix [at] wanadoo [dot] fr





Edited 1 time(s). Last edit at 01/06/2010 04:10AM by JujuLand.

Options: ReplyQuote
Re: macros.cpp
Posted by: slayer
Date: January 05, 2010 07:18AM

grinning smiley yeah, sorry. I mean testing both conditions, that would be an OR, and not AND as I wrote in the first post, my mistake.
I really want to know it it is possible to execute a macro, inject js|cs before the page finishes loading.

Thanks in advance.

Options: ReplyQuote
Re: macros.cpp
Posted by: disrupted
Date: January 05, 2010 09:27AM

i tested this thing for so long, it gave me a headache..there doesn't seem to be an automatic way using event handlers to inject a js or any command before/while the page load.

in theory the opentab event should help but the problem with it (if you are using injectjs or injectcss) is that you need to place it in the new tab..right? but the opentab event will execute all your commands first before opening that..that includes fetching the url address.. in case you want to check a website's address before injecting your js. so what happens is, it gets the url address first(of the current tab/window) before it proceeds to open the tab so it doesn't work

one very dumb way i tried was by using the id(new tab with the opentab event and then using the utils plugin first to delay it, hoping that way it would get the urladdress for the new tab instead of the previous current tab but this caused an instant crash

the only way through the macro was by making a link menu command that opens the link in a new tab, and then injects the js..this does indeed inject the js during the page is loading but it's very unpractical because you will have to initiate it from a menu and second, you have no time to check the url..so the injected js will execute regardless if it's the right url or not, so you will need to write the url check in the js code itself and not in the macro..and ofcourse it wasn't foolproff even when the js was checking the page url because for example, if it did check the js but in the flick of time between checking the url and injecting, the user decided to switch tabs for any reason..it will inject in the wrong tab.

it seems the best way for injecting some specific js .. especially automated ones that should not require user intervention is through greasemeleon..which is flawed and painful, personally i had too much trouble with it and it seems the best practise for greasemeleon is having no more than 3 or 4 scripts.. they have to be very well coded, less than 32kb(not a problem for most scripts) and they must not conflict in anyway with one another..one conflicting script will break greasemeleon.

maybe in the future kko can make a nice event that initiates on pageload on preload? something like that..it will make it much easier.. for now, if you inject through macro, it will have to be on pageload and do not check page url, check for urlbar..or use greasemeleon with caution

Options: ReplyQuote


K-Meleon forum is powered by Phorum.