K-Meleon
KMeleonWiki > Documentation > ReferenceManual > JsbridgePlugin
It's an interface providing a channel between javascript language and k-meleon core .
To be able of using jsbridge functions you need to call it inside your javascript code, which can be done by :
var KMeleon = Components.classes["@kmeleon/jsbridge;1"] .getService(Components.interfaces["nsIJSBridge"]);
or
Components.utils.import("resource:///modules/KMeleon.jsm");
.
Right now (=2014) Jsbridge? has 6 main functions which are:
-SetMenuCallback : Set \ create Menu items , which will call Javascript function when menu is activated .
SetMenuCallback(menu, label,function() {},before) ;
KMeleon.!SetMenuCallback--("&Tools", "open pref",function(mode) { KMeleon.Open('chrome://kmprefs/content/pref.xul', KMeleon.OPEN_NEWTAB); });
Open : Open a local a external address in a new tab/window
Open( url , state ) ;
state:
Example -
var url='chrome://kmprefs/content/pref.xul'; KMeleon.Open(url, KMeleon.OPEN_NEW);
-Id : Open Command IDs.
id(null ,commandID);
Example -
KMeleon.id(null,'ID_PASSWORDS_VIEWER');
-SetMenu : create new menu item .
setmenu(menuName,itemType,itemName,command,location);
itemType:
Example -
KMeleon.SetMenu("&Tools","macro","my macro","my_function");
-RebuildMenu : Rebuild a menu.
RebuildMenu(menuName);
Example -
KMeleon.RebuildMenu("my_Menu");
-SendMessage : In basic it do the connection with plugins, but it work now only with macro plugin .
SendMessage(to,from,subject,data1,data2);
Example -
KMeleon.SendMessage("macros", "kmAddon", "RunMacro", macro);
macro: the macro file in String form.
Addons now can be installed directly using addons manager , and a lot of them can work with less effort than the old versions.
(2014) Under Test :
k-meleon 74 has added the ability to run macro from inside xpi file ( withe the name 'load.kmm' ) , or run startup function from javascript file ( withe the name 'kmeleon.js' ) inside xpi file too.
The startup function can create k-meleon menu item , using SetMenuCallback function ,which mean that menu item could run javascript or macro function if you need it.
Note : if you want to try this method , then you will need to add the component " kmAddon.js" to k-meleon with modified versions of "jsbridge.xpt" & "JSBridge.dll" & "macros.dll" from this
Example: newsfox_test2.zip .
(2019) Example-Addon 2
Download: howtousejsbridge.v.1.0_adodupan.xpi
See Forum
This adds a menu line for calling a macro (incidentally also named "howtousejsbridge", but can be any other too) to the context menu of a xul page. As example the URL "about:config" was chosen in chrome.manifest.
Adodupan posted this 2019, saying that it works in KM74, crashed in KM75-76, and now works again since KM-Goanna76.
Howto change the text in the menu item: edit file howtousejsbridge.dtd
Howto call another macro: edit pref 'extensions.howtousejsbridge.macro'.