General
: K-Meleon Web Browser Forum
General discussion about K-Meleon
Go to:
Forum List
•
Message List
•
Search
•
Log In
Your Name:
Subject:
Help information
BBcode help
Smileys help
Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
[Please, enable JavaScript to see the code]
Enter code:
[quote=adodupan] [b]CreateButton, CreateCallbackButton[/b] These functions are not implemented. [b]AddToolbar[/b] [quote][b]AddToolbar[/b] The current implementation of this function does not work as expected.[/quote] Somewhere i wrote almost the same comment, in fact this function works as expected. You can try this function in error console, then open a new km window and you will see the new toolbar there. [code]const JSB = Components.classes['@kmeleon/jsbridge;1'].getService(Components.interfaces.nsIJSBridge); JSB.SetMenuCallback('Misc', 'Test AddToolbar function', function () { JSB.AddToolbar('TestToolbar'); }, '');[/code] So, that's what Dorian was expecting :) This function is unusable in km addons. [b]Id[/b] [quote=Kris_88] [quote=siria] Regarding parameters, macros can use 1 (?), and it must be a string (?) not some object, which can inside be accessed as $ARG: macros(mymacro(sometext)); [/quote] Yes, it works surprisingly. Thank you! jsb.id( null, 'macros(mymacro(123))' ); mymacro{ alert($ARG); } [/quote] [b]GetCmdList[/b] You can see the registered commands. In practice, i did not see the need for such a function. Perhaps in some hypothetical circumstances when you use the SetAccel function and you need to check if some key combination is already being used. [b]AddListener[/b] Paste this code into the error console, then open, switch, close tabs and windows: [code]Components.utils.import('resource://gre/modules/Services.jsm'); const JSB = Components.classes['@kmeleon/jsbridge;1'].getService(Components.interfaces.nsIJSBridge); const TEST = { observe: function (subject, topic, data) { if (topic == 'kmeleon-switchtab') Services.console.logStringMessage('kmeleon-switchtab: ' + subject.document.documentURIObject.spec); else Services.console.logStringMessage(topic); } }; JSB.AddListener(TEST);[/code] [b]GetActiveBrowser, GetCurrentWindow, GetWindows[/b] Open several windows in km and several websites in different tabs, then paste this code into the error console and make some tests: [code]Components.utils.import('resource://gre/modules/Services.jsm'); const JSB = Components.classes['@kmeleon/jsbridge;1'].getService(Components.interfaces.nsIJSBridge); JSB.SetMenuCallback('Misc', 'Test GetActiveBrowser (get url)', function () { Services.console.logStringMessage('url: ' + JSB.GetActiveBrowser().contentDOMWindow.document.documentURIObject.spec); }, ''); JSB.SetMenuCallback('Misc', 'Test GetCurrentWindow (get url)', function () { Services.console.logStringMessage('wnd.tab.length: ' + JSB.GetCurrentWindow().getTabs().length); for (var a in JSB.GetCurrentWindow().getTabs()) { Services.console.logStringMessage( 'wnd.tab[' + a + '].url: ' + JSB.GetCurrentWindow().getTabs()[a].contentDOMWindow.document.documentURIObject.spec); } }, ''); JSB.SetMenuCallback('Misc', 'Test GetWindows (get url)', function () { Services.console.logStringMessage('wnd.length: ' + JSB.GetWindows().length); for (var a in JSB.GetWindows()) { Services.console.logStringMessage('wnd[' + a + '].tab.length: ' + JSB.GetWindows()[a].getTabs().length); for (var z in JSB.GetWindows()[a].getTabs()) { Services.console.logStringMessage( 'wnd[' + a + '].tab[' + z + '].url: ' + JSB.GetWindows()[a].getTabs()[z].contentDOMWindow.document.documentURIObject.spec); } } }, '');[/code] [b]RegisterCmd[/b] One example from my old km when it is necessary for a menu item or a button to be checked or disabled. Paste this code into the error console: [code]Components.utils.import('resource://gre/modules/Preferences.jsm'); const JSB = Components.classes['@kmeleon/jsbridge;1'].getService(Components.interfaces.nsIJSBridge); [ ['network.cookie.cookieBehavior', 'Block Co&okies', [2, 0], 'cookie', 'Toggle cookie acceptance', ], ['javascript.enabled', 'Block Java&script', [false, true], 'javascript', 'Toggle JavaScript execution', 'VK_F7'], ['dom.disable_open_during_load', 'Block &Popups', [true, false], 'popup', 'Toggle popup blocking', 'VK_F8'], ['permissions.default.image', 'Block &Images', [2, 1], 'image', 'Toggle image loading', 'VK_F9'], ['image.animation_mode', 'Block Image Ani&mation', ['none', 'normal'], 'animation', 'Toggle image animation', ], ['permissions.default.object', 'Block Objec&ts', [2, 1], 'object', 'Toggle object loading', ], ['kmeleon.flashblock', 'Block F&lash', [true, false], 'flash', 'Toggle Flashblock', ], ['kmeleon.adblocking', 'Block A&dvertisement', [true, false], 'advertisement', 'Toggle Ad-Blocking StyleSheet', ], ['browser.display.use_document_colors', 'Block &Colors', [false, true], 'color', 'Toggle page colors', ], ['browser.frames.enabled', 'Block &Frames', [false, true], 'frame', 'Toggle frame support', ] ].forEach(function([pref, desc, value, cmnd, msg, accel]) { JSB.RegisterCmd( 'privacy' + cmnd + 'cmnd', msg, function () { Preferences.set(pref, Preferences.get(pref) == value[0] ? value[1] : value[0]); }, '', function () { /* enabled */ return ((cmnd == 'flash' && Preferences.get('javascript.enabled') == false) ? false : true); }, function () { /* checked */ return (Preferences.get(pref) == value[0]); } ); JSB.SetMenu('TestPrivacy', 1, desc, 'privacy' + cmnd + 'cmnd', ''); if (typeof accel != 'undefined') JSB.SetAccel(accel, 'privacy' + cmnd + 'cmnd'); }); JSB.RegisterCmd( /* button command */ 'btncmnd', '', function () { Preferences.set('javascript.enabled', !Preferences.get('javascript.enabled')); }, 'chrome://global/skin/icons/information-64.png', function () { /* enabled */ return true; /* set a condition here when the button will be disabled */ }, function () { /* checked */ return !Preferences.get('javascript.enabled'); } ); JSB.AddButton( '&Go Buttons', 'btncmnd', 'TestPrivacy', 'Test RegisterCmd function\nRight click for more options.' );[/code] I wrote a small simple [url=http://kmeleonbrowser.org/forum/file.php?9,file=2073,filename=referencemanualhelp.v.1.0_adodupan.xpi]addon[/url], hoping it can help you in your tests. Inside, you can see how to use most of the jsbridge functions. Important: in pref "[b]kmeleon.install_firefox_extension[/b]" set value [b]false[/b], in pref "[b]consoleservice.enabled[/b]" set value [b]true[/b].[/quote]
[Please Enable JavaScript]
K-Meleon forum is powered by
Phorum
.
Home/News
Screenshots
Download
Documentation
Resources
Get Involved
Forum
FAQ
English