Hacker News new | past | comments | ask | show | jobs | submit login

Can any Firefox experts help me out with a bookmarklet, please?

A HN comment a while ago reported that you can switch to the 'reader mode' view of a website by prefixing the URL with 'about:reader?url=' - this can be useful for some pages where FF doesn't put the 'reader mode' button in the URL bar.

This seemed like an ideal use for a bookmarklet, so I created one as follows:

   javascript:(function(){
       window.location = "about:reader?url=" + window.location;
   })()
But, this doesn't work. In the console I get the error:

TypeError: Location.href setter: Access to 'about:reader?url=https://www.example.com/' from script denied.

Is there any way to work around this, or do bookmarklets simply not have the permissions to alter the URL like this?




It works with some other address than about:reader, so I think there’s something special with about: addresses.

Also, you don’t have to wrap it in a function; you can just do

javascript:location.href='foo:/bar/'+document.location.href;


https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/The...

at the bottom

Note: You must access about: protocol pages by typing them into the address bar. Attempts to navigate through window.location will throw — Error: Access to 'about:addons' from script denied.


GP, You could put the link into a window.prompot() for easy copy/paste into the address bar


Well, I guess you could probably use document.execCommand to do it, unless that is blocked for JavaScript uri scheme access, or ask for async clipboard access (I wonder what happens if you ask for it from JavaScript uri, should take time to investigate some day)


I can't answer your question, but I can offer a nice alternative in the form of extension, aptly named "Open in Reader View", works a treat!

https://addons.mozilla.org/es/firefox/addon/reader-view/

https://add0n.com/reader-view.html


That's great, thanks!


Also if I put a link into the page with the about:reader uri scheme, it does not work (opens blank page if I open new tab, does not go anywhere if I click on it without opening new tab)

I suppose it might work if I put it into an extension of some sort, if not then I think to make it work on Windows it would be easiest to have an AutoHotkey script that prepended about:reader?url= on the address line and pressed enter for you.

I have as yet to find a worthwhile AutoHotkey competitor on Linux or MacOs.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: