K-Meleon

KMeleonWiki > Documentation > ReferenceManual > JsbridgePlugin

About Jsbridge Plugin

It's an interface providing a channel between javascript language and k-meleon core .

Calling Jsbridge

To be able of using jsbridge functions you need to call it inside your javascript code, which can be done by :

  • Directly calling the interface
var KMeleon = Components.classes["@kmeleon/jsbridge;1"]
                         .getService(Components.interfaces["nsIJSBridge"]);

or

  • Import KMeleon module
Components.utils.import("resource:///modules/KMeleon.jsm");

.

Jsbridge functions

Right now (=2014) Jsbridge? has 6 main functions which are:

-SetMenuCallback : Set \ create Menu items , which will call Javascript function when menu is activated .

  • Syntax:
SetMenuCallback(menu, label,function() {},before) ;
  • Example:
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

  • Syntax:
Open( url , state ) ;

state:

  • OPEN_NORMAL
  • OPEN_NEW
  • OPEN_BACKGROUND
  • OPEN_NEWTAB
  • OPEN_BACKGROUNDTAB
  • OPEN_CLONE

Example -

var url='chrome://kmprefs/content/pref.xul';
 KMeleon.Open(url, KMeleon.OPEN_NEW);

-Id : Open Command IDs.

  • Syntax:
id(null ,commandID);

Example -

KMeleon.id(null,'ID_PASSWORDS_VIEWER');

-SetMenu : create new menu item .

  • Syntax:
setmenu(menuName,itemType,itemName,command,location);

itemType:

  • inline
  • popup
  • separator
  • command
  • macro
  • plugin

Example -

KMeleon.SetMenu("&Tools","macro","my macro","my_function");

-RebuildMenu : Rebuild a menu.

  • Syntax:
RebuildMenu(menuName);

Example -

KMeleon.RebuildMenu("my_Menu");

-SendMessage : In basic it do the connection with plugins, but it work now only with macro plugin .

  • Syntax:
SendMessage(to,from,subject,data1,data2);

Example -

KMeleon.SendMessage("macros", "kmAddon", "RunMacro", macro);

macro: the macro file in String form.


Jsbridge And Addons

http://kmeleon.sourceforge.net/wiki/?binary=internal%3A%2F%2Fba049820350a1db8e41f3da56325e9bd.jpeg

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

K-Meleon

(c) 2000-2010 kmeleonbrowser.org. All rights reserved.
design by splif.