Wandering Thoughts archives


Using personal ruleset recipes in uMatrix in Firefox

I generally don't run Javascript on websites, and these days I do this with uMatrix. uMatrix requires more fiddling than controlling Javascript with uBlock Origin, but I like its fine grained control of various things (including cookies) and how it can improve my web experience. One of the ways I've started doing that is by exploiting uMatrix's ability to let you define personal ruleset recipes.

Suppose, not hypothetically, that you periodically read technical articles on Medium. These articles frequently use images and often inline snippets of code from Github gists and the like, and unfortunately both of these only render if you turn on enough Javascript (and not just Medium's Javascript). Also unfortunately, Medium's own Javascript does enough annoying things that I don't want to leave it on all of the time; I only want to turn it on when I really need it for an article. I can certainly do this by hand, but it involves an annoying amount of clicking on things and refreshing the page.

But it turns out that we can do better. uMatrix has a thing called ruleset recipes, which are, to quote it:

Ruleset recipes ("recipes" thereafter) are community-contributed rulesets suggested to you when you visit a given web site. Recipes are specific, they contain only the necessary rules to un-break a specific web site or behavior.

There is no community contributed recipe for Medium that I know of, but we can write our own and hook it into uMatrix, provided that we have a website somewhere. Once added to uMatrix, we can enable it temporarily with a couple of clicks and then dump all of its temporary additions later.

First we need to create a text file with the rulesets we want and the necessary rules in them. For my Medium rules, what we need looks like this:

$ cat recipes_cks_en.txt
! uMatrix: Ruleset recipes 1.0
! Title: Chris's additional rulesets for English websites
! Maintainer: Chris Siebenmann

Medium no account
   medium.com *
      _ 1st-party script
      _ gist.github.com script

Next we need to put this on a website somewhere. Generally this should be a HTTPS website that you trust, for safety. Having done this we next need to add our recipes URL to uMatrix. This is done by going to the uMatrix dashboard, going to the Assets tab, and then down at the bottom of the 'Ruleset recipes' section you will see an 'Import...' option. Enable it, enter the URL of your recipes, and click 'Apply changes'. There, you're done; your new recipes are now available through uMatrix's regular interface for them, described in the ruleset recipes wiki page.

(You can also see the built in recipes in the Assets tab, or look at them on Github. This will give you an idea of what you can do in your own recipes.)

PS: I haven't tried to contribute my Medium recipe because I have no idea if it's complete or truly good enough. It works for me for the things that I care about, more or less, but I don't care very much about having all of Medium's various peculiarities working correctly (or correctly being blocked).

web/UMatrixPersonalRulesets written at 23:11:11; Add Comment

Page tools: See As Normal.
Login: Password:
Atom Syndication: Recent Pages, Recent Comments.

This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.