Skip to content

Instantly share code, notes, and snippets.

@lkuper
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lkuper/2bb60be77b609c505c2a to your computer and use it in GitHub Desktop.
Save lkuper/2bb60be77b609c505c2a to your computer and use it in GitHub Desktop.
function hello(name) {
console.log("Hello from privileged code, " + name + "!");
}
Components.utils.exportFunction(hello, unsafeWindow, {defineAs: "hello"});
const {Cu} = require("chrome");
var pageMod = require("sdk/page-mod");
var data = require("sdk/self").data;
pageMod.PageMod({
include: "*",
attachTo: ["existing", "top"],
contentScriptFile: data.url("content.js"),
contentScriptWhen: "start", // Attach the content script before any page script loads.
});
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Test page</title>
</head>
<body>
<script type="text/javascript">
hello("Lindsey");
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment