Adblock Plus(https://addons.mozilla.org/zh-CN/firefox/addon/adblock-plus/) 这款火狐浏览器插件由社区提供了极大的阻止列表文件,但它是客户端软件,并不能在服务器上运行。
Privoxy的代理具有很好的潜力来阻止在服务器端的广告,但它经历更新黑名单的严重短缺。
除了正则表达式的模板匹配的主机名的所有语法功能都支持
隐藏/取消隐藏页面元素(通过CSS)
所有的语法功能都支持
除了过时的所有阻止请求选项:
支持:脚本,图片,样式表,对象,xmlhttprequest,对象子请求,子文档,文档,elemhide,other,popup, third-party, domain=..., match-case, donottrack
不支持: collapse,背景,xbl, ping 和 dtd
采用 Haskell 语言开发。
Privoxy proxy has good potential to block ads at server side, but it experiences acute shortage of updated block lists.
This software converts adblock lists to privoxy config files format.
Almost all adblock features are supported including
If no source URLs are specified, task file is used to determine sources: previously processed sources are processed again if any of them is expired. Nothing is done if all sources in the task file are up to date.
If task file exists and privoxyDir, webDir or domainCSS is not specified, corresponding value is taken from task file.
If webDir is not specified and cannot be taken from task file, privoxyDir value is used for webDir.
If domainCSS is not specified and cannot be taken from task file, Element Hide functionality become disabled. No webserver is needed in this case.
domainCSS can contain just IP address if CSS web server has no associated domain. Use localhost or 127.0.0.1 if you run your browser on the same machine with webserver.
Privoxy的代理具有很好的潜力来阻止在服务器端的广告,但它经历更新黑名单的严重短缺。
Adblock2Privoxy软件可以对Adblock的列表转换为Privoxy的配置文件格式。支持几乎所有的Adblock的功能,包括:
阻止/不阻止 请求(在Privoxy)除了正则表达式的模板匹配的主机名的所有语法功能都支持
隐藏/取消隐藏页面元素(通过CSS)
所有的语法功能都支持
除了过时的所有阻止请求选项:
支持:脚本,图片,样式表,对象,xmlhttprequest,对象子请求,子文档,文档,elemhide,other,popup, third-party, domain=..., match-case, donottrack
不支持: collapse,背景,xbl, ping 和 dtd
采用 Haskell 语言开发。
Check downloads page for binary packages and processed privoxy configs
Version 1.4.2 released!
Adblock2Privoxy
Convert adblock config files to privoxy formatSynopsis
adblock2privoxy [OPTION...] [URL...]
Objectives
AdBlock Plus browser plugin has great block lists provided by big community, but it is client software and cannot work on a server as a proxy.Privoxy proxy has good potential to block ads at server side, but it experiences acute shortage of updated block lists.
This software converts adblock lists to privoxy config files format.
Almost all adblock features are supported including
Tested with privoxy version 3.0.21. Element hiding feature requires a webserver to serve CSS files. See Nginx and Apache config examples provided.
- block/unblock requests (on privoxy)
- all syntax features are supported except for regex templates matching host name
- hide/unhide page elements (via CSS)
- all syntax features are supported
- all block request options except for outdated ones:
- Supported: script, image, stylesheet, object, xmlhttprequest, object-subrequest, subdocument,document, elemhide, other, popup, third-party, domain=..., match-case, donottrack
- Unsupported: collapse, background, xbl, ping and dtd
Description
Adblock files specified by [URL]... are converted to privoxy config files and auxiliarly elemHide CSS files. Local file names and http(s) addresses are accepted as URLs.If no source URLs are specified, task file is used to determine sources: previously processed sources are processed again if any of them is expired. Nothing is done if all sources in the task file are up to date.
Options
If taskFile is not specified explicilty, [privoxyDir]/ab2p.task is used.
- -v, --version
- Show version number
- -p PATH, --privoxyDir=PATH
- Privoxy config output path
- -w PATH, --webDir=PATH
- Css files output path
- -d DOMAIN, --domainCSS=DOMAIN
- Domain of CSS web server (required for Element Hide functionality)
- -t PATH, --taskFile=PATH
- Path to task file containing urls to process and options.
- -f, --forced
- Run even if no sources are expired
If task file exists and privoxyDir, webDir or domainCSS is not specified, corresponding value is taken from task file.
If webDir is not specified and cannot be taken from task file, privoxyDir value is used for webDir.
If domainCSS is not specified and cannot be taken from task file, Element Hide functionality become disabled. No webserver is needed in this case.
domainCSS can contain just IP address if CSS web server has no associated domain. Use localhost or 127.0.0.1 if you run your browser on the same machine with webserver.
Usage
Example of first run:adblock2privoxy -p /etc/privoxy -w /var/www/privoxy -d www.example.com -t my_ab2b.task https://easylist-downloads.adblockplus.org/easylist.txt https://easylist-downloads.adblockplus.org/advblock.txt my_custom.txtExample of subsequent runs:
adblock2privoxy -t my_ab2b.taskThe app generates following files
- privoxyDir:
- ab2p.system.action
- ab2p.action
- ab2p.system.filter
- ab2p.filter
- webDir:
- ab2p.common.css
- ab2p.css
- [lot of directories for all levels of domain names]
- taskFile:
- special file containing execution details. It can be reused to update privoxy config from same sources with same options. Its name is ab2p.task by default.
How to apply results
- Install privoxy. Optionally setup it as transparent proxy. See privoxy installation manual for details.
- Change privoxy config file located in
- /etc/privoxy/config for linux
- C:\Program Files\Privoxy\config.txt for windows
actionsfile ab2p.system.action actionsfile ab2p.action filterfile ab2p.system.filter filterfile ab2p.filter
- In order to make Element hiding work you also need a webserver to serve CSS files. You can choose nginx, apache or any other webserver. See nginx installation manual, apache on linux installation manual or apache on windows intallation manual for details.
- Change webserver config. In examples below
- replace www.example.com with your domain or IP address (equal to --domainCSS adblock2privoxy parameter)
- replace /var/www/privoxy with your CSS files location (equal to --webDir adblock2privoxy parameter)
- remember, these examples are simplified to use by unexperienced people. If you're familiar with webservers administration, you'll find better ways to apply these configs.
- for linus /etc/nginx/nginx.conf
- for windows [nginx location]\conf\nginx.conf
server { listen 80; #ab2p css domain name (optional, should be equal to --domainCSS parameter) server_name www.example.com; #root = --webDir parameter value root /var/www/privoxy; location ~ ^/[^/.]+\..+/ab2p.css$ { # first reverse domain names order rewrite ^/([^/]*?)\.([^/.]+)(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?/ab2p.css$ /$9/$8/$7/$6/$5/$4/$3/$2/$1/ab2p.css last; } location ~ (^.*/+)[^/]+/+ab2p.css { # then try to get CSS for current domain # if it is unavailable - get CSS for parent domain try_files $uri $1ab2p.css; } }
- for linux: /etc/apache2/sites-available/000-default.conf (replace existing content)
- for windows: C:\Program Files\Apache Group\Apache2\conf\httpd.conf (append to the end)
<VirtualHost *:80> #ab2p css domain name (optional, should be equal to --domainCSS parameter) ServerName www.example.com #root = --webDir parameter value DocumentRoot /var/www/privoxy RewriteEngine on # first reverse domain names order RewriteRule ^/([^/]*?)\.([^/.]+)(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?/ab2p.css$ /$9/$8/$7/$6/$5/$4/$3/$2/$1/ab2p.css [N] # then try to get CSS for current domain # if it is unavailable - get CSS for parent domain RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f RewriteRule (^.*/+)[^/]+/+ab2p.css$ $1ab2p.css [N] </VirtualHost>
- Get adblock2privoxy output
- Either run adblock2privoxy providing privoxy dir, web dir, domain and adblock input file urls such as
- EasyList
- Russian AD list
- and many others from official adblock repository
- Or just download processed lists from downloads page and unpack privoxy to and web directories content into
- /var/www/privoxy and /var/www/privoxy for linux
- C:\Program Files\Privoxy and [your webserver directory] for windows
- Either run adblock2privoxy providing privoxy dir, web dir, domain and adblock input file urls such as
- Restart privoxy and webserver to load updated configs
Contribution
- Clone repository from http://projects.zubr.me/adblock2privoxy.git.
- Report bugs
Adblock2Privoxy installation
From binary package
There are packages for various systems available at downloads page
- For linux: you can try RPM or DEB package (depending on your package manager).
- For windows: Just unzip the file provided. You'll find adblock2privoxy executable is in bin folder.
From sources
You can build and run adblock2privoxy from sources if there is no binary package for your system.- Ensure you have Haskell Stack environment
- Install Stack for your platform
- Build the app:
stack unpack adblock2privoxy cd adblock2privoxy-* stack setup stack build
- Run the app:
stack exec adblock2privoxy -- [YOUR ARGS] #for example: stack exec adblock2privoxy -- -p /etc/privoxy -d example.com https://easylist-downloads.adblockplus.org/easylist.txt
Packaging
You can create your own binary package for adblock2privoxy.- Use scripts from distribution folder for your platform.
Here you can
- browse source code
- report a bug
- download for binary packages and processed privoxy configs。
from http://projects.zubr.me/wiki/adblock2privoxy