Install Greasemonkey addon to Mozilla Prism

capture image

Prism 0.9のバグを回避したことでGreasemonkeyを入れることに成功した。当然ながらGreasemonkeyFirefox,Songbird向けであるので、いくつかパッチを当てる必要がある。

予告どおり出来たということでその方法を書くよ。

環境

Firefox AddonとしてあるPrismの方は試していないので分からない。たぶん出きると思う。

適用方法

Prismはインストール済みとします。オイラの場合は~/opt/prismにある。また、バージョン0.9の場合Prism 0.9のバグを回避する必要があるだろう。

1. Greasemonkeyのダウンロードと展開

パッチを適用するためにGreasemonkeyをダウンロードする必要がある。既にFirefoxに入れている人はProfD/extensions/{e4a8a97b-f2ed-450b-b12d-ee082ba24781}/ディレクトリをコピーしても構わない。

$ cd /tmp
$ wget https://addons.mozilla.org/ja/firefox/downloads/file/30326/greasemonkey-0.8.20080609.0-fx.xpi
$ unzip greasemonkey-0.8.20080609.0-fx.xpi -d greasemonkey
$ cd greasemonkey/chrome
$ unzip greasemonkey.jar chromeFiles

Firefoxに入れているGreasemonkeyをコピーした人はgreasemonkey.jarの展開のみでOK

2. パッチの適用
  1. greasemonkey-prism-1.patch
  2. greasemonkey-prism-2.patch

上記2つのパッチを当てる。
前者はinstall.rdf,chrome.manifestへのパッチで、後者はgresemonkey.jarを展開したファイルchromeFiles/content/browser.xul,chromeFiles/content/browser.jsへのパッチである。

$ cd /tmp/greasemonkey
$ wget -q http://www.paw.hi-ho.ne.jp/makochi/prism/greasemonkey/greasemonkey-prism-1.patch -O- | patch
$ cd chrome/chromeFiles/content
$ wget -q http://www.paw.hi-ho.ne.jp/makochi/prism/greasemonkey/greasemonkey-prism-2.patch -O- | patch
3. jarファイルの更新

展開したgreasemonkey.jarにパッチを当てたファイルを更新する。更新したら展開したファイルは不要なので削除(残しておいても良いけど)

$ cd /tmp/greasemonkey/chrome
$ zip -u greasemonkey.jar chromeFiles/content/browser.{js,xul}
$ rm -r chromeFiles icons
4. Addonとして登録

以下、二通りのやり方がある。

  • xpiファイルを作成し直してAddonダイアログからインストール
  • Prismのインストールされたディレクトリに配置する

両者には明確な違いがあり、前者はそのWebアプリケーション単体のみにGreasemonkeyがインストールされ、後者はPrismを通して起動されるもの全てにGreasemonkeyが有効になる。どちらにしても、ユーザスクリプトは個々のプロファイルで管理されるためアプリケーション単位で独立している。

まずは前者から

$ # xpiファイルを作成
$ cd /tmp/greasemonkey
$ zip -r greasemonkey.xpi *
  1. アプリケーションを起動
  2. ステータスバーにあるメニュー -> tools -> Addons でAddonダイアログを出す
  3. "install"ボタンからxpiファイルを指定
  4. 再起動

次に後者

$ mv tmp/greasemonkey installDir/extensions/\{e4a8a97b-f2ed-450b-b12d-ee082ba24781\}*1

移動させたらアプリケーションを起動すれば有効になっているだろう。

ユーザスクリプトのインストール

残念ながらFirefoxの様に簡単にインストールは出来ない。何故なら、prismのWebアプリケーションは他ドメインのURLを開けないからである*2。よって、手動でファイルの配置とconfig.xmlの編集をする必要がある。まぁ大抵はFirefoxに入っているものをコピー/真似で良いから難しくはないでしょう。

最後に

所謂自己責任ってやつでお願いします。できるだけ対応はしますが、責任は持てません。
あと、Prismは単独のドメインに絞ることでセキュア性を高めている訳だが、それにGreasemonkeyを入れるってどうなよって感じがあったりなかったり :)

*1:installDirはPrismがインストールされたディレクトリ。オイラの場合は~/opt/prismとなっている。

*2:JavaScriptのwindow.openを使うと他ドメインも開けちゃうけどね :P