David Kalnischkieshttps://david.kalnischkies.de/blog/tags/firefoxstaticsite2016-03-16T11:27:39Zapt-get a life: posts tagged firefoxdotPageMod: a firefox extensionhttps://david.kalnischkies.de/blog/2016/dotPageMod2016-03-16T11:27:39Z2016-03-16T11:27:39Z
<p>A long while ago I was using <a href="http://www.greasespot.net/">Greasemonkey</a>, but
just hiding a few elements with it felt very daunting with all this metadata
and editing in a browser window. I <em>regressed</em> to using <a href="https://adblockplus.org/">Adblock
Plus</a> and later <a href="https://github.com/gorhill/uBlock">uBlock
Origin</a> for cosmetic filtering and more and
more to block the execution of JavaScript by default. Eventually I introduced
<a href="https://github.com/gorhill/uMatrix">uMatrix</a> with a rigid block-policy to the
mix which ended up leaving uBlock mostly jobless beside a bunch of cosmetic
filters. Management of these isn't perfect through and sometimes you want more
than just <code>display: none</code> – especially now that I had all of JavaScript blocked
by default and some websites downright refuse to be usable without it (e.g.
default collapsed infoboxes). So I moved my filters to <code>~/.css</code> and started
fixing up websites in <code>~/.js</code> with <a href="https://github.com/rlr/dotjs-addon">dotjs</a>.
Quickly I ended up hitting issue <a href="https://github.com/rlr/dotjs-addon/issues/27">#27: console.log doesn't work from
dotjs</a> which I researched and
after commenting researched even more. Set out to write a patch to have this
option set automatically I ended up changing other things as well until I
realized that the architecture as-is wasn't to my liking (using a single global
PageMod reading files dynamically and sending the content to be processed by
eval (JS) and by DOM insertion (CSS) – the later failing in the event of a
content policy forbidding inline CSS) – and I always wanted to look into
developing Firefox extensions…</p>
<p>So, with a "how hard can it be?" I moved on to write my own extension to resolve
my real as well as my imaginary problems by introducing new problems – not for
me (hopefully), but potentially for anyone (else) wanting to use it…</p>
<p>The result is <a href="https://github.com/DonKult/dotPageMod">dotPageMod</a> which
exports the strength of the SDKs
<a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/SDK/High-Level_APIs/page-mod">PageMods</a>
to be configured easily at runtime.</p>
<p>This isn't a WebExtension and I have my doubts that it ever will be
possible to do it as a WebExtension as it contradicts the requirement of
extension signing & review somewhat, but I will worry about that at
a later time. It is at least only using low- and high-level SDK
functions and most could be done in terms of a WebExtension, you would
"just" loose all of the easy configuration part – which is the whole
point of the exercise…</p>
<p><small><a rel="canonical" href="https://david.kalnischkies.de/blog/2016/dotPageMod">This article</a> was written by David Kalnischkies on <a href="https://david.kalnischkies.de">apt-get a life</a> and republished here by pulling it from a syndication feed. You should check there for updates and more articles about firefox.</small></p>