📜 ⬆️ ⬇️

How convenient to read Habr (and not only) on the e-book or on mobile



I love to read Habr (as well as LiveJournal, roem.ru, Rambler news and much more) on my favorite e-book Nook and, occasionally, on my mobile on android. On the reading room, I read, so as not to spoil my eyes, and not to strain myself once more while sitting at a computer, and on a mobile, because of hopelessness, standing in some line.

I made the readitlaterlist.com/unread page (service from the “read later” series) home on my reader, put the application on my phone, and conveniently add topics from Habr (LJ and others) that I want to read on the reader, using a plugin for Firefox
')
It would seem that everything is fine, but the trouble is: the usual version of Habr is loaded in the browser of my Nook for more than a minute, slows down and because of the layout for the usual screens, you need to manually center the column with the text. However, I experienced inconvenience with the majority of full-size pages of various media and blogs.

I tried to migrate to Instapaper , because it supports uploading to epub and mobi (you can even send yourself an email, for example, to autoload on the Kindle), but the problem is also here: all services when hauling text from Habr cut comments (Habr without comment?!?!).

In the end, I came to the conclusion that before sending it to ReadItLater, I manually edited the url of the post on the Habrr to switch to the mobile version of this post (now this is just to add m. , And before that I had to delete /< >/ , set posts , and also add m. ). And on media sites, I looked for links like “print version” or “PDA version”.



In the end, I was tired of doing this monkey job and my patience is exhausted. I decided to write a plugin for firefox. In the process of searching, I came across a plugin for vimperator 's (plug-in for firefox, sharpening it under control from the keyboard, about it on Habré: one , two ): readitlater.js . The plugin contains a mistake in one team and terrible comments in Japanese, but if you arm yourself with a google translat and figure it out, then it does its job.

By that time, I already hooked on vimperator (I strongly advise everyone!) And decided to finish readitlater.js.

The plugin itself adds several commands:
  1. ril a[dd] - add the current page to ReadItLater (or ril a url title add an arbitrary url with an arbitrary title)
  2. ril o[pen] - open the page from the list of unreads in ReadItLater (with search according to TAB)
  3. ril r[ead] url - remove url from the list unread in ReadItLater (with enumeration by TAB)
  4. There is still ril get (pull out the list of ril stats ), ril stats (see statistics)


It turned out that the main language of writing the plugin was Javascript and the plugin code is quite clear. In the end, I worked on the plugin and in addition to the commands I added the ril m[add] command. It works as ril a , but for a number of sites before adding it changes the url to the url of the mobile version or the version for printing.

In addition, I ril get bug in ril get and made it so that ril read without url marks the current page read. In addition, I added README and somehow translated the internal documentation from Japanese.

At the moment, the plugin supports the following sites:

  1. habrahabr.ru
  2. livejournal.com (including topics of the day)
  3. www.trud.ru
  4. lenta.ru
  5. roem.ru
  6. www.guardian.co.uk
  7. news.rambler.ru


And now you can easily add new ones there.

I have been using the plugin for 2 months and will not enjoy it :)

Installation is very simple:
  1. We put vimperator through Firefox Add-ons Manager
  2. Create a daddy ~ / .vimperator / plugin / (or% HOME% \ vimperator \ plugin if you are using Windows) and put the readitlater.js file in it (select the RAW link during the download)
  3. We reload firefox with the command :restart
  4. Enjoy


The results of my work can be seen here: github.com/petRUShka/readitlater.js

If someone wants to add support for their favorite sites, you can do this as follows:
  1. fork my repository
  2. Add a couple of lines to the addItemByArgsWithSubstitution function. Example for habrahabr:
      if(url.match(/:\/\/habrahabr\.ru/)) args["url"] = url.replace("habrahabr.ru", "m.habrahabr.ru").replace(/\.ru\/.+\/(\d+)/, ".ru/post/$1").replace(/#habracut$/, ""); 
  3. Make pull request


If someone is interested in reading articles not online, but offline, you can use the migration script from ReadItLater to Instapaper . For example, you can do this before uploading to epub. By the way, Instapaper does not cut comments in the mobile version of Habr !! So you can safely unload.

In the future, for the sake of this functionality, I plan to add Instapaper support to the plugin. I will take my leave for this.

Source: https://habr.com/ru/post/141391/


All Articles