Skip to content

Instantly share code, notes, and snippets.

Created May 21, 2014
What would you like to do?
content test-addon ./
overlay chrome://browser/content/browser.xul chrome://test-addon/content/overlay.xul
<?xml version="1.0" encoding="UTF-8" ?>
<RDF xmlns="" xmlns:em="">
<Description about="urn:mozilla:install-manifest">
<em:name>test add-on</em:name>
<em:creator>Nils Maier</em:creator>
Any copyright is dedicated to the Public Domain.
// Use strict mode in particular to avoid implicitly var declarations
(function() {
"use strict";
// Main runner function for each content window.
// Similar to SDK page-mod, but without the security boundaries.
function run(window, document) {
// jquery setup. per
$ = function(selector,context) {
return new jq.fn.init(selector,context || document);
$.fn = $.prototype = jq.fn;
if (document.getElementById("my-example-addon-container")) {
let main = $('<div id="my-example-addon-container">');
main.appendTo(document.body).text('Example Loaded!'); { //<--- added this function
const log = Components.utils.reportError.bind(Components.utils);
// Do not conflict with other add-ons using jquery.
const jq = jQuery.noConflict(true);
gBrowser.addEventListener("DOMContentLoaded", function load(evt) {
try {
// Call run with this == window ;)
let doc = ||;
if (!doc.location.href.startsWith("http")) {
// Do not even attempt to interact with non-http(s)? sites.
}, doc.defaultView, doc);
catch (ex) {
}, true);
<?xml version="1.0"?>
<overlay id="test-addon-overlay" xmlns="">
<script type="text/javascript" src="jquery.js"/>
<script type="text/javascript" src="overlay.js"/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment