Notepad SDK access

I would like to test small fragments of my additional code with notepad. In this case, I am trying to access the notification module as follows:

const { notify } = require("sdk/notifications");
notify({
  //My notification options
}); 

As expected, I get an error Exception: require is not defined. Since the Add-on SDK is packaged with Firefox, I wonder if there is a way to access the modules directly from Notepad. Thanks.


Edit: after some Googling, I discovered a scratch-kit (github) , an add-on that does exactly what I'm trying to do. But unfortunately broken , so I filed an error in the hope that this functionality will be added to devtools.

+3
source share
2 answers

There is currently no way to do this. Several things can happen to make this possible so that people can observe / contribute:

+2
source

There is currently a relatively simple way to do this. The following code works fine if executed in a privileged context (which means that the Scratchpad environment switches to Browser):

let {require} = Cu.import("resource://gre/modules/commonjs/toolkit/require.js", {});
let {notify} = require("sdk/notifications");

, Firefox 36, , .

: pull request # 1679 ( ).

+4

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


All Articles