Hypothesis web annotation in Firefox: cellphone and PC

Update June 8th, 2020: As of today, an unofficial extension is available for Firefox desktop!

Hypothesis is a great web annotation tool that lets you annotate any webpage, and share your annotations publicly, within private groups, or keep them for your own.

Although webpage owners can add the necessary code to enable annotations for anyone visiting their webpages, you can annotate any webpage by simply injecting the necessary code: the Hypothesis client. To do so, the easiest way is to use a browser extension, which is currently only available for Google Chrome.

If you use other browser (e.g. Firefox, Safari) or use Chrome in your cellphone (which doesn’t accept extensions), you can still use the bookmarklet, something like a link which you can bookmark and click on any webpage to inject the necessary code to make annotations.

I tried the bookmarklet in Firefox (both PC and mobile), but it presents two major drawbacks:

  1. Launching the bookmarklet is not as straightforward as clicking an extension button. It is true that a shortcut can be added to the bookmark toolbar, but I prefer to hide this toolbar to allow more space for browsing. In addition, this toolbar is not available (and it would take too much space if it were) for mobile.

In this guide I will explain what I think is the best way to use Hypothesis in an Android cellphone (although I guess it may work in iOS too), using Firefox. The cool thing is these instructions will work for both PC and mobile versions of the browser.

It is worth noting that another option to use Hypothesis in a cellphone is by installing Yandex, a browser based based on Chrome (Chromium, to be accurate), available both for Android and iOS. As opposed to mobile versions of Google Chrome, this browser does work with Chrome extensions, including Hypothesis’. However, I haven’t played much with the browser myself, so that’s all I can say about it. Update June 3rd, 2020: Chris Aldrich published another interesting option here, using the Url Forwarder app and the Via proxy.

1. How to easily activate Hypothesis on all webpages?

After installing Firefox, a way to easily activate Hypothesis on all webpages, without having to find and launch the bookmarklet, is using a userscript manager, such as Greasemonkey. Update January 29th, 2021: As mentioned by Kostis in the comments below, a simpler way is to just install Hernawan Faïz Abdillah’s bookmarklet extension. To do this in the new Firefox for Android, you have to use Firefox Nightly and follow the instructions here.

Greasemonkey is a Firefox addon that lets you run custom JavaScript code on the pages you visit. To install it, go here and click on “Add to Firefox”.

Once installed, you can install a script I wrote based on the Hypothesis’ bookmarklet. To get it, go here and click “Install” on the window that will pop up. Feel free to check the code and suggest changes if you wish!

All set: the Hypothesis client should now be enabled on all webpages you visit. If you want to disable it for any particular site, just add it to the “User excludes” in the Greasemonkey menu (Update January 13th, 2020: Facebook seems to slow down with the script; you may want to add https://www.facebook.com/* to the exclude list to avoid this).

Update April 30th, 2020: tim improved the script a bit, including some useful exceptions, and published it for Greasy Fork and Greasemonkey here.

2. How to make Hypothesis work in sites with CSP enabled?

As mentioned above, when launched from the bookmarklet the Hypothesis client isn’t working on webpages with Content Security Policy (CSP) enabled, such as GitHub and Internet Archive’s Wayback Machine. Update July 23rd, 2019: Apparently this will be fixed in Firefox 69.

One possible workaround is to disable CSP in your browser altogether, but that would be insecure.

Alternatively, you can use a browser addon to include Hypothesis as a trusted source in the CSP header of the webserver response.

To do this automatically for all webpages, I am using the Header Editor addon, which is the only Firefox addon I found which let me run a custom function on the response headers. You can get it here.

Once installed, you can write your own rule, or use the one I wrote:

  1. Open the Header Editor menu.

Once saved, you can look the “Hypothesis” rule up in the “Rules List” section, and click “Edit” to check the code:

That’s all. I hope you find this guide useful. Feel free to add comments at the end, or using Hypothesis!

Update July 1st, 2019
Bare in mind that unfortunately, due to a change in Firefox 60 and newer, Greasemonkey user scripts are not running on the browser’s pdf.js viewer. As a result, the Hypothesis client doesn’t load automatically on PDFs, and it has to be loaded through the bookmarklet instead. See here and here for further information.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store