I'm very bad at learning by example (especially if the example is undocumented code) so looking at the source for someone's addon is not really an option.
Since I'm already filtering web content with Privoxy, I was thinking I could simply use the external filters feature:
But again, I have no idea how to start.8.5.14. external-filter
Typical use:
Modify content using a programming language of your choice.
Effect:
All instances of text-based type, most notably HTML and JavaScript, to which this action applies, can be filtered on-the-fly through the specified external filter. By default plain text documents are exempted from filtering, because web servers often use the text/plain MIME type for all files whose type they don't know.)