Sunday, February 7, 2016

First Firefox Addon - "Toggle Autoplay"

This evening, I spent some time hacking together an addon for Firefox (and the first one I've built). Over the past week or so, I'd gotten increasingly annoyed by how certain video players (notably Vimeo's) were having some random playback issues when I've got autoplay disabled globally across the whole browser. The workaround for those cases is to turn autoplay back on while dealing with that page, and then disable again once done (so that the next page doesn't get any wrong ideas about causing a ruckus).

However, that's a PITA right now, as you have to open a new page, navigate to the user preferences page, navigate to the property, and only then can you change its setting. With no obvious way to just "pin" a setting to the toolbar, I was only left with the option of hacking together a simple addon to do so instead!

Impressions of the Process and Tools
My first impressions with the dev infrastructure for creating these addons is that they've got a pretty nice system for getting you up and running. The basic parts of getting the thing up and running were quite straightforward, and were initially just a matter of copy and pasting snippets from the tutorials, and adapting them slightly.

Equally interesting was the way you test the addons - the tool basically spawns a secondary instance to let you do your thing. The only not-so-great thing is that the warnings/errors given do not always make it easy to figure out why exactly it's gone and barfed on your code.

While I'm not a big fan of JS, the JS on show here is fortunately still relatively tame and manageable for someone not too familiar with that stuff. Of course, once you start dealing with a larger and more complex codebase, things may be a bit different then.

Documentation + Keeping Properties in Sync
The documentation was good for helping you get started (i.e. as a tutorial it's nice), but as a reference source, it often wasn't clear whether that certain properties could be applied in certain ways.  "ToggleButton.checked" in particular is non-obvious.

However, other than a few other minor issues, the documentation was clearly good enough to have helped me get the job done. So, it can't have been too bad :)

Addon Signing Crap - A Rant
Everything is fine and all until you come to the point of trying to run the install the bloody thing on your own machine, under your own account, for everyday use/proper road testing once you're satisfied that it looks like it'll serve your basic needs for a while.


/me unleashes the pitchforks and flame torches

What do you mean it's unverified/unsigned?!  I already clicked through all those screens saying that I understand the risks of installing such things, and have followed the bloody instructions and ran "jpm sign" on it, with auto-generated keys produced by your servers. And it's not like I'm running/installing this addon on a separate machine either... this is the very same machine that I used to develop and package and sign the addon with just moments ago. Yet, it's "Computer Says No".


Two guiding principles:
1) If thy user wants to change how his machine works, the machine must let him do so... even if he breaks everything in the process, so be it!  (So long as it doesn't directly kill or maim anyone immediately, there's nothing wrong)

2) If it's man made, it is malleable. Man made = someone drew a line in the sand one day, and said, "I like it this way. Do it my way".


To save anybody else the trouble, just change the following setting if you find yourself in this situation...

xpinstall.signatures.required = false

No comments:

Post a Comment