Firefoxにインストール済みのExtensionは、もちろんExtension Managerで確認できるわけですが、なんかの拍子にプロファイル作り直しの刑を受けてしまうと当然Extensionも入れ直しなわけです。この作業は、新たなExtensionを導入する作業と違ってかったるいだけの作業だったりするわけで。てなわけでその作業の手間を少し楽にするためにインストール済みのExtensionの情報が書かれているExtension.rdfを(かなり適当に)パースして、Extensionの名前とバージョン、配布サイトのURLをリスト・アップするスクリプトを書いてみました。・・・WSH with JScriptで。

Extensions.rdfの構造はちゃんと調べてないのでよく知らない(最低)のですが、どうもインストールしたExtensionについてはem:versionとかem:nameとかいう属性を持つRDF:Description要素が追加されるようなので、それを単純にリストアップしてみました。

// fxexts.js

var oArgs = WScript.Arguments;
var fFxExtsRdf = oArgs(0);

var oFileSys = new ActiveXObject("Scripting.FileSystemObject");

if (!oFileSys.FileExists(fFxExtsRdf)) {
  WScript.Echo(fFxExtsRdf + "\nファイルが見つかりません。\n指定したファイル名が正しいかどうか確認してください。");
  WScript.Quit();
}

var xmlDoc  = new ActiveXObject("Msxml2.DOMDocument.3.0");

xmlDoc.async = false;
xmlDoc.load(fFxExtsRdf);

if (xmlDoc.parseError.errorCode != 0) {
  WScript.Echo(xmlDoc.parseError.reason);
  WScript.Quit();
}

var descriptionNodes = xmlDoc.getElementsByTagName("RDF:Description");
var sExtsList = "";

for (var i = 0; i < descriptionNodes.length; i++) {
  var description   = descriptionNodes.item(i);
  var emName        = description.getAttribute("em:name");
  var emVersion     = description.getAttribute("em:version");
  var emHomepageUrl = description.getAttribute("em:homepageURL");

  if (emName && emVersion && emHomepageUrl) {
    sExtsList += emName + " version " + emVersion + "\n" + emHomepageUrl + "\n";
    sExtsList += "----------------------------------------\n";
  }
}

if (sExtsList) {
  sExtsList = "Firefox installed Extensions\n========================================\n" + sExtsList;
  WScript.Echo(sExtsList);
}

WScript.Quit();

使い方は、コマンドプロンプトでfxexts.jsを保存したフォルダに移動し、

C:> cscript.exe //Nologo fxexts.js <Extensions.rdfのパス>

とすると、標準出力にそのまま単純なリストが出力されます(わかりづら)。出力例はこんな感じ。

Firefox installed Extensions
========================================
LiveHTTPHeaders version 0.9
http://livehttpheaders.mozdev.org/
----------------------------------------
Link Toolbar version 0.9
http://cdn.mozdev.org/linkToolbar/
----------------------------------------
Add Bookmark Here version 0.5.2
http://gorgias.de/mfe/
----------------------------------------
Tab Clicking Options version 0.2.1
http://twanno.mozdev.org/
----------------------------------------
Popup ALT Attribute version 1.3.2004102501
http://piro.sakura.ne.jp/xul/_popupalt.html.en
----------------------------------------
FlashGot version 0.5.3
http://www.informaction.com/mozilla/flashgot/
----------------------------------------
Plain Text Links version 0.2
http://ted.mielczarek.org/code/mozilla/
----------------------------------------
Right Encoding version 0.1
http://heygom.com/extensions/
----------------------------------------
Sage version 1.3
http://sage.mozdev.org
----------------------------------------
Feed Your Reader version 0.8.1
http://projects.koziarski.net/fyr/
----------------------------------------
Paste and Go version 0.4.1
http://tecwizards.de/mozilla/
----------------------------------------

Extensions.rdfはプロファイル・フォルダのextensionsというフォルダ直下にあります。

WSH with JScriptな理由は、XMLを手軽にパースできる環境だからで、それ以外には理由は無いです。WSH with JScriptなので当然Windowsマシンじゃないと動かないです。その他にもいろいろ条件があるけどメンドウなので言わない。

てか、こういった機能は実はFirefoxにビルトインで存在しそうなを気がしないでもない。まぁ良いんだけど。てか、「Extensionをインストールした時に、ちゃんとメモしておくとかしておけばこんなのいらないじゃん?」とかなんとか。