Vimium: Add command to activate Firefox reading mode

Created on 21 Aug 2017  ·  9Comments  ·  Source: philc/vimium

I'd like to go into the reading mode in Firefox, which reformats the page to potentially make it scroll smoother and make it easier to read. In VimFX this was gr, but of course it does not have to have the same mapping by default. Actually, I don't even necessarily think it would need to be mapped at all by default. It would be fine just having it available to be mapped.

Most helpful comment

As fun as it is to be pessimistic, you can follow the breadcrumbs from the catch-all reader mode WebExtensions bug:

  • It isn't a privileged URL and so tabs.create should be able to open it. Judging from its bug, it's awaiting this security review request completing.

    • The reader URL format is "about:reader?url="+encodeURIComponent(url), so it would be trivial to add to Vimium with this.

    • There are concerns that the url parameter might not be correctly sanitised at the moment, which is holding this up.

  • Content scripts should also be able to run on non-piviledged URLs, so there's promise in the bug for that too.

    • Again, this is blocked on security review (to check that content scripts on about:reader don't damage the sandbox).

  • An API for checking whether reader mode supports a page or not has got baseline approval.
  • An API for whether tabs are in reader mode or not has been proposed.

    • This hasn't progressed any further, since at present checking for about:reader at the start of the tab's URL should do the trick.

Edit: The first bullet is all we need to be able to implement a command for entering/leaving reader mode.

All 9 comments

I would be surprised if it is possible (or ever will be) for a WebExtension.

Because it's Firefox specific?

Nah, because it's such a specific thing to add an API for.

As fun as it is to be pessimistic, you can follow the breadcrumbs from the catch-all reader mode WebExtensions bug:

  • It isn't a privileged URL and so tabs.create should be able to open it. Judging from its bug, it's awaiting this security review request completing.

    • The reader URL format is "about:reader?url="+encodeURIComponent(url), so it would be trivial to add to Vimium with this.

    • There are concerns that the url parameter might not be correctly sanitised at the moment, which is holding this up.

  • Content scripts should also be able to run on non-piviledged URLs, so there's promise in the bug for that too.

    • Again, this is blocked on security review (to check that content scripts on about:reader don't damage the sandbox).

  • An API for checking whether reader mode supports a page or not has got baseline approval.
  • An API for whether tabs are in reader mode or not has been proposed.

    • This hasn't progressed any further, since at present checking for about:reader at the start of the tab's URL should do the trick.

Edit: The first bullet is all we need to be able to implement a command for entering/leaving reader mode.

Yay! Sorry for the negativity.

Regarding @mrmr1993's edit, I think you need the first two bullets to be able to leave reader mode. Right now, it seems that WebExtensions can't be loaded into about: URL's, so the keybinding to leave reader mode wouldn't work.

I use reader mode a lot. I don't mind using the default keybinding of Ctrl-Alt-r to activate it, but it is annoying that I can't use other keybindings in reader mode, especially j, k, and other scrolling related keys. Do we need a separate issue for loading Vimium inside of reader mode or does that fit here? Or will it just work without changes to Vimium if bug 1371786 is resolved?

I think you need the first two bullets to be able to leave reader mode.

You're right. Good catch.

Do we need a separate issue for loading Vimium inside of reader mode

No: the issue tracker here is chaos, and essentially functions as a mailing list. Issues only get fixed if someone decides to fix them (and then Steve cares about the issue enough to merge the fix), and this isn't really coordinated in any meaningful way.

I use reader mode a lot, so I intend to fix this -- at least for myself -- when it becomes possible.

will it just work without changes to Vimium if bug 1371786 is resolved?

Either without changes or with a one-line change to the extension manifest, depending on the implementation.

The API for this is live in nightly. See this bug (or commit mozilla/gecko-dev@8f848ff9dfe8e5b11966cbe6177019deb1f75a3c) for details. I can't find any official documentation, and only ran into it while doing some unrelated work on the Firefox codebase.

Briefly, the changes are:

  • isArticle added to the Tab object, which corresponds to the reader view button being shown in the address bar (I think)
  • isInReaderMode also added to the Tab object
  • browser.tabs.toggleReaderMode(tabId) API added

We still can't run content scripts in reader mode (this bug), so once we're in, we're stuck.

Here's the documentation for browser.tabs.toggleReaderMode. It's in Firefox 58. Not much progress on allowing content scripts in reader mode so far.

Was this page helpful?
0 / 5 - 0 ratings