Firefox Quantumのリリースとともに終焉を迎えた Vimperator。その代替アドオンとして Vimium-FFを使ってきた。
Vimium-FFの先行きが不安
しかし、 Find Command not working on firefox · Issue #3774 · philc/vimium · GitHubにあがっている、find mode(ページ内検索)したときに、一文字目に一致すると、その後、続く文字が入力ができない問題が鬱陶しく感じてきた。
そのうち直るかなと傍観していたが、
This project is not anymore actively mantained, I suggest to migrate away or take over the manteinance. This is the big disadvantage of opensource. see the quoted text in my message
と、作者に維持、改善していくモチベーションはないとのこと。それが事実かどうか分からないけど、更新が滞りがちな雰囲気1。この様子では修正されるとしてもかなり遅れそうだ。
Vimium, Vimperator 代替アドオン
I confirm that the Vimium-c extension does not have this issue with Firefox 86 on MacOS.. and works exactly like Vimium
同スレッドでは、 Vimium Cに乗り換えることを勧めてもいる。
Vimium C は全く使ったことないので、何とも言えないが、名前やスクリーンショットを見る限り、 Vimium-FF から乗り換えるにあたっては一番負荷が少なそう。
しかし、それとともに、
I was trying some new plugins and just find out 2 awesome tools for firefox which improve and can also replace Vimium
https://github.com/tridactyl/tridactyl
https://github.com/glacambre/firenvim
が紹介されていたので、当初より
This is a “Firefox Quantum” replacement for VimFX, Vimperator and Pentadactyl.
として Vimperator 代替アドオンを目指している Tridactyl を試すことにした。
Tridactyl インストール
Firefox Quantum登場当時、恐らく殆どの Vimperator 使いは、この Tridactyl を試しただろう。私の場合、ノーマルモードに戻るキーバインドがCtrl+]になっていなかったことや、オプション開くといきなり圧倒されるヘルプ画面が表示されることもあり、ちょっと試すにはあまりにハードルが高かった。なので、インストールはしたものの、ずっと無効化にしたままだった。
しかし、今回使ってみて驚いた。大分 Vimperator に近付いていた。
native messenger インストール
ともあれ、まずは tridactyl/native_messengerというものをインストールしないことにはその真価が発揮されないので、インストール。
nativeinstallを打つとクリックボードに、native messengerをインストールするためのコマンドがコピーされる。
Windows
>powershell -ExecutionPolicy Bypass -NoProfile -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12;(New-Object System.Net.WebClient).DownloadFile('https://raw.githubusercontent.com/tridactyl/native_messenger/master/installers/windows.ps1', '%TEMP%/tridactyl_installnative.ps1');& '%TEMP%/tridactyl_installnative.ps1' -Tag 1.21.1;Remove-Item '%TEMP%/tridactyl_installnative.ps1'"
Installing native messenger version 0.3.4 in C:\Users\arimasou16\.tridactyl
Entering C:\Users\arimasou16\.tridactyl
Downloading native messenger
ディレクトリ: C:\Users\arimasou16\.tridactyl
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 2021/05/15 19:35 0 native_main.exe
Downloading manifest
Registering native messenger
Exiting C:\Users\arimasou16\.tridactyl
Done
The installer for the native messenger has been copied to C:\Users\arimasou16\.tridactyl.
To uninstall the native messenger, navigate to that directory in Powershell
and run ".\installer.ps1 -Uninstall".
>
Linux
curl -fsSl https://raw.githubusercontent.com/tridactyl/native_messenger/master/installers/install.sh -o /tmp/trinativeinstall.sh && sh /tmp/trinativeinstall.sh 1.21.1
arimasou16@Aerobookplus:~$ curl -fsSl https://raw.githubusercontent.com/tridactyl/native_messenger/master/installers/install.sh -o /tmp/trinativeinstall.sh && sh /tmp/trinativeinstall.sh 1.21.1
Installing manifest here: /home/arimasou16/.mozilla/native-messaging-hosts/
Installing script here: XDG_DATA_HOME: /home/arimasou16/.local/share/tridactyl
Successfully installed Tridactyl native messenger!
Run ':native' in Firefox to check.
arimasou16@Aerobookplus:~$
設定ファイルのエクスポート
設定は、基本はFirefox ストレージ データベースに保存される。設定ファイルの 例は↓にある。
https://github.com/tridactyl/tridactyl/blob/master/.tridactylrc
書き方がいくつかあるみたいで、いきなり、こちらの
例をベースとして設定していくよりは、素直にmktかmktridactylrcで今の設定をエクスポートした方が良さそう2。
既に .tridactylrc が存在する場合は上書きはされないが、-fのオプションを付けるか、mkt!、mktridactylrc!だと上書きされる。引数としてファイル名を指定すると、native messengerがインストールされたディレクトリ~/.local/share/tridactyl直下にファイルが作成される。もちろん、パスで指定することもできる。
プロファイルディレクトリの設定
restartするには、Windowsではset profiledirされていないとcontroller in extcmd: Error: Couldn't deduce witch profile you want. See ':help profiledir'と表示されて出来ない。
なので、about:profilesでプロファイルについての画面を表示させて、これは使用中のプロファイルです。削除できません。3と表示させている方のルートディレクトリを設定させればいい。
↑の 例は、このプロファイル設定にしても
" set profile dir on Windows
jsb browser.runtime.getPlatformInfo().then(os=>{const profiledir = os.os=="win" ? "C:\\Users\\olie\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\gwm76nmk.default" : "auto"; tri.config.set("profiledir", profiledir)})
という書き方をしている。またset profiledir C:\Users\arimasou16\AppData\Roaming\Mozilla\Firefox\Profiles\8f1396eb.default-releaseと書くことでもOK。Windowsしかこの値を見ないようで、この設定値のためにLinuxとWindows端末ごと値を変更する必要はない。とはいえ、Windows複数端末で使う場合は駄目だろう。
設定ファイルのインポート
インポートは$HOME/.tridactylrcか$XDG_CONFIG_DIR/tridactyl/tridactylrc、Windowsは%USERPROFILE%\.tridactylrc4とファイルを置けば、ファイルの設定が適用される。
source --url https://raw.githubusercontent.com/arimasou16/dotfiles/master/.tridactylrcとした場合も、設定がインポートされる。
ちなみに
bind <F5> source ~/.tridactylrc
としてもちゃんと機能しなかった。というより
If no argument given, it will try to open ~/.tridactylrc, ~/.config/tridactyl/tridactylrc or $XDG_CONFIG_HOME/tridactyl/tridactylrc in reverse order. You may use a _ in place of a leading . if you wish, e.g, if you use Windows.
とあるので、引数なければsource ~/.tridactylrcとなるので、わざわざリマップするほどでもなかった。それでも、 tridactylrc の書き方が悪いのか、sourceコマンドが不安定なのか、たまにコマンドモードの取消が出来なくなったり、入力が出来なくなったり、設定が反映されてなかったりする。なので、基本はrestartしてる。またはset [定義名](引数無し)で値の確認をした方が良い。
設定のしかた
- tridactyl/config.ts at master · tridactyl/tridactyl · GitHub
- tridactyl/excmds.ts at master · tridactyl/tridactyl · GitHub
Tridactyl はググっても情報が余りないので、ひたすらhelp [コマンド]で調べていくのが近道。ただ、表示されるのがmoz-extension://直下なのでアドオンが効かない。なので下のtridactyl/excmds.tsの素のファイルを見てもいいかも。
以下、というか、これまでも私の勘違い、誤用で間違っている可能性もあるが、設定の細かい内容についての記載。
Quickmarks
" Make quickmarks for the sane Tridactyl issue view
quickmark a https://www.amazon.co.jp/
quickmark c https://console.aws.amazon.com/
quickmark d http://www.dmm.com/
quickmark f https://feedly.com/i/latest
quickmark g https://douga.geo-online.co.jp/
quickmark h https://www.hmv.co.jp/
quickmark i https://www.instagram.com/
quickmark l https://www.deepl.com/ja/translator
quickmark n https://www.netflix.com/jp/Login
quickmark p https://getpocket.com/a/
quickmark r https://www.rakuten.co.jp/
quickmark s https://app.simplenote.com/
quickmark t https://github.com/tridactyl/tridactyl/issues?utf8=%E2%9C%93&q=sort%3Aupdated-desc+
quickmark t https://tweetdeck.twitter.com/
quickmark x https://app.plex.tv/desktop
quickmark y https://www.youtube.com/?gl=JP
quickmark z https://us02web.zoom.us/signin
これでOK。これにより
-
go[mark]現在のページで開く。
bind gna tabopen https://www.amazon.co.jp/ -
gn[mark]新しいタブで開く。
bind goa open https://www.amazon.co.jp/ -
gw[mark]新しいウィンドウで開く。
bind gwa winopen https://www.amazon.co.jp/
三つが設定される。
新しいタブを開く
Tridactyl インストールすると、新規タブの表示が Tridactyl のヘルプ画面となる。
何もなしにするにはset newtab about:blank。
ただ、そもそも Speed Dial 2といった新しいタブの設定をカスタマイズしてる場合はどうするのか?
まずFirefoxの設定、ホーム -> 新しいタブの設定を Tridactyl から、表示したいアドオンに戻す。そして、新しいタブをtabopenでなく、Ctrl+tやタブ横の+で開く。アドレスバーの中点三つをクリックしてリンクをコピーをする。そして
set newtab moz-extension://d530a585-8263-4c4e-987f-1dbcb8772db9/newtab.html
のように設定すれば、tabopenで開いても、カスタマイズされたタブが表示される。
ヒント文字
set hintnames uniform
set hintchars hjklasdfgyuiopqwertnmzxcvb
でOK。set hintnames numeric5としていると、ヒント文字が変更されない。また、set hintchars "hjklasdfgyuiopqwertnmzxcvb"とダブルコーテーションで括ると"ダブルコーテーションもヒント文字となってしまい。その場合、"を押しても、遷移できない、といったことになる。必要な場合もあるが、 hintchars に限らず基本、コーテーションは要らないと思って良い。
キーワードよる検索エンジンを切り替え
tabopenの後、キーワードを入力することで、検索エンジンを変更してタブ、ページを開くことができる。
set searchurls.julia https://www.google.com/search?q=site:http://docs.julialang.org/en/v1%20
set searchurls.google https://www.google.com/search?q=
set searchurls.googlelucky https://www.google.com/search?btnI=I'm+Feeling+Lucky&q=
set searchurls.scholar https://scholar.google.com/scholar?q=
set searchurls.googleuk https://www.google.co.uk/search?q=
set searchurls.bing https://www.bing.com/search?q=
set searchurls.duckduckgo https://duckduckgo.com/?q=
set searchurls.yahoo https://search.yahoo.com/search?p=
set searchurls.twitter https://twitter.com/search?q=
set searchurls.wikipedia https://en.wikipedia.org/wiki/Special:Search/
set searchurls.youtube https://www.youtube.com/results?search_query=
set searchurls.amazon https://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=
set searchurls.amazonuk https://www.amazon.co.uk/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=
set searchurls.startpage https://startpage.com/do/search?language=english&cat=web&query=
set searchurls.github https://github.com/search?utf8=✓&q=
set searchurls.searx https://searx.me/?category_general=on&q=
set searchurls.cnrtl http://www.cnrtl.fr/lexicographie/
set searchurls.osm https://www.openstreetmap.org/search?query=
set searchurls.mdn https://developer.mozilla.org/en-US/search?q=
set searchurls.gentoo_wiki https://wiki.gentoo.org/index.php?title=Special%3ASearch&profile=default&fulltext=Search&search=
set searchurls.qwant https://www.qwant.com/?q=
上記設定で、tabopen twitter arimasou16とすれば
https://twitter.com/search?q=arimasou16 の検索結果が表示される。%sもしくは%s1、%s[数値]と記述することでクエリの置換場所を指定できる。ただ、日本のサイトのいくつかが未だに<meta http-equiv="content-type" content="text/html; charset=Shift_JIS">なために、マルチバイト文字を検索文字とすると、文字化けして正しく検索できない…
ホームページ
ヘルプを見ると
set homepages [“example.org”, “example.net”, “example.com”]
とあるが、set homepages.0 yahoo.co.jpという書き方でも良いらしい。勿論、set homepages ["yahoo.co.jp"]でもOK。
入力フォームへの自動フォーカス
入力フォームへのフォーカスはset allowautofocus falseとして、オフにしている。
Tridactyl適用除外ページの設定
autocmd DocStart ^http(s?)://app.eigosapuri.jp mode ignore
autocmd DocStart ^http(s?)://blog.feedly.com mode ignore
autocmd DocStart ^http(s?)://feedly.com mode ignore
autocmd DocStart ^http(s?)://jamstash.com mode ignore
autocmd DocStart ^http(s?)://mail.google.com mode ignore
autocmd DocStart ^http(s?)://manabi-gakushu.benesse.ne.jp mode ignore
autocmd DocStart ^http(s?)://oyayubi-typing.solaniwa.net mode ignore
autocmd DocStart ^http(s?)://tweetdeck.twitter.com mode ignore
autocmd DocStart ^http(s?)://unityroom.com mode ignore
autocmd DocStart ^http(s?)://www.e-typing.ne.jp mode ignore
という書き方。手動の場合は、Shift+Insertで切り替え。分かりにくいが、右下にひょっこりモードが表示されている。
タブ複製
何故か、ダブ複製が複製して、それを新規ウィンドウで開くになっていたので、変更。
- bind gD composite tabduplicate; tabdetach
+ bind gD composite tabduplicate
キーバインドの初期値がgDというのがちょっと特殊かな。ytをこちらに変更しても良いのだけど。
入力フォームのエディター変更
Firefox Quantumになって、もう駄目だろうと思ったら、テキスト、テキストエリア入力フォームにフォーカスしてのCtrl+iでエディターでの編集・入力ができる!
set editorcmd start cmd.exe /c "vim %f"
でやってみたら、というか"auto"でも .txt 関連付けエディターがvimになっていれば、それで開くような気がする。
Windowsでは、"notepad"はちゃんと保存すると入力フォームに反映される。しかし、上の設定や"gvim"は、GVim.exeが起動するのだけど、反映されない。どうしてなのか…と思ったら、
thinca/vim-singletonを使っていると駄目らしい。無効にしたらちゃんと反映された。
set editorcmd gvim -u NONE %fとしてみたら、上手くいったが、マルチバイト文字、つまり日本語が文字化けして反映…意味ねぇ。set editorcmd gvim -u NONE -c ":e ++enc=utf8"で上手くいった。
Lubuntuでも、set editorcmd nvimは上手く行かない。set kitty nvimとターミナル経由でなければ行けないようだ。こちらは起動だけでなく、ちゃんと反映された。
set editorcmd nvim-qtでも成功。gvimでも行けるっぽい。GUIアプリはターミナルを経由する必要はない。
ただ、ターミナルによっては
- editorcmd=“auto” get information from Firefox but does not send it back! · Issue #1035 · tridactyl/tridactyl · GitHub
- using terminator as my terminal emulator results in the same issue as gnome-terminal · Issue #1346 · tridactyl/tridactyl · GitHub
と、似たような課題があがっている。gnome-terminalだと上手く行かないとか。set editorcmd gnome-terminal --disable-factory -- vimで上手く行く。
- terminator(1) — Arch manual pages
- Ubuntu Manpage: xfce4-terminal - X ターミナルエミュレーター
- gnome-terminal - man pages section 1: User Commands
- D-Bus - ArchWiki
set editorcmd terminator -e 'vim %f'やset editorcmd xfce4-terminal --disable-server -e 'vim %f'だと上手く行くらしい。
js tri.browserBg.runtime.getPlatformInfo().then(os=>{const editorcmd = os.os=="linux" ? "kitty nvim" : "auto"; tri.config.set("editorcmd", editorcmd)})
というやり方なら、Windowsとエディターを使い分けられる。Windowsでは"auto"となった。set profileのところでも、そうだが、こうした書き方はmktridactylrcのときに適応されているOSの設定値だけで出力されるため、注意が必要。
カラースキーマ
colourscheme [カラースキーマ]でsetは不要。カラースキーマテーマは
tridactyl/src/static/themesから確認できる。
URLコピー
-
yankcanon
初期値だと
bind yy clipboard yankcanon。正規化されたURL、canonical属性のURLがコピーされる6。他、shortlink属性をコピーするyankshortもある。 -
yank
bind yy clipboard yankだと https://www.youtube.com/watch?v=cbp3p5yCHwc とクエリーまでコピーされる。 -
yankmd
bind ym clipboard yankmdとymでタイトルとリンクをマークダウン形式でのコピーが可能。 -
yankorg
bind yo clipboard yankorg。yoでタイトルとリンクをEmacsのorg-modeのための形式でコピーできるらしい。 -
yanktitle
bind yt clipboard yanktitle。タイトルだけのコピー。
とURLコピー系アドオンが不必要になる程の充実ぶり。
コマンドモードの補完
コマンドを候補から選択したい。それは通常、TabしてEnterで成し遂げられるが、時に補完だけして、実行はしてほしくない、というときもある。
bind --mode=ex <C-f> ex.complete
bind --mode=ex <Space> ex.insert_space_or_completion
ので上記キーで試すも。良く分からない。ただ、コマンド文字列をシェル、Emacs系のキーバインドで移動、削除できるのは素晴らしい。
ページ内検索のキーバインド
/ — find the next/previous instance of the last find operation (note: these are the standard Firefox shortcuts)
今だとページ内検索で、次の検索はCtrl+g、前の検索はCtrl+Shift+gとnとNでない。
- Support ’n’ for Find Again · Issue #64 · tridactyl/tridactyl · GitHub
- Issues with our find mode · Issue #1612 · tridactyl/tridactyl · GitHub
bind n findnext 1
bind N findnext -1
とやっても動かない。対応待ち。
次、前のページ遷移
set followpagepatterns.next ^(次へ|進む|もっと見る|もっとみる|次のページ|続き|next|newer|more|(>|→|»|≫|>>)\b)
set followpagepatterns.prev ^(前へ|戻る|前のページ|prev(ious)?|older|back|(<|←|«|≪|<<|«|<<)\b)
とりあえず適当に設定しているが、どうしてか google.com のページ遷移が上手くいかず、
Yahoo!ニュースでのコメントも、comments?page=2とクエリが付かない一ページ目だと、変な部分がインクリメントだけされて、遷移できない。まあ、出来るサイトでは出来るのだけど…
Tridactyl help pageで調べると、動きとしては、以下のように処理するらしい。
- find the last anchor on the page with innerText matching the appropriate followpagepattern.
- call urlincrement with 1 or -1
翻訳挿入
例どおり以下のように記述して、コマンドtranslateを実行すると、閲覧ページに翻訳バーを挿入できる。
alias translate js let googleTranslateCallback = document.createElement('script'); googleTranslateCallback.innerHTML = "function googleTranslateElementInit(){ new google.translate.TranslateElement(); }"; document.body.insertBefore(googleTranslateCallback, document.body.firstChild); let googleTranslateScript = document.createElement('script'); googleTranslateScript.charset="UTF-8"; googleTranslateScript.src = "https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit&tl=&sl=&hl="; document.body.insertBefore(googleTranslateScript, document.body.firstChild);
はじめ、標準機能かと早合点したよ。しかし、ここまでカスタマイズできるということだ。
コンテナー
恐しいのはコンテナー系のコマンドも用意されていてcontainerupdate、containerclose、containercreate、containerdelete、autocontainを使えば
要らなくなるのかなーとか思ったが、どうも上手く行かない。
containercreate arimasou16 red briefcase
containercreate facebook turquoise fence
contextualIdentities.ContextualIdentity - Mozilla | MDNを参考にしながら、コンテナーは作れたのだけど、autocontainが良く分からずautocontain -s facebook\.com facebookとやってもset autocontainで確認すると変な値になっている。しかも tridactylrc ファイルからautocontainの行を削除しても設定値が残りつづける。
Configuration example for autocontain-开源项目-CSDN问答を見るとjs tri.config.set("autocontain", "facebook\.com", "facebook")ってやるとあるが、出来ない。というか、autocontainの設定値が消えない…消したい。
set autocontainmode strict
autocontain first\.com some_container
とやってるのだが。ともあれset autocontainmode {}とやると完全に消えないまでも# autocontain = {"0":"{","1":"}"}といった値になった。マジわけ分からんな。
とりあえず、一度 Tridactyl アドオンを削除して、インストールしなおしたら、初期化された。怖くて、再度試す気になれない。
最後に
自分も二日ぐらい触ったぐらいで、わけの分からない状態が続いていて、イマイチ動きが良く分からない部分も多いのだが、ついにここまで出来るようになったんだな、と感慨深い。
【悲報!】もう Chromium で同期機能が使えません。 | PC-FREEDOMに見られるように Chromiumから同期機能とGoogle APIへのアクセスを削除されたことで、Chromiumをベースとしたブラウザにも今後、影響が出てくるかも知れない。
Firefox Quantumリリース以降、シェアをMicrosoft Edgeにも抜かされた状況だが、やはりFirefoxを応援していきたい。
-
2021/05/16時点、最終コミットは2020/06/15。 ↩︎
-
とはいえ、設定した状況によりけりなのか、初めて
mktしたときは80行ぐらいだったが、設定を加えていった後に再度行うと300行ぐらいに増えていた。 ↩︎ -
知らぬまにWindowsもLubuntuも default-release に加えて release が作成されている。要らなそうだがら、ついでに削除した。 ↩︎
-
Windowは
_tridactylrcとドットファイルでなくても良い。 ↩︎ -
これだとYoutubeでどれを見てても https://www.youtube.com/ がコピーされるというのは間違いだった。canonical属性のURLにも普通にクエリまで含まれていた。 ↩︎



