Akhier Dragonheart Akhier Dragonheart - 4 months ago 20
Android Question

Bookmarklet to activate reader mode in Firefox on Android

Recently a change happened with Firefox on Android which stopped me from using the work around of adding something to my reading list and opening it from there to force a page into reader mode. With that in mind I tried to find and then finally make a bookmarklet to force a page into reader mode for me.

So far I have found that by adding 'about:reader?url=' to the beginning of a url will try to open any page into reader mode. From there not knowing much about javascript I tried to cludge together something using other examples I found on the web. To start I just figured out how to add to the url and was able to get that working

javascript: window.location = window.location + 'about:reader?url=';


The above will add onto the end just fine but when I move it to the beginning it no longer works so when I try

javascript: window.location = 'about:reader?url=' + window.location;


Nothing happens at all even on a page that will just allow reader mode. When I replace the stuff I am adding with just 'test' though it will happily cause the page to go to 'testhttp://www.google.com/' or wherever else. I have tried it on not only my android phone but also my desktop. What am I doing wrong as from what I can see this should work?

DG. DG.
Answer

Almost certainly Firefox considers it to be a security risk to allow Javascript to change a page to any location beginning with about:.

Using the Javascript console in Firefox in Windows to run this code:

window.location = 'about:reader?url=' + window.location;

returns error:

Access to 'about:reader?url=...' from script denied

Here is a "work around" that might ease your particular pain:

javascript:(function(){prompt('Copy the below text and then paste it into the URL bar:', 'about:reader?url='+encodeURIComponent(document.location))})();

It will prompt you with a url you can copy and then paste into the URL bar.