eww lately for browsing the web looking for documentation and things like that. I dislike that
eww receives the same web page as it were Firefox or Google Chrome, it cannot render web pages as those web browsers do. Then, what I want to achieve is to make
eww tell the web sites that it visits that send the mobile friendly version of their web pages, thus, I would have a simpler layout rendered by
eww (or at least that's my assumption).
eww uses the
url library, so we can add advice to
url-http-user-agent-string to fake the
(advice-add 'url-http-user-agent-string :around (lambda (ignored) "Pretend to be a mobile browser." (concat "User-Agent: " "Mozilla/5.0 (Linux; U; Android 4.0.3; ko-kr; LG-L160L Build/IML74K) AppleWebkit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30")))
I took a mobile browser User-Agent string from
With this advice I get the mobile version of
google.com; your mileage may vary.
(I found this by using
M-x apropos RET user-agent RET.)
In recent versions of Emacs, you can simply use the customization variable
(setq url-user-agent "User-Agent: Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7\n")