階層を1つ上に上がるGo Upを右クリックメニューに追加する
階層を1つ上に上がるボタンの拡張機能 "Go Up" を userChrome.js を使って右クリックメニューに追加するコードです。
(function() { const GoUpMenu = { init: function() { var urlbar = document.getElementById('urlbar'); }, menuClicked: function(e) { var up = this.getUp(_content.document.location.href); openUILink(up, e); }, getUp: function(url) { var matches, origUrl = url; matches = url.match(/(^.*\/)(.*)/); if(!matches) { return null; } url = matches[1]; if(url != origUrl && !/(index|main)\.(php3?|html?)/i.test(url)) { return url; } matches = url.match(/^([^\/]*?:\/\/.*\/)[^\/]+?\//); if(matches) { return matches[1]; } matches = url.match(/([^:]*:\/\/)?(.*)/); var protocol = matches[1], domain = matches[2]; matches = domain.match(/^[^\.]*\.(.*)/); if(matches) { return (protocol + matches[1]); } return null; } }; window.addEventListener('load', function() { GoUpMenu.init; }, false); var contextmenu = document.getElementById('contentAreaContextMenu'); var menuitem = document.createElement('menuitem'); menuitem.setAttribute('id', 'context-goupmenu'); menuitem.setAttribute('label', 'Go Up'); menuitem.addEventListener('command', function(e) { GoUpMenu.menuClicked(e); }, false); contextmenu.insertBefore(menuitem, document.getElementById('context-stop').nextSibling); contextmenu.addEventListener('popupshowing',function() { var cm = gContextMenu; menuitem.hidden = (cm.isTextSelected || cm.onLink || cm.onImage || cm.onTextInput); }, false); })();
Firefoxのメインメニューをまとめる
Firefox のメインメニューのラベルを変更する と 不要なメニューを非表示にする を参考にしてメインメニューをまとめてラベルを変更する userChrome.js スクリプトを作ってみました。
(function() { var aTarget = getTopWin().document.getElementById('main-menubar'); var menu = document.createElement('menu'); menu.setAttribute('id', 'firefox-mainmenu'); menu.setAttribute('label', 'Fox'); menu.setAttribute('accesskey', 'F'); var popup = document.createElement('menupopup'); var menucount = aTarget.childNodes.length; var j = 0; var showFlag = { "File" : false, "Edit" : false, "View" : false, "History" : false, "Books" : true, "Tools" : false, "Help" : false } for (var prop in showFlag) { aTarget.childNodes[j].setAttribute('label', prop); if (showFlag[prop]) { j++; } else { popup.appendChild(aTarget.childNodes[j]); } } menu.appendChild(popup); aTarget.appendChild(menu); })();
こんな感じになります。
FoxメニューにBooks(Bookmarks)以外のメニューがまとめられます。
showFlagの部分を適当に変更すれば、カスタマイズできます。
Ubuntuでmp3をエンコード・デコード
エンコードに必要なもの
lame, gstreamer0.8-lame, gstreamer0.10-plugins-ugly-multiverse をインストールする。
$ sudo apt-get install lame gstreamer0.8-lame gstreamer0.10-plugins-ugly-multiverse
再生に必要なもの
gstreamer0.10-plugins-ugly をインストールする。
$ sudo apt-get install gstreamer0.10-plugins-ugly
UbuntuでWindowsメディア再生
コーデック(w32codecs)をインストールする。
$ wget -c http://www.debian-multimedia.org/pool/main/w/w32codecs/w32codecs_20060611-0.0_i386.deb $ sudo dpkg -i w32codecs_20060611-0.0_i386.deb
UbuntuでAACを再生する
gstreamer0.10-plugins-bad-multiverse, gstreamer0.10-plugins-bad をインストールする。
$ sudo apt-get install gstreamer0.10-plugins-bad-multiverse gstreamer0.10-plugins-bad
UbuntuでDVDを再生する
libdvdcss2, VLC media player をインストールする。
$ sudo /usr/share/doc/libdvdread3/install-css.sh $ sudo apt-get install vlc
CuberXtreme
CuberXtreme
パズルゲーム。
flash版の最後のパズルが解けない...
vim (on Putty) でインデントを崩さずにペーストする
:a[Enter]を入力後に[Shift]+[Insert][ESC]でペーストする。
Firefox2.0
Firefox2.0正式版がリリースされたので使ってみる。
普段使っている拡張機能は問題なくインストールできた。
右クリックメニューが選択状態のメニューではなく通常のメニューの状態になってコピーできなくなる場合がある。
JSActionsを使用したときに発生するもよう。