You should use the page-mod api, here is the documentation ( including simple code examples ):
https://developer.mozilla.org/en-US/Add-ons/SDK/High-Level_APIs/page-mod
In particular, you add js files using the contentScriptFile
option, and css files using the contentStyleFile
option. Here's a very simple example:
var data = require('sdk/self').data;
require('sdk/page-mod').PageMod({
include: ["*"],
contentScriptFile: [data.url('script.js')],
contentScriptFile: [data.url('style.css')],
attachTo: ["existing", "top"]
});
This code should be in ./lib/main.js
in your add-on project directory and the files script.js
and style.css
should be located in the ./data/
sub-folder of your add-on project directory.