Skip to content

Instantly share code, notes, and snippets.

@yajd
Created April 30, 2014 01:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save yajd/17ee5b1b98cb717c8429 to your computer and use it in GitHub Desktop.
Save yajd/17ee5b1b98cb717c8429 to your computer and use it in GitHub Desktop.
_ff-addon-snippet-AccessBootstrapScope - example of how to access addon module scope of bootstrapped addon
var XPIScope = Cu.import('resource://gre/modules/XPIProvider.jsm');
alert(XPIScope.XPIProvider)
var scope = XPIScope.XPIProvider.bootstrapScopes['ghForkable@jetpack'];
alert(scope)
@Noitidart
Copy link

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

@Noitidart
Copy link

single line promise:

var XPIScope = Cu.import('resource://gre/modules/addons/XPIProvider.jsm');
var scope = XPIScope.XPIProvider.bootstrapScopes['Profilist@jetpack'];
scope.getProfileSpecs(Object.keys(scope.ini)[5]).then(function(a){console.log('a:',a)},function(b){console.warn('b:',b)}).catch(function(c){console.error('c:',c)})

@Noitidart
Copy link

testing PromiseWorker promise


                var aDOMWin = Services.wm.getMostRecentWindow('navigator:browser');
                var cBaseWin = aDOMWin.QueryInterface(Ci.nsIInterfaceRequestor)
                                      .getInterface(Ci.nsIWebNavigation)
                                      .QueryInterface(Ci.nsIDocShellTreeItem)
                                      .treeOwner
                                      .QueryInterface(Ci.nsIInterfaceRequestor)
                                      .getInterface(Ci.nsIBaseWindow);
                var cWinHandlePtrStr = cBaseWin.nativeHandle;
                console.log(cWinHandlePtrStr);


var XPIScope = Cu.import('resource://gre/modules/addons/XPIProvider.jsm');
var scope = XPIScope.XPIProvider.bootstrapScopes['Profilist@jetpack'];
scope.ProfilistWorker.post('changeIconForAllWindows', ['C:\\Users\\Vayeate\\AppData\\Roaming\\Mozilla\\Firefox\\profilist_data\\launcher_icons\\BADGE-ID_youtube-2__CHANNEL-REF_beta.ico', ['0x2a079a']]).then(function(a){console.log('a:',a)},function(b){console.warn('b:',b)}).catch(function(c){console.error('c:',c)})

scope.ProfilistWorker.post('findLaunchers', ['Profiles/7i1dvxno.Unnamed Profile 8']).then(x=>console.log('x:',x),y=>console.warn('y:',y)).catch(z=>console.error('z:',z));

@Noitidart
Copy link

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

setTimeout(function(){
    var gClipboardHelper = Cc["@mozilla.org/widget/clipboardhelper;1"].getService(Ci.nsIClipboardHelper);
    gClipboardHelper.copyString(JSON.stringify(getScope().gEditor.winArr));
    console.log('copied');
}, 10000);



getScope().MainWorker.post('getAllWin', [{
    filterVisible: true,
    getPid: true,
    getTitle: true,
    getBounds: true
}]).then(winArr=>Cc["@mozilla.org/widget/clipboardhelper;1"].getService(Ci.nsIClipboardHelper).copyString(JSON.stringify(winArr)));

@Noitidart
Copy link

var getScope = function() { var XPIScope = Cu.import('resource://gre/modules/addons/XPIProvider.jsm'); return XPIScope.XPIProvider.bootstrapScopes['MouseControl@jetpack']; }; a = getScope();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment