Making use of AdGuard's support for "$network"

This commit is contained in:
Imre Kristoffer Eilertsen
2019-09-25 19:16:50 +02:00
committed by GitHub
parent 44a6ef53c9
commit 0a206b2b85
2 changed files with 311 additions and 131 deletions
@@ -1135,3 +1135,145 @@ fuglelyder.net#@##banner_ad
||nofotballshop.com^$empty,important
||nofotballstore.com^$empty,important
||dkfodboldstore.com^$empty,important
3.210.252.48$network
3.248.18.175$network
5.39.220.85$network
13.225.212.101$network
13.225.212.53$network
13.225.62.2$network
18.189.126.183$network
23.227.38.32$network
23.23.86.44$network
23.27.73.214$network
23.94.235.88$network
23.95.244.102$network
31.169.51.140$network
31.222.200.102$network
31.222.201.66$network
31.222.202.71$network
31.3.65.30$network
35.186.219.42$network
35.227.255.245$network
35.241.20.53$network
37.157.2.236$network
43.248.10.237$network
45.58.146.154$network
46.183.136.42$network
46.250.210.141$network
46.30.215.134$network
47.91.170.222$network
50.63.202.42$network
52.164.250.133$network
52.216.109.170$network
52.58.78.16$network
54.157.54.26$network
62.50.190.101$network
67.227.226.240$network
69.172.201.153$network
74.91.20.131$network
77.234.171.173$network
81.95.105.70$network
83.221.150.162$network
86.48.36.52$network
89.188.76.230$network
89.248.170.156$network
91.189.177.154$network
91.225.60.235$network
94.23.105.26$network
95.128.27.38$network
98.126.4.66$network
100.42.68.162$network
103.232.215.144$network
104.140.186.144$network
104.164.143.147$network
104.164.177.83$network
104.165.52.83$network
104.18.119.98$network
104.18.32.122$network
104.237.152.201$network
104.24.111.20$network
104.24.119.5$network
104.24.124.114$network
104.24.97.65$network
104.27.145.13$network
104.28.4.240$network
104.28.8.151$network
107.150.93.71$network
107.172.160.239$network
107.172.160.99$network
107.172.163.217$network
107.172.163.50$network
107.172.169.215$network
107.173.121.244$network
107.173.172.61$network
107.173.172.62$network
107.174.198.168$network
107.174.201.232$network
107.174.202.107$network
107.179.67.145$network
122.10.109.175$network
136.243.23.201$network
141.255.161.124$network
142.93.134.57$network
151.80.13.35$network
154.92.189.29$network
156.234.4.218$network
158.255.2.99$network
159.8.209.70$network
160.153.128.26$network
165.231.102.178$network
165.231.198.15$network
165.231.2.215$network
165.231.202.19$network
167.160.13.5$network
172.217.12.198$network
172.241.59.200$network
172.241.59.217$network
172.241.59.218$network
172.255.61.238$network
172.82.206.20$network
173.82.167.117$network
173.82.48.54$network
176.9.53.166$network
184.168.131.241$network
185.13.40.150$network
185.191.120.62$network
185.53.177.20$network
185.53.179.7$network
185.53.179.8$network
185.57.253.48$network
185.65.143.249$network
185.87.187.198$network
192.64.147.215$network
193.106.122.91$network
194.63.248.52$network
194.63.249.232$network
195.149.158.3$network
195.178.187.50$network
196.196.112.67$network
196.196.113.215$network
196.196.115.171$network
196.196.115.36$network
196.196.118.17$network
196.196.252.54$network
196.247.26.241$network
198.211.23.249$network
198.54.117.197$network
198.55.28.201$network
199.115.115.102$network
199.59.242.152$network
202.208.203.101$network
204.15.79.70$network
208.43.231.246$network
209.124.66.22$network
213.236.166.56$network
216.157.88.25$network
217.65.231.100$network
@@ -9,7 +9,6 @@ UNSUPPORTED_TPL = ['##', '#@#', '#?#', r'\.no\.$']
UNSUPPORTED_PRIVOXY = ['##', '#@#', '#?#', '@@', '!#']
OUTPUT = 'xyzzyx.txt'
OUTPUT_AG = 'NordicFiltersAdGuard.txt'
OUTPUT_ABP = 'NordicFiltersABP.txt'
OUTPUT_TPL = 'DandelionSproutsNorskeFiltre.tpl'
OUTPUT_PRIVOXY = 'NordicFiltersPrivoxy.action'
@@ -23,132 +22,6 @@ def download_filters() -> str:
text += r.text
return text
# function that prepares the filter list for AdGuard
def prepare_ag(lines) -> str:
text = ''
for line in lines:
# until this is done: https://github.com/AdguardTeam/CoreLibs/issues/152
line = re.sub(
r"([\$,])doc.*",
r"\1empty,important",
line
)
line = re.sub(
r"(itle:.*Dandelion Sprout.*)",
r"\1 (for AdGuard)",
line
)
line = re.sub(
r"! Version: [0-9][0-9][0-9][0-9].*",
"",
line
)
line = re.sub(
"\[Adblock Plus 3.4\]",
"[AdGuard ≥6]",
line
)
line = re.sub(
r"! Redirect:.*",
"",
line
)
line = re.sub(
r"([$,])xhr",
r"\1xmlhttprequest",
line
)
line = re.sub(
r"([$,~])3p",
r"\1third-party",
line
)
line = re.sub(
r"([$,])1p",
r"\1~third-party",
line
)
line = re.sub(
"viaplay.\*#",
"viaplay.no,viaplay.dk#",
line
)
line = re.sub(
"google.\*#",
"google.no,google.dk,google.is#",
line
)
line = re.sub(
"eurogamer.\*#",
"eurogamer.dk#",
line
)
line = re.sub(
"ticketmaster.\*#",
"ticketmaster.no,ticketmaster.dk#",
line
)
line = re.sub(
"qxl.\*#",
"qxl.no,qxl.dk#",
line
)
line = re.sub(
"expedia.\*#",
"expedia.no,expedia.dk#",
line
)
line = re.sub(
"gamereactor.\*#",
"gamereactor.no,gamereactor.dk#",
line
)
line = re.sub(
"viafree.\*#",
"viafree.no,viafree.dk#",
line
)
line = re.sub(
"momondo.\*#",
"momondo.no,monondo.dk#",
line
)
line = re.sub(
"eurosport.\*#",
"eurosport.no,eurosport.dk#",
line
)
line = re.sub(
"prisjakt.\*,",
"prisjakt.no,",
line
)
text += line + '\r\n'
return text
def is_supported_abp(line) -> bool:
for token in UNSUPPORTED_ABP:
if token in line:
@@ -771,7 +644,6 @@ if __name__ == "__main__":
lines = text.splitlines(False)
print('Total number of rules: ' + str(len(lines)))
ag_filter = prepare_ag(lines)
abp_filter = prepare_abp(lines)
tpl_filter = prepare_tpl(lines)
privoxy_filter = prepare_privoxy(lines)
@@ -780,9 +652,6 @@ if __name__ == "__main__":
with open(OUTPUT, "w") as text_file:
text_file.write(text)
with open(OUTPUT_AG, "w") as text_file:
text_file.write(ag_filter)
with open(OUTPUT_ABP, "w") as text_file:
text_file.write(abp_filter)
@@ -797,6 +666,175 @@ if __name__ == "__main__":
print('The adblocker-based list versions have been generated.')
import requests
import re
SOURCES = ['https://gitlab.com/DandelionSprout/adfilt/raw/master/NorwegianList.txt', 'https://gitlab.com/DandelionSprout/adfilt/raw/master/NorwegianExperimentalList%20alternate%20versions/NordicFiltersIPs.txt']
OUTPUT_AG = 'NordicFiltersAdGuard.txt'
# function that downloads the filter list
def download_filters() -> str:
text = ''
for url in SOURCES:
r = requests.get(url)
text += r.text
return text
# function that prepares the filter list for AdGuard
def prepare_ag(lines) -> str:
text = ''
for line in lines:
# until this is done: https://github.com/AdguardTeam/CoreLibs/issues/152
line = re.sub(
r"([\$,])doc.*",
r"\1empty,important",
line
)
line = re.sub(
r"(itle:.*Dandelion Sprout.*)",
r"\1 (for AdGuard)",
line
)
line = re.sub(
r"! Version: [0-9][0-9][0-9][0-9].*",
"",
line
)
line = re.sub(
"\[Adblock Plus 3.4\]",
"[AdGuard ≥6]",
line
)
line = re.sub(
r"! Redirect:.*",
"",
line
)
line = re.sub(
r"([$,])xhr",
r"\1xmlhttprequest",
line
)
line = re.sub(
r"([$,~])3p",
r"\1third-party",
line
)
line = re.sub(
r"([$,])1p",
r"\1~third-party",
line
)
line = re.sub(
"viaplay.\*#",
"viaplay.no,viaplay.dk#",
line
)
line = re.sub(
"google.\*#",
"google.no,google.dk,google.is#",
line
)
line = re.sub(
"eurogamer.\*#",
"eurogamer.dk#",
line
)
line = re.sub(
"ticketmaster.\*#",
"ticketmaster.no,ticketmaster.dk#",
line
)
line = re.sub(
"qxl.\*#",
"qxl.no,qxl.dk#",
line
)
line = re.sub(
"expedia.\*#",
"expedia.no,expedia.dk#",
line
)
line = re.sub(
"gamereactor.\*#",
"gamereactor.no,gamereactor.dk#",
line
)
line = re.sub(
"viafree.\*#",
"viafree.no,viafree.dk#",
line
)
line = re.sub(
"momondo.\*#",
"momondo.no,monondo.dk#",
line
)
line = re.sub(
"eurosport.\*#",
"eurosport.no,eurosport.dk#",
line
)
line = re.sub(
"prisjakt.\*,",
"prisjakt.no,",
line
)
line = re.sub(
r"^# .*",
"",
line
)
line = re.sub(
r"^([0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?)$",
r"\1$network",
line
)
text += line + '\r\n'
return text
if __name__ == "__main__":
print('Starting the script')
text = download_filters()
lines = text.splitlines(False)
print('Total number of rules: ' + str(len(lines)))
ag_filter = prepare_ag(lines)
with open(OUTPUT_AG, "w") as text_file:
text_file.write(ag_filter)
print('The AdGuard list version has been generated.')
import requests
import re