Skip to content

Instantly share code, notes, and snippets.

@lkuper lkuper/content.js
Last active Aug 29, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.