Writing my first addon for Firefox wasn't too hard or annoying
(The pre-WebExtensions NoScript does a lot of magic, which has good and bad aspects. uMatrix is a lot more focused and regular.)
To cut a long story short, today I wrote a Firefox WebExtensions-based addon to fix this, which I have imaginatively called gsearch-urlfix. It's a pretty straightforward fix because Google embeds the original URL in their transformed URL as a query parameter, so you just pull it out and rewrite the link to it. Sane people would probably do this as a GreaseMonkey user script, but for various reasons I decided it was simpler and more interesting to write an addon.
The whole process was reasonably easy. Mozilla has very good
that will walk you through most of the mechanics of an addon, and
it's easy enough to test-load your addon into a suitable Firefox
up to me, which made me a bit worried about needing to play around
with regular expressions and string manipulation and parsing URLs,
and objects that do all of the hard work; all I had to do was glue
them together correctly. I had to do a little bit of debugging
because of things that I got wrong, but
console.log() worked fine
to give me my old standby of print based debugging.
There are a couple of things about your addon
the MDN site won't tell you directly. The first is that if you want
to make your addon into an unsigned XPI and load it permanently
into your developer or nightly Firefox, it must have an
(see the example here
and the discussion here).
The second is that the
matches globs for what websites your content
scripts are loaded into cannot be used to match something like 'any
.google. in it'; they're very limited.
I assume that this restriction is there because
matches feeds into the
permissions dialog for your addon.
(It's possible to have Firefox further filter what sites your content
scripts will load into, see here,
but the design of the whole system insures that your content scripts can
only be loaded into fewer websites than the user approved permissions for,
not more. If you need to do fancy matching, or even just
you'll probably have to ask for permission for all websites.)
This limitation is part of the reason why gsearch-urlfix currently only acts on www.google.com and www.google.ca; those are the two that I need and going further is just annoying enough that I haven't bothered (partly because I want to actually limit it to Google's sites, not have it trigger on anyone who happens to have 'google' as part of their website name). Pull requests are welcome to improve this.
I initially wasn't planning to submitting this to AMO to be officially signed so it can be installed in normal Firefox versions; among other things, doing so feels scary and probably calls for a bunch of cleanup work and polish. I may change my mind about that, if only so I can load it into standard OS-supplied versions of Firefox that I wind up using. Also, I confess that it would be nice to not have my own Firefox nag at me about the addon being unsigned, and the documentation makes the process sound not too annoying.
(This is not an addon that I imagine there's much of an audience for, but perhaps I'm wrong.)
Comments on this page:Written on 12 February 2018.