Extensions :  K-Meleon Forum
All about K-Meleon extensions. 
About functions
Posted by: adodupan
Date: May 21, 2011 11:53PM

Take for example macro _example1, file abc.js and function a() inside file:

_example1{
injectJS(readfile(getfolder(MacroFolder)."\\abc.js"));
open("javascript:void(function(){a()})()");
}

You can try javascript function in a simple and fast way, just paste in URLBAR:
javascript: <code between the curly braces {}>
For example:
javascript:alert('Hello');
If everything is fine, you can use macrolanguage and injectJS() - for example:
injectJS("javascript:alert('Hello');");
javascript must be enabled!!

Is it possible to call js files, or functions inside chrome (jar files) with macros?
Answer is no!



Edited 1 time(s). Last edit at 12/23/2012 08:34AM by adodupan.

Options: ReplyQuote
Re: About functions
Posted by: disrupted
Date: May 22, 2011 12:55AM

you can't inject a js from chrome using readfile command because it's not able to read from a chrome jar-compressed folder. there's not much need for it and normally in kmeleon, the js is either coded inside the macro itself or called from a nornal file path, usually a 'scripts' folder in k-meleon's root. you can make kmeleon call a xul file inside the jar using open command that xul may call the js inside its own jar or another registered jar. the xul can be coded as simple xhtml window just to call the js but it's much easier/practical to have the js in kmeleon's root or scripts folder if its function isn't linked to a xul extension.

Options: ReplyQuote
Re: About functions
Posted by: adodupan
Date: May 22, 2011 01:43AM

Flashblock v.1.5.13



Edited 1 time(s). Last edit at 12/22/2012 12:33PM by adodupan.

Attachments: Flashblock v.1.5.13.7z (63.3 KB)  
Options: ReplyQuote
Re: About functions
Posted by: adodupan
Date: June 07, 2011 09:01PM

MOVED



Edited 1 time(s). Last edit at 07/07/2011 09:04PM by adodupan.

Attachments: win7_km16_HKCU.reg (13 KB)  
Options: ReplyQuote
Re: About functions
Posted by: adodupan
Date: September 23, 2011 03:12AM

Last week i read that Nick wants to open websites in other browsers and it fails. This is irrelevant, but sometimes it can bother users. I've tried all the extensions, but none passed my criteria. So, i wrote a universal code for easy opening websites in any browser.
With this km macro, the end user can simply add an item on the menu for every browser (the user can also easily delete any item from the menu). It is not necessary to restart km, after selecting the exe file, the item will appear in the menu.

To add items:
Tools > Open in browser > Add a new browser
To open a website you need to right click.
It is not necessary to restart km for any action.

browser.kmm v.0.4



Edited 4 time(s). Last edit at 03/15/2013 05:23AM by adodupan.

Attachments: browser v.0.4.7z (1.6 KB)  
Options: ReplyQuote
Re: About functions
Posted by: ndebord
Date: September 23, 2011 06:44AM

Quote
adodupan
Last week i read that Nick wants to open websites in other browsers and it fails. This is irrelevant, but sometimes it can bother users. I've tried all the extensions, but none passed my criteria. So, i wrote a universal code for easy opening websites in any browser. With this km macro, the end user can simply add an item on the menu for every browser (the user can also easily delete any item from the menu). It is not necessary to restart km, after selecting the exe file, the item will appear in the menu.

adodupan,

This works perfectly.... although I tried to get Alain's macro to work with Seamonkey portable, it never did work right. This one does. Very much appreciated.

Why Seamonkey was a problem and others not, I do not know. The right click macros work for Firefox, QTweb, IronPortable, IE, and Maxthon just fine. Now I have all the browsers available from within K-Meleon. (Will have to think about loading up Opera too, although that is a browser I never got used to, in terms of its quirky interface, that is.)

N

Options: ReplyQuote
Re: About functions
Posted by: John
Date: September 23, 2011 12:25PM

Quote
ndebord
Will have to think about loading up Opera too

Like there? http://kmext.sourceforge.net/ext5.htm

Options: ReplyQuote
Re: About functions
Posted by: ndebord
Date: September 23, 2011 08:30PM

Quote
John
Quote
ndebord
Will have to think about loading up Opera too

Like there? http://kmext.sourceforge.net/ext5.htm

John,

Yes or Alain's executable that does the same thing.

http://extensions.geckozone.org/K-MeleonEn#O

N

Options: ReplyQuote
Re: About functions
Posted by: jsnj
Date: September 24, 2011 02:51AM

Quote
adodupan
Last week i read that Nick wants to open websites in other browsers and it fails. This is irrelevant, but sometimes it can bother users. I've tried all the extensions, but none passed my criteria. So, i wrote a universal code for easy opening websites in any browser. With this km macro, the end user can simply add an item on the menu for every browser (the user can also easily delete any item from the menu). It is not necessary to restart km, after selecting the exe file, the item will appear in the menu.
To add items:
Tools > Open in browser > Add a new browser
To open a website you need to right click.
For developers, i suggest this code for the next update of km. The best way is to combine ie.kmm with this code.
Try this macro.

}

Nice addition. I'm curious why you chose not to use the 'Send To' menus in your _browser_03 macro.

"S&end Page To"
"S&end Link To"
"S&end Image To"
"S&end To"

Options: ReplyQuote
Re: About functions
Posted by: adodupan
Date: September 24, 2011 03:38PM

jsnj,
there is no special reason. In my km i do not have a file sendto.kmm, it is the only reason.
Now i suppose...
If you want combine file ie.kmm with this code ( or whatever ), you should have no trouble, you can use all the menus. You also can change and adapt this code any way you want.

Regards

Options: ReplyQuote
Re: About functions
Posted by: melo
Date: October 14, 2011 03:25PM

browser.kmm fails in KM 1.1.6 ! sad smiley



Edited 1 time(s). Last edit at 10/14/2011 03:26PM by melo.

Options: ReplyQuote
Re: About functions
Posted by: adodupan
Date: October 15, 2011 02:34PM

melo,
browser.kmm need a newer version of the macros.dll and function ExecMacros_List.

ExecMacros_List{
# Execute one or more macros for each item of a semicolon-separated list.
# Parameters (set before calling):
# - $ExecMacros: The macros to be executed (semicolon-separated list)
# - $List : The list to be processed ("<string1>;<string2>;...;<stringN>;" or an empty string)
# Output (for use in your macros):
# - $ListItem : The current substring <stringM>
$ListItem=$List?substr($List,0,index($List,";")):"";
while($ListItem) {
macros($ExecMacros);
$List=$List?sub($ListItem.";","",$List):"";
$ListItem=$List?substr($List,0,index($List,";")):"";
}
}

Packing for km11.
Differences: after selecting another browser, you need to restart your km.



Edited 1 time(s). Last edit at 01/06/2012 11:17PM by adodupan.

Attachments: browser_km11.7z (37.4 KB)  
Options: ReplyQuote
Re: About functions
Posted by: adodupan
Date: January 11, 2012 11:01PM

Now it is possible to set up K-Meleon as default browser without SetDefault.exe (file SetDefault.exe not needed anymore).

Tested on win2000/xp/vista/win7 (i don't have win98).

Download kmprefs.jar for km16.



Edited 1 time(s). Last edit at 01/11/2012 11:02PM by adodupan.

Attachments: kmprefs.jar (448.7 KB)   doNotTrack.7z (1.5 KB)  
Options: ReplyQuote
Re: About functions
Posted by: rodocop
Date: July 02, 2012 11:34PM

adodupan,
tell me please, what actually is changed inside kmprefs.jar?

_____________________________________
Using K-Meleon-1.6.17db+ / KM-16-S2014
1.6beta2.5 by JamesD
______________________________
Recommending K-Meleon Twin+
Try and discuss it!!!

Options: ReplyQuote
Re: About functions
Posted by: adodupan
Date: July 03, 2012 04:01AM

rodocop,

- changed a few lines of code in a file pref-browsing.xul,
- added a new file DefaultBrowser.js.

For more details you can compare file pref-browsing.xul with older file.

Options: ReplyQuote
Re: About functions
Posted by: rodocop
Date: July 03, 2012 05:00AM

thank you very much for your answer!

_____________________________________
Using K-Meleon-1.6.17db+ / KM-16-S2014
1.6beta2.5 by JamesD
______________________________
Recommending K-Meleon Twin+
Try and discuss it!!!

Options: ReplyQuote
Re: About functions
Posted by: adodupan
Date: September 04, 2012 03:06AM

AllowScript is a simple km addition for creating javascript whitelist.

EDIT: After installation, you must delete two files in the folder components (compreg.dat, xpti.dat)

Regards



Edited 1 time(s). Last edit at 09/04/2012 07:04PM by adodupan.

Options: ReplyQuote
Re: About functions
Posted by: adodupan
Date: March 10, 2013 03:22AM

Here you often discuss about User-Agent. I don't know why it takes 10-15 different UA strings, but it does not matter. Now it's possible even more, here is possibility that you create UA rules (or exceptions) for the site. This file transmits UA header of your choice, and you can create rules.
User interface requires more lines and more time. Of course, you're all invited to complete the interface.
Important:
nsUserAgent.js file reads preferences 'network.httpheaders.User-Agent.'
If you want to create a rule, for example for site http://kmeleon.sourceforge.net, and you want to send UA header Firefox 14.0.1, you need to create a pref STRING 'network.httpheaders.User-Agent.firefox' and set value:

Mozilla/5.0 (Windows NT 5.1; rv:14.0) Gecko/20100101 Firefox/14.0.1@kmeleon.sourceforge.net

So, in the first place is ua string, then @, then hostname. Here you can put more than one page, but it is necessary to separate each, use a empty character, for example:

Mozilla/5.0 (Windows NT 5.1; rv:14.0) Gecko/20100101 Firefox/14.0.1@kmeleon.sourceforge.net en.wikipedia.org developer.mozilla.org

Now you create a new pref, for example STRING 'network.httpheaders.User-Agent.iexplorer' etc...

nsUserAgent.js (put this file in the folder components)

/** K-meleon HTTP Headers (User-Agent) © 2013 adodupan **/

Components.utils.import('resource://gre/modules/XPCOMUtils.jsm');
const Cc = Components.classes;
const Ci = Components.interfaces;
const UA_RULES = 'network.httpheaders.User-Agent.';

function nsUserAgent() {
    //this.wrappedJSObject = this;
    this.observer = Cc['@mozilla.org/observer-service;1'].getService(Ci.nsIObserverService);
    this.prefs = Cc['@mozilla.org/preferences-service;1'].getService(Ci.nsIPrefService)
    .getBranch(UA_RULES);
}
nsUserAgent.prototype = {
classDescription: 'Create a rule for UserAgent',
contractID: '@adodupan/nsUserAgent;1',
classID: Components.ID('{18823150-88e5-11e2-9e96-0800200c9a66}'),

Load: function(aSubject) {
    var nsIHttpChannel = aSubject.QueryInterface(Ci.nsIHttpChannel),
    nsIChannel = aSubject.QueryInterface(Ci.nsIChannel);
    for(var a=0,b=this.prefs.getChildList('', {});a<b.length;a++) {
      if(this.prefs.getCharPref(b[a]).indexOf(nsIChannel.URI.host)>-1) {
        nsIHttpChannel.setRequestHeader('User-Agent', this.prefs.getCharPref(b[a]).split('@')[0], false);
        return;
        break;
      }
    }
},
observe: function(aSubject, aTopic, aData) {
    try{
      switch(aTopic) {
        case 'app-startup' : this.AppStartup(); break;
        case 'http-on-modify-request' : this.Load(aSubject); break;
        case 'xpcom-shutdown' : this.Shutdown(); break;
      }
    }catch(err){}
},
get Shutdown() {
    this.observer.removeObserver(this, 'http-on-modify-request');
    this.observer.removeObserver(this, 'xpcom-shutdown');
},
get AppStartup() {
    this.observer.addObserver(this, 'xpcom-shutdown', false);
    this.observer.addObserver(this, 'http-on-modify-request', false);
},
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
_xpcom_categories: [{ category: 'app-startup', service: true }]
};
function NSGetModule(compMgr, fileSpec) {
    return XPCOMUtils.generateModule([nsUserAgent]);
}



Regards

Attachments: nsUserAgent.js (1.8 KB)  
Options: ReplyQuote
Re: About functions
Posted by: rodocop
Date: March 10, 2013 07:44AM

adodupan,
great stuff!

But couldn't we ask you to create macro providing simple GUI for adding such strings (or assign one of predefined UA-strings to currently viewed site)?

_____________________________________
Using K-Meleon-1.6.17db+ / KM-16-S2014
1.6beta2.5 by JamesD
______________________________
Recommending K-Meleon Twin+
Try and discuss it!!!

Options: ReplyQuote
Re: About functions
Posted by: adodupan
Date: March 11, 2013 11:04AM

rodocop, as i already wrote, user interface file(s) requires much more lines and much more time than file nsUserAgent.js. Macrolanguage is too poor language, but it is possible. JavaScript xul is a better option.
Once again, you are all invited and welcome to complete the user interface, don't be shy :)
For macrolanguage coders, it is easy to change the way, how to read preferences in file nsUserAgent.js. Share your own code with everyone.

Best regards

Options: ReplyQuote
Re: About functions
Posted by: rodocop
Date: March 13, 2013 01:56AM

The case is only that I'm not enough capable in macrolanguage and not capable at all in JS or other languages.

KMML is the first language I've used to produce something really working but I'm too stupid to work with its GUI-handling part.

When I can I make macros by myself but not now, sorry...

_____________________________________
Using K-Meleon-1.6.17db+ / KM-16-S2014
1.6beta2.5 by JamesD
______________________________
Recommending K-Meleon Twin+
Try and discuss it!!!

Options: ReplyQuote


K-Meleon forum is powered by Phorum.