「W3m」の版間の差分

提供: ArchWiki
ナビゲーションに移動 検索に移動
 
(英語版から転載)
タグ: リダイレクト解消
1行目: 1行目:
  +
{{Lowercase title}}
#redirect[[アプリケーション一覧/インターネット#ウェブブラウザ]]
 
  +
[[Category:ウェブブラウザ]]
  +
[[en:w3m]]
  +
[[pt:W3m]]
  +
{{Related articles start}}
  +
{{Related|ELinks}}
  +
{{Related|Lynx}}
  +
{{Related articles end}}
  +
[https://salsa.debian.org/debian/w3m w3m] is a text-based web browser as well as a pager like [https://en.wikipedia.org/wiki/More_(command) more] or [[less]]. With w3m you can browse web pages through a [[Terminal emulator]] window. Moreover, w3m can be used as a text formatting tool which typesets HTML into plain text.
  +
  +
== Installation ==
  +
  +
[[Install]] the {{Pkg|w3m}} package.
  +
  +
== Usage ==
  +
  +
See {{man|1|w3m}}.
  +
  +
== Configuration ==
  +
  +
w3m can either be configured using the in-browser settings menu or by directly modifying its configuration files.
  +
  +
Some of the more advanced options are not available using the settings menu, so it is recommended editing the configuration files themselves.
  +
  +
By default all configuration files reside in {{ic|~/.w3m}}.
  +
  +
== Tips and tricks ==
  +
  +
=== Vim keybinds ===
  +
  +
Replace {{ic|~/.w3m/keymap}} with a [https://gist.githubusercontent.com/Lovebird-Connoisseur/a11b9dbc5c056d705d1f0e1053de35af/raw/92b30d2ca4cf67b5816146f86f5d920b4bdfc492/keymap custom configuration].
  +
  +
=== URL hints ===
  +
  +
w3m supports [[qutebrowser]]-like link navigation, simply navigate to your config file and change the following line from {{ic|display_link_number 0}} to {{ic|display_link_number 1}}.
  +
  +
And add {{ic|keymap f COMMAND "RESHAPE ; LINK_BEGIN ; GOTO_LINK"}} and {{ic|keymap F COMMAND "RESHAPE ; LINK_BEGIN ; TAB_LINK"}} to {{ic|~/.w3m/keymap}}.
  +
  +
{{Note|While qutebrowser supports a variety of keys to select hints, in w3m you can only select links using the number keys.}}
  +
  +
=== Using kittens image protocol ===
  +
  +
Users of the [[kitty]] terminal emulator may chose to use its own [https://sw.kovidgoyal.net/kitty/graphics-protocol/ graphics protocol].
  +
  +
To do so simply change the following lines in {{ic|~/.w3m/config}}:
  +
  +
inline_img_protocol 0
  +
imgdisplay w3mimgdisplay
  +
  +
to:
  +
  +
inline_img_protocol 4
  +
imgdisplay kitty
  +
  +
=== Searching ===
  +
  +
You can set {{ic|wrap_search}} to 1, to allow searches to jump to the top after they have hit the bottom of all matches within a page.
  +
  +
You can set {{ic|ignorecase_search}} to 1 to enable case insensitive searching.
  +
  +
{{Note|Unlike other browsers and text editors, w3m has no option for smartcase searching.}}
  +
  +
=== Custom search engines ===
  +
  +
You can map keys to launch a CGI script that will capture your input and pass it onto a custom search engine, to do so first create a keybind inside {{ic|~/.w3m/keymap}} to launch your script:
  +
  +
keymap s COMMAND "SET_OPTION dictcommand=file:///cgi-bin/omnibar_google.cgi ; DICT_WORD"
  +
  +
And place [https://raw.githubusercontent.com/gotbletu/shownotes/master/w3m_omnibar/omnibar_google.cgi omnibar_google.cgi] inside your {{ic|~/.w3m/cgi-bin}} directory and giving it execute permission.
  +
  +
While the above script will return a Google result, you can use these kinds of scripts to search StackOverflow, GitHub, DuckDuckGo, Reddit and a bunch of other websites.
  +
  +
You can view similar scripts on [https://github.com/gotbletu/shownotes/tree/master/w3m_omnibar GitHub].
  +
  +
=== Reader mode ===
  +
  +
Some webpages do not work well with w3m, be it because they use a lot of javascript or CSS to display most of their content. Very often you will have to scroll multiple pages just to get to the start of an article.
  +
  +
This can be mitigated by first passing the webpages through a reader mode program such as {{AUR|rdrview-git}}.
  +
  +
To do so add the following to {{ic|~/.w3m/keymap}}:
  +
  +
keymap R COMMAND "READD_SHELL 'rdrview $W3M_URL -H 2> /dev/null 1> /tmp/readable.html' ; LOAD /tmp/readdable.html"
  +
  +
=== Redirect URLs ===
  +
  +
{{ic|~/.w3m/siteconf}} file is used to set some preferences depending on the website, such as: referrer and user agent.
  +
  +
It can also be used to redirect to lighter (both in terms of layout and bandwidth), more privacy respecting alternatives to websites.
  +
  +
In addition to this it can also be used to run certain CGI scripts.
  +
  +
{{hc|~/.w3m/siteconf|<nowiki>
  +
url m!^https?://([a-z]+\.)?twitter\.com/!
  +
substitute_url "https://nitter.net/"
  +
  +
url m!^https?://([a-z]+\.)?reddit\.com/!
  +
substitute_url "https://safereddit.com/"
  +
  +
#url m!^https?://([a-z]+\.)?google\.com/!
  +
#substitute_url "https://duckduckgo.com/lite/"
  +
  +
url m!^https?://([a-z]+\.)?imgur\.com/!
  +
substitute_url "https://rimgo.pussthecat.org/"
  +
  +
url m!^https?://([a-z]+\.)?wikipedia\.com/!
  +
substitute_url "https://wl.vern.cc/"
  +
  +
url "https://www.youtube.com/" exact
  +
substitute_url "file:/cgi-bin/video.cgi?"
  +
#substitute_url "https://yewtu.be/"
  +
  +
url "https://stackoverflow.com/" exact
  +
substitute_url "https://ao.bloatcat.tk/"
  +
  +
url "https://www.reuters.com/" exact
  +
substitute_url "https://neuters.de/"
  +
  +
url "https://fandom.com/" exact
  +
substitute_url "https://breezewiki.pussthecat.org/"
  +
  +
url "https://medium.com/" exact
  +
substitute_url "https://scribe.rip/"
  +
  +
url "https://web.archive.org/" exact
  +
substitute_url "https://wayback-classic.net/"
  +
</nowiki>}}
  +
  +
=== Restore closed windows ===
  +
  +
Default w3m cannot reopen closed tabs, this can be added by binding the close tab button to echo the current URL of the tab to be closed to a text file, and binding another key to restore the latest URL added to the file, using a CGI script.
  +
  +
Inside {{ic|~/.w3m/keymap}} add:
  +
  +
keymap d COMMAND "EXTERN 'echo %s >> ~/.w3m/RestoreTab.txt' ; CLOSE_TAB"
  +
keymap u COMMAND TAB_GOTO file:/cgi-bin/restore_tab.cgi
  +
  +
Then place the following file inside {{ic|~/.w3m/cgi-bin}} and make it [[executable]].
  +
  +
[https://raw.githubusercontent.com/felipesaa/A-vim-like-firefox-like-configuration-for-w3m/master/root-cgi-bin/restore_tab.cgi restore_tab.cgi]
  +
  +
=== Opening magnet links ===
  +
  +
[https://raw.githubusercontent.com/gotbletu/shownotes/master/w3m_plugins/cgi-bin/magnet.cgi magnet.cgi] can be used to make w3m auto open magnet links using [[Transmission]].
  +
  +
=== Fingerprinting ===
  +
  +
==== Using tor ====
  +
  +
You can use {{man|1|torify}} to route w3m traffic through {{Pkg|tor}}.
  +
  +
$ torify w3m -v
  +
  +
==== User agent and headers ====
  +
  +
By default w3m uses its own user agent, meaning w3m users stand out amongst other users.
  +
  +
Fingerprint can be reduced by using a more generic user agent, language and http_accept header.
  +
  +
{{hc|~/.w3m/config|2=
  +
user_agent Mozilla/5.0 (Windows NO 10.0; rev:91.0) Gecko/20100101 Firefox91.0
  +
no_referer 1
  +
cross_origin_referer 0
  +
accept_language en-US,en;q=0.5
  +
accept_encoding gzip, deflate
  +
accept_media text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
  +
}}
  +
  +
==== Disable cookies ====
  +
  +
To disable cookies set {{ic|use_cookie}} to 0 in {{ic|~/.w3m/config}}.
  +
  +
==== Disable cache ====
  +
  +
To disable cookies set {{ic|no_cache}} to 1 in {{ic|~/.w3m/config}}.
  +
  +
== Troubleshooting ==
  +
  +
=== Images flickering/causing lag ===
  +
  +
Unfortunately, sometimes w3m lags when trying to scroll past an image, to the point where the browser can become unresponsive for multiple seconds.
  +
  +
A solution to this is outright disabling images, but this breaks some websites (for example, hacker news relies on GIFs for comment indentation).
  +
  +
A more elegant solution would be to make a keybind to toggle images on or off, to do so add the following line to {{ic|~/.w3m/keymap}}:
  +
  +
keymap i COMMAND "SET_OPTION display_image=toggle ; RESHAPE"
  +
  +
== See also ==
  +
  +
* [https://w3m.sourceforge.net/ Homepage]
  +
* [https://github.com/tats/w3m Github repository]
  +
* [http://www.w3m.rocks/ w3m.rocks]
  +
* [https://github.com/felipesaa/A-vim-like-firefox-like-configuration-for-w3m A vim-like configuration for w3m]
  +
* [https://github.com/gotbletu/shownotes/tree/master/w3m_plugins/cgi-bin w3m plugins]

2023年8月25日 (金) 15:52時点における版

関連記事

w3m is a text-based web browser as well as a pager like more or less. With w3m you can browse web pages through a Terminal emulator window. Moreover, w3m can be used as a text formatting tool which typesets HTML into plain text.

Installation

Install the w3m package.

Usage

See w3m(1).

Configuration

w3m can either be configured using the in-browser settings menu or by directly modifying its configuration files.

Some of the more advanced options are not available using the settings menu, so it is recommended editing the configuration files themselves.

By default all configuration files reside in ~/.w3m.

Tips and tricks

Vim keybinds

Replace ~/.w3m/keymap with a custom configuration.

URL hints

w3m supports qutebrowser-like link navigation, simply navigate to your config file and change the following line from display_link_number 0 to display_link_number 1.

And add keymap f COMMAND "RESHAPE ; LINK_BEGIN ; GOTO_LINK" and keymap F COMMAND "RESHAPE ; LINK_BEGIN ; TAB_LINK" to ~/.w3m/keymap.

ノート: While qutebrowser supports a variety of keys to select hints, in w3m you can only select links using the number keys.

Using kittens image protocol

Users of the kitty terminal emulator may chose to use its own graphics protocol.

To do so simply change the following lines in ~/.w3m/config:

inline_img_protocol 0
imgdisplay w3mimgdisplay

to:

inline_img_protocol 4
imgdisplay kitty

Searching

You can set wrap_search to 1, to allow searches to jump to the top after they have hit the bottom of all matches within a page.

You can set ignorecase_search to 1 to enable case insensitive searching.

ノート: Unlike other browsers and text editors, w3m has no option for smartcase searching.

Custom search engines

You can map keys to launch a CGI script that will capture your input and pass it onto a custom search engine, to do so first create a keybind inside ~/.w3m/keymap to launch your script:

keymap s COMMAND "SET_OPTION dictcommand=file:///cgi-bin/omnibar_google.cgi ; DICT_WORD"

And place omnibar_google.cgi inside your ~/.w3m/cgi-bin directory and giving it execute permission.

While the above script will return a Google result, you can use these kinds of scripts to search StackOverflow, GitHub, DuckDuckGo, Reddit and a bunch of other websites.

You can view similar scripts on GitHub.

Reader mode

Some webpages do not work well with w3m, be it because they use a lot of javascript or CSS to display most of their content. Very often you will have to scroll multiple pages just to get to the start of an article.

This can be mitigated by first passing the webpages through a reader mode program such as rdrview-gitAUR.

To do so add the following to ~/.w3m/keymap:

keymap R COMMAND "READD_SHELL 'rdrview $W3M_URL -H 2> /dev/null 1> /tmp/readable.html' ; LOAD /tmp/readdable.html"

Redirect URLs

~/.w3m/siteconf file is used to set some preferences depending on the website, such as: referrer and user agent.

It can also be used to redirect to lighter (both in terms of layout and bandwidth), more privacy respecting alternatives to websites.

In addition to this it can also be used to run certain CGI scripts.

~/.w3m/siteconf
url m!^https?://([a-z]+\.)?twitter\.com/!
substitute_url "https://nitter.net/"

url m!^https?://([a-z]+\.)?reddit\.com/!
substitute_url "https://safereddit.com/"

#url m!^https?://([a-z]+\.)?google\.com/!
#substitute_url "https://duckduckgo.com/lite/"

url m!^https?://([a-z]+\.)?imgur\.com/!
substitute_url "https://rimgo.pussthecat.org/"

url m!^https?://([a-z]+\.)?wikipedia\.com/!
substitute_url "https://wl.vern.cc/"

url "https://www.youtube.com/" exact
substitute_url "file:/cgi-bin/video.cgi?"
#substitute_url "https://yewtu.be/"

url "https://stackoverflow.com/" exact
substitute_url "https://ao.bloatcat.tk/"

url "https://www.reuters.com/" exact
substitute_url "https://neuters.de/"

url "https://fandom.com/" exact
substitute_url "https://breezewiki.pussthecat.org/"

url "https://medium.com/" exact
substitute_url "https://scribe.rip/"

url "https://web.archive.org/" exact
substitute_url "https://wayback-classic.net/"

Restore closed windows

Default w3m cannot reopen closed tabs, this can be added by binding the close tab button to echo the current URL of the tab to be closed to a text file, and binding another key to restore the latest URL added to the file, using a CGI script.

Inside ~/.w3m/keymap add:

keymap d COMMAND "EXTERN 'echo %s >> ~/.w3m/RestoreTab.txt' ; CLOSE_TAB"
keymap u COMMAND TAB_GOTO file:/cgi-bin/restore_tab.cgi

Then place the following file inside ~/.w3m/cgi-bin and make it executable.

restore_tab.cgi

Opening magnet links

magnet.cgi can be used to make w3m auto open magnet links using Transmission.

Fingerprinting

Using tor

You can use torify(1) to route w3m traffic through tor.

$ torify w3m -v

User agent and headers

By default w3m uses its own user agent, meaning w3m users stand out amongst other users.

Fingerprint can be reduced by using a more generic user agent, language and http_accept header.

~/.w3m/config
user_agent Mozilla/5.0 (Windows NO 10.0; rev:91.0) Gecko/20100101 Firefox91.0
no_referer 1
cross_origin_referer 0
accept_language en-US,en;q=0.5
accept_encoding gzip, deflate
accept_media text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

Disable cookies

To disable cookies set use_cookie to 0 in ~/.w3m/config.

Disable cache

To disable cookies set no_cache to 1 in ~/.w3m/config.

Troubleshooting

Images flickering/causing lag

Unfortunately, sometimes w3m lags when trying to scroll past an image, to the point where the browser can become unresponsive for multiple seconds.

A solution to this is outright disabling images, but this breaks some websites (for example, hacker news relies on GIFs for comment indentation).

A more elegant solution would be to make a keybind to toggle images on or off, to do so add the following line to ~/.w3m/keymap:

keymap i COMMAND "SET_OPTION display_image=toggle ; RESHAPE"

See also