Managing a Firefox Extension Through Javascript

Is it possible, using javascript, to control the extension of the firefox overlay? I extracted the contents of the extension and determined which functions / methods I need to execute, but they are not available within the console.

Thanks in advance for any ideas.

+4
source share
2 answers

Yes, it is possible to interact with other add-ons, given the right circumstances.

My test case will be com.googlecode.sqlitemanager.openInOwnWindow(), which is part of the SqliteManageraddon .

  • ( Nightly) . , com.googlecode.sqlitemanager.openInOwnWindow() .

  • ( WebDev Chrome, , "about: newtab" ). , . , , : var bwin = Services.wm.getMostRecentWindow("navigator:browser"); bwin.com.googlecode.sqlitemanager.openInOwnWindow()

  • -. Scratchpad Chrome " ". com.googlecode.sqlitemanager.openInOwnWindow() Scratchpad .

  • , , .

  • .

  • /SDK-: XPIProvider.jsm ( ) ( bootstrap.js) XPIProvider.bootstrapScopes[addonID] ( , , SDK).

: , . , , , , , . ( ) JS- . (, AdBlock Plus require() - , SDK , )...

, .

: , , , , - mozilla

chrome js:

var myExtension = {
  myListener: function(evt) {
   IprPreferences.setFreshIpStatus(true); // replace with whatever you want to 'fire' in the extension
  }
}

document.addEventListener("MyExtensionEvent", function(e) { myExtension.myListener(e); }, false, true);
// The last value is a Mozilla-specific value to indicate untrusted content is allowed to trigger the event.

-:

var element = document.createElement("MyExtensionDataElement");
element.setAttribute("attribute1", "foobar");
element.setAttribute("attribute2", "hello world");
document.documentElement.appendChild(element);

var evt = document.createEvent("Events");
evt.initEvent("MyExtensionEvent", true, false);
element.dispatchEvent(evt);
+7

Firefox 47

Firefox 47 . .

var XPIScope = Cu.import('resource://gre/modules/addons/XPIProvider.jsm');
var addonid = 'Profilist@jetpack';
var scope = XPIScope.XPIProvider.activeAddons.get(addonid).bootstrapScope

< Firefox 47

, :

AdBlocks, id AdBlock, {d10d0bf8-f5b5-c8b4-a8b2-2b9879e08c5d}, :

var XPIScope = Cu.import('resource://gre/modules/addons/XPIProvider.jsm');
var adblockScope = XPIScope.XPIProvider.bootstrapScopes['{d10d0bf8-f5b5-c8b4-a8b2-2b9879e08c5d}'];

- .

: , id NativeShot@jetpack

:

var XPIScope = Cu.import('resource://gre/modules/addons/XPIProvider.jsm');
var nativeshotScope = XPIScope.XPIProvider.bootstrapScopes['NativeShot@jetpack'];

console.log(nativeshotScope), , .

+1

Source: https://habr.com/ru/post/1529111/


All Articles