Building eLinks Text-based Web Browser with (Some Sort of) JavaScript Support

Orange Pi Development Boards

Yesterday, I’ve spend some time trying to find a text-based web browser with support for JavaScript. Although I doubt many people would need that, I’ll post my findings, and show how to build and enable Javascript in eLinks web browser to access the web from a terminal in Linux (Ubuntu/Debian). Bear in mind that the implementation is far from complete, and most pages won’t work, at least for now.

Initial research pointed me to three potential candidates: links2, w3m + w3m-js extension, and elinks. Links2 used to have JavaScript, but support was poor, so they decided to remove it. w3m-js is an experimental patch to add JavaScript to w3m, but the link is broken, so we are left with elinks.

If you just want a text based web-browser, and do not care about JavaScript, you can just install links2, w3m, or elinks with apt-get. The versions I’ve tried in Ubuntu 12.04 LTS, and 13.10 do not support JavaScript.


So I’ve had to build elinks development code. Elinks uses Mozilla SpiderMonkey JavaScript engine, so the first step is to install the development library, as well as pkg-config if it is not already installed on your system:


Now let’s download a tarball of the experimental code snapshot (Mine was on 20140208), extract the code and configure the build:


Now scroll up a bit, and make sure SpiderMonkey has been enabled in configure log:


In case it has not been enabled, check config.log to miss which library or package is missing.

Time to build and install elinks:


By default, JavaScript is not enabled. We’ll need to start elinks, press “Esc” twice to access to the top menu, and go to Setup->Options Manager. Expand ECMAScript menu, select Enable, and Edit to set the value to 1.

elinks_JavaScriptSelect Save to update the settings, and create a configuration file in ~/.elinks/elinks.conf. If you want to understand why some JavaScript does not work, you may want to enable Script error reporting which will pop a window for each JavaScript error.

I’ve tried it by running elinks http://javatester.org/javascript.html, but the page just says JavaScript is not supported. Other pages with JavaScript will have errors due to missing features, so it may only be usable in few cases.

If you want elinks to be the default text-based browser (www-browser), you may have to remove elinks package (apt-get remove elinks), and add it back to alternatives:


Now make sure it selected by default:

You can also set the default Desktop browser (Chromium, Firefox..) using the command line by replacing www-browser, by x-www-browser.

Support CNX Software - Donate via PayPal or become a Patron on Patreon

10
Leave a Reply

avatar
10 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
8 Comment authors
Liviu Balaniw2evkTobias BroxDrakonasLeandro Knorre Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
trackback

[…] It will provide a link to access in your browser, to get a verification code that you can enter in the terminal. This is only requires for the first time, after you can just upload the videos without user intervention for authentication. If you run the command without noauth_local_webserver, and if you only have access to a text based web browser this won’t work, as they don’t usually support JavaScript. […]

onebir
Guest
onebir

Being nosey, why did you want a text-based web browser with support for JavaScript?

onebir
Guest
onebir

Oh! Well now anyone who needs one has a nice tutorial 🙂

Haris Sarwar
Guest
Haris Sarwar

Have u used phantomjs? It is based on webkit and supports javascript. You can do all page processing in javascript.

Leandro Knorre
Guest
Leandro Knorre

Tks!! Finally I was able to install elinks w/ javascript – I’ve been trying to do so for more than 24 hours. Too bad it doesn’t fetch the webpages I need to harvest the data from, let’s move on to phantomjs to see if it solves my problem… But the tutorial is perfect!

Drakonas
Guest
Drakonas

At first I figured all that needs changing is changing the User Agent string, because ELinks defaults to its own text-based user agent. Any website would normally notice that it’s text-based and automatically assume it doesn’t support JS, I’d expect. I’ve tried Mozilla and Firefox with different options, but I seem to get crashes when clicking on JS links (or sometimes just loading a page with JS code).

Considering that Mozilla’s Spidermonkey 1.8.5 (Ubuntu 12.04’s latest is libmozjs185-dev, which is 1.8.5) is heavily outdated, as in Firefox 4.0! I’d recommend installing Spidermonkey from source. I am attempting this myself. I will report back on my findings.. All specific instructions to ELinks can be found here:
http://elinks.cz/documentation/manual.html#ecmascript
While inscructions from Mozilla directly can be found here:
https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Build_Documentation
(We want non-developer build, because we are not contributing to SpiderMonkey)

Tobias Brox
Guest
Tobias Brox

I know at least one blind guy that would be very happy to use a text-based browser that supports javascript.

iw2evk
Guest
iw2evk

HI, someone can help me to embed the spidermonkey engine into links2.9 browser?

http://links.twibright.com/download/links-2.9.tar.gz

i’m beginner in gcc ..

Thanks

Roberto

Milan (italy)

Liviu Balan
Guest

Nice! If you want to learn more about how to install ELinks on Ubuntu Server you can checkout http://www.liviubalan.com/install-elinks-on-ubuntu-server