(function () { var bookmarklet = prompt('Paste bookmarklet here'); if (bookmarklet) { Array.prototype.forEach.call(gBrowser.mTabs, function (tab) { gBrowser.getBrowserForTab(tab).contentWindow.document.location.href = bookmarklet; }); } })();
promptじゃなくてブックマークの任意のフォルダ以下から選択して実行とかできるようにしたい。これだとコピペの手間が面倒。
追記
Array.prototype.forEach.call(gBrowser.mTabs, function (tab) {
じゃなくて
Array.forEach(gBrowser.mTabs, function (tab) {
って書けるんだ。クラスメソッド。知らなかった。Firefox 1.5 の JavaScript の主な変更点: Days on the Moon