2011/08/10
github にリポジトリを作った
ずっと gist 使ってたけど差分が見たかったり目的のものを探すのが面倒だったのでちゃんとリポジトリを作りました。
使い方がサッパリですが、これからはこちらにアップしていきます。
UserScriptLoader を更新
全体的に書き直しました。
更新しておいて言うのもアレなんだけど、Scriptish に移行したほうがいいんじゃないかな?(ぇ
uAutoPagerize を更新
- INCLUDE, EXCLUDE をワイルドカード式にした
- アイコンに右クリックメニューを付けた
- スクロールするまでは次を読み込まないオプションをつけた
UserCSSLoader を更新
- スタイルのテスト機能を作り直した
- ファイルが削除された場合 rebuild 時に CSS を解除しメニューを消すようにした
- uc で読み込まれた .uc.css の再読み込みに仮対応
AutoPagerize の継ぎ足し後もページ内検索の強調をする
サイドバーを上下左右に移動させる
2011/07/11
addMenu.uc.js 更新
バグ修正と機能の追加です。
- %URL_HTMLIFIED%, %EOL_ENCODE% が変換できなかったミスを修正
- %LINK_OR_URL% 変数を作成(リンク URL がなければページの URL を返す)
- タブの右クリックメニューでは %URL% や %SEL% はそのタブのものを返すようにした
- keyword で "g %URL%" のような記述を可能にした
- ツールの再読み込みメニューの右クリックで設定ファイルを開くようにした
// 2つ書くのがだるいので page({ label: "Internet Explorer で開く", text: "%u", exec: "C:\\Program Files\\Internet Explorer\\iexplore.exe", accesskey: "I", condition: "nolink" }); page({ label: "リンクを Internet Explorer で開く", text: "%l", accesskey: "I", exec: "C:\\Program Files\\Internet Explorer\\iexplore.exe" }); // こう書けるようにした page({ label: "Internet Explorer で開く", text: "%LINK_OR_URL%", exec: "C:\\Program Files\\Internet Explorer\\iexplore.exe", accesskey: "I", }); // これも page({ label : "リンクのテキストを検索", text : "%LINK_TEXT%", keyword: "g", where : "tab" }); // keyword にまとめて書けるようにした page({ label : "リンクのテキストを検索", keyword: "g %LINK_TEXT%", where : "tab" });
適当なサンプル追加
スクリプトの機能を使ってないけど気にしない。
- タブ毎に JS や画像の ON/OFF を切り替えるメニューを作る
var allow_list = ["allowImages", "allowJavascript", "allowMetaRedirects", "allowPlugins", "allowSubframes"]; var allow = TabMenu({ label: "タブの環境設定", accesskey: "O", onpopupshowing: function(event) { var docShell = document.popupNode && document.popupNode.linkedBrowser ? document.popupNode.linkedBrowser.docShell : gBrowser.mCurrentBrowser.docShell; Array.slice(event.target.children).forEach(function(menuitem){ var alw = menuitem.getAttribute("allow"); if (!alw) return; menuitem.setAttribute("checked", docShell[alw]); }); }, }); allow_list.forEach(function(e){ allow({ label: e.substr(5), type: "checkbox", checked: "true", allow: e, accesskey: e[5], oncommand: function(event) { var docShell = document.popupNode && document.popupNode.linkedBrowser ? document.popupNode.linkedBrowser.docShell : gBrowser.mCurrentBrowser.docShell; var alw = event.target.getAttribute("allow"); docShell[alw] = !docShell[alw]; }, onclick: function(event) { if (event.button != 1) return; event.preventDefault(); event.stopPropagation(); var docShell = document.popupNode && document.popupNode.linkedBrowser ? document.popupNode.linkedBrowser.docShell : gBrowser.mCurrentBrowser.docShell; var alw = event.target.getAttribute("allow"); var bool = docShell[alw] = !docShell[alw]; event.target.setAttribute("checked", bool); } }); }); allow([ { }, { label: "全て許可", allows: allow_list.join(","), accesskey: "E", oncommand: function(event){ var docShell = document.popupNode && document.popupNode.linkedBrowser ? document.popupNode.linkedBrowser.docShell : gBrowser.mCurrentBrowser.docShell; event.target.getAttribute('allows').split(',').forEach(function(e){ docShell[e] = true; }); } }, { label: "全て拒否", allows: allow_list.join(","), accesskey: "D", oncommand: function(event){ var docShell = document.popupNode && document.popupNode.linkedBrowser ? document.popupNode.linkedBrowser.docShell : gBrowser.mCurrentBrowser.docShell; event.target.getAttribute('allows').split(',').forEach(function(e){ docShell[e] = false; }); } } ]);
- 最近閉じたタブメニューを作る
PageMenu({ label: "最近閉じたタブ", onpopupshowing: function(event) { var popup = event.target; var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore); var data = JSON.parse(ss.getClosedTabData(window)); data.forEach(function(obj, i){ var entry = obj.state.entries[obj.state.index-1]; var m = document.createElement("menuitem"); m.setAttribute("label", obj.title); m.setAttribute("image", obj.image); m.setAttribute("class", "menuitem-iconic bookmark-item menuitem-with-favicon"); m.setAttribute("value", i); m.setAttribute("oncommand", "undoCloseTab(" + i + ");"); popup.appendChild(m); }); }, onpopuphidden: function(event){ var range = document.createRange(); range.selectNodeContents(event.target); range.deleteContents(); range.detach(); } });
- 選択範囲を〇〇するメニューを作る
var selmenu = PageMenu({ label: "Selection", condition:"select", accesskey: "R", insertBefore: "frame-sep" }); selmenu([ { label: "選択文字列を強調", oncommand: function(event) { var win = addMenu.focusedWindow; var sel = win.getSelection(); var ts = {}; for (var i = 0, len = sel.rangeCount; i < len; i++) { var word = sel.getRangeAt(i).toString(); if (!ts[word]) { gFindBar._highlightDoc(true, word, win); ts[word] = true; } }; } }, { label: "選択範囲内のリンクを開く", oncommand: function(event) { var sel = addMenu.focusedWindow.getSelection(); var urls = {}; for (var i = 0, len = sel.rangeCount; i < len; i++) { Array.forEach(sel.getRangeAt(i).cloneContents().querySelectorAll('a:not(:empty)'), function(a){ if (!urls[a.href] && /^http|^file/.test(a.href)) gBrowser.addTab(a.href); urls[a.href] = true; }); }; } }, { label: "選択範囲内のチェックボックスを ON", class: "checkbox", oncommand: function(event) { var win = addMenu.focusedWindow; var sel = win.getSelection(); Array.slice(win.document.querySelectorAll('input[type="checkbox"]:not(:disabled)')).forEach(function(e) { if (sel.containsNode(e, true)) e.checked = true; }); } }, { label: "選択範囲内のチェックボックスを OFF", class: "checkbox", oncommand: function(event) { var win = addMenu.focusedWindow; var sel = win.getSelection(); Array.slice(win.document.querySelectorAll('input[type="checkbox"]:not(:disabled)')).forEach(function(e) { if (sel.containsNode(e, true)) e.checked = false; }); } }, ]);
2011/07/04
uAutoPagerize 更新
セキュリティ問題の報告を受けたので更新します。
ヤフオクで動かなかったので修正。Ver 0.1.9.1
まあ動かないのが正常と言えば正常なんですが…。
アイコンが紫になるエラーは意図的に止めてるのであんまり気にしないように。
ヤフオクは以下の流れで動作するんですが、
基本的に 1 と 2、2 と 3 が違ったらエラーで終了します。
今まで 2 と 3 がどちらも yahoo.co.jp なら例外的に許可してましたが、昨日の修正時に例外処理を 1 と 2 の方に持ってきたのでリダイレクトでエラーになりました。
今回 2 と 3 もチェックするようにしたのでヤフオクでも動きます。
そこまで不便にはなっていないのですが、以前の方が視認しやすいので修正お願いできないでしょうか?
よろしくお願いします。