Support for AdBlock Format

This commit is contained in:
minoplhy 2021-08-02 15:15:42 +07:00
parent e8d97433ab
commit 11bc15614d

View File

@ -28,7 +28,7 @@ def filtering(filters_welcome):
lines = f.read().splitlines()
with open(filters_welcome, 'w') as f:
for line in lines:
if not line.startswith(('#',';','@','$',' NS','@@||')) and line.strip():
if not line.startswith(('#',';','@','$',' NS','@@||','!')) and line.strip():
f.write('\n'.join([line + '\n']))
print("++ successful!")
f.close()
@ -46,6 +46,20 @@ def filteringcon(filters_regex_one):
print("++ successful!")
f.close()
a = ['||','^','|']
lst = []
with open(filters_regex_one, 'r') as f:
for line in f:
for word in a:
if word in line:
line = line.replace(word,'')
lst.append(line)
f.close()
with open(filters_regex_one, 'w') as f:
for line in lst:
f.write(line)
f.close()
def killingdup(duplicated_file):
print('Getting rid of duplicated line')
with open(duplicated_file, 'r') as f:
@ -63,6 +77,7 @@ download_filters("https://filters.kylz.nl/RPZ/adguard/cname-original.txt")
download_filters("https://filters.kylz.nl/RPZ/stevenblack/f-s.txt")
download_filters("https://filters.kylz.nl/RPZ/someonewhocares/rpz.txt")
download_filters("https://urlhaus.abuse.ch/downloads/rpz/")
download_filters("https://github.com/easylist/easylist/raw/master/easylist/easylist_adservers.txt")
filtering(input)
filteringcon(input)
killingdup(input)