Question: I am writing a Firefox extension and I am using their Add-on SDK; but I can't figure out how to inject a local CSS file from the data folder into the webpage. It would be great if there were a way to do it via `page_mod` package.

Answer: 
As of Add-on SDK 1.14 there's experimental (API may change) support for this in the [page-mod](https://addons.mozilla.org/en-US/developers/docs/sdk/1.14/modules/sdk/page-mod.html) module:

```
var pageMod = require("sdk/page-mod").PageMod({
  include: "*",
  contentStyleFile: require("sdk/self").data.url("my-style.css")
});

```

See [Modifying Web Pages Based on URL](https://addons.mozilla.org/en-US/developers/docs/sdk/1.14/dev-guide/tutorials/modifying-web-pages-url.html) for an elaborate guide to using page-mod.

There's [a page on the Addon SDK's wiki](https://github.com/mozilla/addon-sdk/wiki/contentStyle-issues) discussing issues with the current implementation, although it seems a bit outdated.

Under the hood it uses [nsIDOMWindowUtils](http://mxr.mozilla.org/mozilla-central/source/dom/interfaces/base/nsIDOMWindowUtils.idl).loadSheet() to add the stylesheet without touching the page's DOM. (This API was added in Firefox 18, see [bug 737003](https://bugzilla.mozilla.org/show_bug.cgi?id=737003). Before that you had to use [nsIStyleSheetService](https://developer.mozilla.org/en/Using_the_Stylesheet_Service) which was similar, but not tab-specific.)

---

Before that you could use the page-mod's content script to insert the link or style element ([example](https://forums.mozilla.org/addons/viewtopic.php?p=13101#p13116)). [edit] thanks to lwburk's comment, here's a more elaborate elaborate description in [Greasemonkey Hacks: Tips & Tools for Remixing the Web with Firefox By Mark Pilgrim: "Alter a Page's Style" section](http://books.google.ru/books?id=KWRE2C_S4YsC&pg=PA19&lpg=PA19&dq=mark+pilgrim+add+Global+Style&source=bl&ots=SnfX5Ad2WO&sig=CKoF9A0Ala96vphTeU4mK2dbMe4&hl=en&ei=GJ3iTpeJKKK2sQLBkMDvBQ&sa=X&oi=book_result&ct=result&redir_esc=y#v=onepage&q&f=false).
To insert CSS from main.js one can now use "page-mod":

```
var data = require("sdk/self").data;
var pageMod = require("sdk/page-mod");

pageMod.PageMod({
  include: "*.org",
  contentStyleFile: data.url("my-page-mod.css")
});

```