4
votes

I want to add a file(background.js) which is a background script for my firefox extension. I added content scripts to my main.js using the following code.

 var panel = panels.Panel({
   contentURL: self.data.url("panel.html"),
   onHide: handleHide,
   contentScriptFile: [self.data.url("js/jquery.js"), 
                  self.data.url("tipsy/jquery.tipsy.js"),,
                  self.data.url("js/settings.js")]
});

How do I add background scripts to the main.js file.

1

1 Answers

0
votes

Simply place the file in the lib folder.

Except for scripts that interact directly with web content, all the JavaScript code you'll write or use when developing add-ons using the SDK is part of a CommonJS module.

Essentially, backend script don't share variables like content scripts/normal JS. You export and require variables between modules.

See adding local modules