Created
May 21, 2014 07:13
-
-
Save nmaier/d1a259435af47f6a159d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
content test-addon ./ | |
overlay chrome://browser/content/browser.xul chrome://test-addon/content/overlay.xul |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8" ?> | |
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#"> | |
<Description about="urn:mozilla:install-manifest"> | |
<em:type>2</em:type> | |
<em:id>test@addon</em:id> | |
<em:name>test add-on</em:name> | |
<em:version>0.1</em:version> | |
<em:creator>Nils Maier</em:creator> | |
<em:targetApplication> | |
<Description> | |
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> | |
<em:minVersion>29.0</em:minVersion> | |
<em:maxVersion>32.*</em:maxVersion> | |
</Description> | |
</em:targetApplication> | |
</Description> | |
</RDF> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Any copyright is dedicated to the Public Domain. | |
http://creativecommons.org/publicdomain/zero/1.0/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 http://stackoverflow.com/a/496970/484441 | |
$ = function(selector,context) { | |
return new jq.fn.init(selector,context || document); | |
}; | |
$.fn = $.prototype = jq.fn; | |
if (document.getElementById("my-example-addon-container")) { | |
return; | |
} | |
let main = $('<div id="my-example-addon-container">'); | |
main.appendTo(document.body).text('Example Loaded!'); | |
main.click(function() { //<--- added this function | |
main.text(document.location.href); | |
}); | |
main.css({ | |
background:'#FFF',color:'#000',position:'absolute',top:0,left:0,padding:8 | |
}); | |
}; | |
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 = evt.target.ownerDocument || evt.target; | |
if (!doc.location.href.startsWith("http")) { | |
// Do not even attempt to interact with non-http(s)? sites. | |
return; | |
} | |
run.call(doc.defaultView, doc.defaultView, doc); | |
} | |
catch (ex) { | |
log(ex); | |
} | |
}, true); | |
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<overlay id="test-addon-overlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> | |
<script type="text/javascript" src="jquery.js"/> | |
<script type="text/javascript" src="overlay.js"/> | |
</overlay> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment