Skip to content

Instantly share code, notes, and snippets.

@nobuoka
Last active April 29, 2016 08:43
Show Gist options
  • Save nobuoka/5181549 to your computer and use it in GitHub Desktop.
Save nobuoka/5181549 to your computer and use it in GitHub Desktop.
ブートストラップ型の XUL ベースの Firefox 拡張としてのサンプル。
var Cc = Components.classes;
var Ci = Components.interfaces;
var PromptService = Cc["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Ci.nsIPromptService);
// インストール時に呼び出される
function install(aData, aReason) {
PromptService.alert(null, "Bootstrapped Extension Sample", "Install");
}
// インストール後や Firefox 起動後などに呼び出される
function startup(aData, aReason) {
PromptService.alert(null, "Bootstrapped Extension Sample", "Startup");
}
// Firefox 終了前や拡張機能が無効化される際などに呼び出される
function shutdown(aData, aReason) {
PromptService.alert(null, "Bootstrapped Extension Sample", "Shutdown");
}
// アンインストールされた後の Firefox 終了時などに呼び出される
function uninstall(aData, aReason) {
PromptService.alert(null, "Bootstrapped Extension Sample", "Uninstall");
}
<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<rdf:Description rdf:about="urn:mozilla:install-manifest">
<em:id>bootstrapped-extension-sample@vividcode.info</em:id>
<em:name>Bootstrapped Extension Sample</em:name>
<em:version>1.0</em:version>
<em:type>2</em:type>
<em:bootstrap>true</em:bootstrap>
<em:targetApplication>
<rdf:Description>
<!-- Firefox -->
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>10.0</em:minVersion>
<em:maxVersion>20.0</em:maxVersion>
</rdf:Description>
</em:targetApplication>
</rdf:Description>
</rdf:RDF>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment