Extensions :  K-Meleon Web Browser Forum
All about K-Meleon extensions. 
Greasemonkey scripts as macros for K-Meleon
Posted by: rodocop
Date: November 03, 2017 02:34PM

Playing with userscripts and macros I've created a little pool of KMMs, integrating some useful GM-scripts.

Macros are all based on the old good Linkify macro by Matt (c)

But even this one was updated with new js-file url.

Moreover, I've created the special 'Userscripts' page on The K-Meleon Place where not only those macros and scripts are catalogized but also JS-files themselves are backed up in order to not disappear if original links suddenly will die.

And some of macros even use working link to JS-file from weebly - not from origin (Greasyfork or else) because our macroroutine cannot handle links with UUEncoded chars like %20 (space) etc.

So welcome to the page and feel free to try some new useful macros!


Page to be updated with more scripty macros as soon as they are ready.



Edited 3 time(s). Last edit at 11/03/2017 02:36PM by rodocop.

Options: ReplyQuote
Re: Greasemonkey scripts as macros for K-Meleon
Posted by: rodocop
Date: November 03, 2017 09:25PM

Quote
siria
Hmm, speaking of "good old macros" as template...
Just a few more basic macro explanations :cool:

$OnLoad:
This text variable is a little list for the names of several macros that shall run automatically. That means they will all be executed after each and every page load of whatever domain. No exceptions. All listed macros, on all URLs.

That also means, if the action of a macro is, for example, to download a 3MB script from an external server, then it downloads those 3MB from that server after EVERY page load too, on whatever domain. Not sure if from the second page it loads only from cache perhaps, but probably depending on user settings.

menugrayed:
Only used to gray out an entry in a menu, so that a user cannot call it manually by MENU (all other means still work, by shortcut or button, automatic by $OnLoad, or called by another macro).
If the macro is not called by a setmenu-line however, graying that line out is useless.

If a macro shall only run on specific domains, an "if" condition is necessary instead of "menugrayed."

And would check the "injectJS" command, very handy...
The main advantage over "open(JS)" is that scripts fired by injectJS run even if the user has blocked JS. For most little macros that's enough, only if afterwards the user needs JS yet again it must be switched on.


Options: ReplyQuote
Re: Greasemonkey scripts as macros for K-Meleon
Posted by: rodocop
Date: November 03, 2017 09:37PM

Well, I post this mostly for such comments and testing.

There are number of esoteric and mystifying things in KMML for me.

For example this hostname() seems to work even called from menugrayed (I know that it is intended for what you describe, siria).

Moreover, I found that one conditional statement starting another my macro (privoxy.kmm) seems to work even not being called anyway - but it does its job and I cannot understand this

So I should say that 3mb script seems to be NOT loaded with EVERY page in fact. Don't know why ;-)

Also I was thinking about InjectJS (I recall that open was just a workaround for failing injectJS in KM 1.7). But I'm not sure about how to use it right with ready js-files.

I remember that we can use your StyleScriptia for that job, but it's too complex for me (and most average users).

I'm going to try saving file locally in browser folder and call it through readfile() routine but... not sure this will work...

So your help, siria would be invaluable as you have got StyleScriptia finished and working.



Edited 1 time(s). Last edit at 11/03/2017 09:38PM by rodocop.

Options: ReplyQuote
Re: Greasemonkey scripts as macros for K-Meleon
Posted by: rodocop
Date: November 03, 2017 09:47PM

I have very strange experience for now with all that UserScripts stuff:

I was able to get partly working GreaseMonkey 2.3.1 in KM 75 earlier but failed to reproduce it now.
In KM 76 Greasemonkey doesn't work at all.

But my macro for Youtube Center works from time to time in the same installation - and when it fails, I cannot understand why (it says - in console - something about CORS and cross-domain restrictions but next time can work again :O).

Google Search Extra Buttons work fine as I can see, and AntiAdware script seems to work fine at least on https://get.adobe.com/flashplayer/ (I had no opportunity to check its work on other sites). And URLcleaner is not very obvious to check whether it works or not. But it produces a lot of errors in console.
Linkify works fine but it's based on simple bookmarklet, not GM-script. But (one more iteration) its code calls 3rd party JS as well as other macros call GM-scripts...

And so on. I just want add some useful functions to KM by minimal effort. May be its better to create config for StyleScriptia?

I don't know for now.



Edited 2 time(s). Last edit at 11/03/2017 09:51PM by rodocop.

Options: ReplyQuote
Re: Greasemonkey... / macrolanguage
Posted by: siria
Date: November 03, 2017 10:16PM

Let's copy this growing discussion to the special macrolanguage-thread
http://kmeleonbrowser.org/forum/read.php?2,141642
and then delete those offtopic-posts here and in ExEx-thread, what do you think?
Just not sure where to start exactly over at ExEx, perhaps at Nov-1 when you asked for a set of examples...?

Options: ReplyQuote
Re: Greasemonkey... / macrolanguage
Posted by: siria
Date: November 04, 2017 02:18AM

$OnLoad runs always, really.
For checking simply add a test alert somewhere, inside the kmm or the js-file itself
KM: alert("","test macro XY");
js: alert('test macro XY');

Can't help suspecting that you still have a misunderstanding about menugrayed... as well as hostname... Those are no commands, they do not "run" anything.

================

open("javascript:xxxx");
is the same as
injectJS("javascript:xxxx");
or simply
injectJS("xxxx");

The difference is that injectJS works also if JS is blocked by user.
Personally I prefer for longer scripts to put the code into a macro var first and then call
injectJS($_code);

In KM76 there are yet more syntax possibilities, but am not familiar.

================

If you use "readfile" remember there's a length limit (64kb since KM75)
If too long, it simply gets cut in the middle, this can also produce errors

================

Instead of StyleScriptia (uses readfile+appendfile) take a look at StyleonMini that's easier (uses only appendfile). It contains also notes about necessary prefs etc.

The core function is really just such a little "append" script snippet, very similar to linkify:
$_code="(function() {var file=document.createElement('script'); file.type='text/javascript'; file.src='".$_file2."'; document.body.appendChild(file);})();";
All the other complicated stuff in it is just for convenience, errorchecks, prefchecks, userinterface, old+new KM versions etc.

But frankly that whole userscript stuff drove me crazy back then too!! (and long since forgotten again of course) Especially because I always try to write macros for all KM versions old and new, and each has other bugs or procedures, and especially all the new "security" blocks in newer gecko versions are a pain - if like my you have no clue about non-macro code and even hardly any about JS at all, sigh. And all those KM7X-beta versions at the time still had a lot more bugs as (hopefully) KM76RC now. Dorian has meanwhile updated macros.dll.
Hmm... and one of those unbearable 'security improvements' was that a new gecko (in 76alpha??) didn't allow anymore to append a LOCAL script at all. Meanwhile have forgotten if it could be fixed by some pref (fileuri?) or if Dorian changed something or if it's even still broken?! Another prob in one of those earlier versions was that "open(javascript:...)" was suddenly forbidden by Mozilla! But this one obviously really was fixed now.

================

Another thought: since you're automatically running so many scripts at every page load, all at the same time, could it be they cause conflicts? Does the errorconsole tell about which one of those scripts it's complaining...?



Edited 4 time(s). Last edit at 11/04/2017 02:40AM by siria.

Options: ReplyQuote


K-Meleon forum is powered by Phorum.