[Privoxy-users] Privoxy-users Digest, Vol 56, Issue 8

Peter G. privoxy at nephros.org
Tue Dec 28 12:43:54 UTC 2021


Hello,

Fabian Keil wrote:
> Jason Parson wrote:
>> I would also, like to find out if it is possible to filter content the same
>> way  uBlock does. Here is an example of my filters. I hope you understand
>> it. I want to be able to filter third-party sites, inline-scripts,
>> inline-fonts etc.  and other parameters
>>
>> ||amazonaws*^$important,all
>>
>> ||google*^$important,all
>>
>> ||googletagmanager^$important,all

[...]SNIP[...]

>
> I'm not familiar with this syntax but maybe others on this list are.

That is the de-facto standard format most of the current browser 
extensions use for both content blocking, and importantly, element hiding.

There is a reference for the format here:
https://adblockplus.org/filter-cheatsheet

The first one (blocking) is relatively easy to translate to privoxy, 
it's basically something like

{+block{adblock rule}}
amazonaws*
google*
googletagmanager*

Element hiding as done by extensions is more involved, as it is done 
*after* the page has been loaded (and can thus also react on some 
methods of loading content which Privoxy can not).

This is harder to emulate in Privoxy, though some of it can be 
translated to regexp filters changing e.g. CSS.

There are several tools out there which try to convert these adblock 
format lists to Privoxy action/filter format - Most of them are "not 
perfect".

The most reliable and most involved is AdBlock2Privoxy, which has been 
mentioned on this list a couple of weeks earlier.

https://github.com/essandess/adblock2privoxy

Not only can it translate these lists, it can also produce custom CSS 
snippets which implement the element hiding, and uses Privoxy Redirects 
to point to those snippets.

The downside to translating AdBlock lists to Privoxy files automatically 
is that there is tons of redundancy in the resulting files, because each 
rule in an Adblock list will be a separate rule in an .action file, so 
you get something like

     {+block{rule-1}}
     google*
     {+block{rule-2}}
     googletagmanager*
     {+block{rule-3}}
     googleads*
     {+block{rule-4}}
     amazon*
     {+block{rule-5}}
     amazonaws*

which could really be only one or two rules.

As the original lists are not short to begin with, this may lead to 
performance issues.

The big advantage of these lists is however, that they are plentyful and 
actively maintained, updated as sites change or break.

It would IMO be a *huge* benefit for Privoxy if it could support (at 
least some of) the format strings of the AdBlock format natively.

Something for the wishlist, maybe, Kyle?

Another source for autogenerated rules files is

https://pgl.yoyo.org/adservers/formats.php

which can generate a Privoxy format file by selecting the "junkbuster" 
(blast form the past!) format.
This is a web service which is cool as you can auto-update your action 
files regularly by requesting something like

curl -o yoyo.action -L "https://pgl.yoyo.org/as/serverlist.php?hostformat=junkbuster&showintro=0&startdate%5Byear%5D=2016&mimetype=plaintext"

Hope this helps, BR
   Peter G.

-- 
"I do not think the way you think I think."
     -- Kai, last of the Brunnen G


More information about the Privoxy-users mailing list