fix
[deb/hackedgotchi.git] / filters / remove-trackers-and-ads.plugin
1 import sys
2 import re
3
4 data = sys.stdin.read()
5
6 regexes = [
7         # Blogger tracking images
8         r"""<img [^>]*?src=["']https?://blogger\.googleusercontent\.com/tracker/[^'"]*['"][^>]*>""",
9         # Feedburner ads
10         r"""<p><a href=['"]https?://[a-zA-Z0-9\-\.]*/~a/[a-zA-Z0-9]*\?a=[a-zA-Z0-9]*['"]><img border=['"]0['"] src=['"]https?://[a-zA-Z0-9\.\-]*/~a/[a-zA-Z0-9/]*\?i=[a-zA-Z0-9]*['"]/></a></p>""",
11         # Feedburner tracking images
12         r"""<img [^>]*?src=['"]https?://feeds\.feedburner\.com/~r/[^"']*['"][^>]*>""",
13         # Wordpress tracking images
14         r"""<img [^>]*?src=['"]https?://stats\.wordpress\.com/b\.gif[^"']*['"][^>]*>""",
15         # Amazon tracking images
16         r"""<img [^>]*?src=['"]https?://www\.assoc-amazon\.com/e/ir[^"']*['"][^>]*>""",
17         # Paypal tracking images
18         r"""<img [^>]*?src=['"]https?://www\.paypalobjects\.com/[^/]*/i/scr/pixel.gif[^"']*['"][^>]*>""",
19         # Other tracking images
20         r"""<img [^>]*?width=["']1["'][^>]*?height=["']1["'][^>]*>""",
21         r"""<img [^>]*?height=["']1["'][^>]*?width=["']1["'][^>]*>""",
22 ]
23
24 for regex in regexes: data = re.sub(regex, '', data)
25
26 sys.stdout.write(data)