今年は何かFirefox Add-onを作ろう

あけましておめでとうございます

開発用プロファイルを作る

firefox -ProfileManagerで起動して新しいプロファイルを作る

開発用のアドオンを入れとく

あたり

about:configをいじる
  • nglayout.debug.disable_xul_cache = true
  • extensions.firebug.showChromeErrors = true
  • extensions.firebug.showChromeMessages = true

とか
http://developer.mozilla.org/ja/docs/Setting_up_extension_development_environment

最低限のxpiをつくる

index.rdf

http://developer.mozilla.org/ja/docs/install.rdf

<?xml version="1.0"?>
<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:name>myExtention</em:name>
    <em:description>myExtention Descriptions</em:description>
    <em:creator>id:tnx</em:creator>
    <em:id>myExtentionId</em:id>
    <em:version>0.01</em:version>
    <em:type>2</em:type>
    <em:targetApplication>
      <Description>
        <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> 
        <em:minVersion>2.0</em:minVersion>
        <em:maxVersion>2.*</em:maxVersion>
      </Description>
    </em:targetApplication>
  </Description>
</RDF>

必須なのは

  • id
  • version
  • type
  • targetApplication
  • name
chrome.manifest

http://developer.mozilla.org/ja/docs/chrome.manifest

content  myExtention                           content/
overlay  chrome://browser/content/browser.xul  chrome://myExtention/content/myExtention.xul
content/myExtention.xul
<?xml version="1.0" encoding="UTF-8"?>
<overlay id="myExtention" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
</overlay>

インストールする

をzipで固めて拡張子をxpiにしてfirefoxドラッグアンドドロップ

あとは

プロファイルの中に展開された.xulとかをいじるいじる
chrome://browser/content/browser.xulをアドレスバーに入れて表示するとfirebugで色々inspectできて便利便利
Firefox拡張機能(extension)の作り方 — ありえるえりあに大変よくまとまっている
拡張機能 | MDNにも大変よくまとまっている