Attempted fix for something the AdGuard team couldn't be bothered to tell me about

This commit is contained in:
Imre Kristoffer Eilertsen
2020-06-12 04:08:33 +02:00
committed by GitHub
parent 2141aeb109
commit 04dcb98013
8 changed files with 231 additions and 272 deletions
@@ -1,5 +1,5 @@
msFilterList
# Version: 10June2020v3-Alpha
# Version: 12June2020v1-Alpha
# Title: 🏔️ Dandelion Sprouts nordiske filtre for ryddigere nettsider
# Translated title: Dandelion Sprout's Nordic filters for tidier websites
: expires = 1
@@ -1,5 +1,5 @@
[Adblock Plus 3.4]
! Version: 100620203
! Version: 120620201
! Title: 🏔️ Dandelion Sprouts vestnordiske filtre for ryddigere nettsider (for Adblock Plus - Møter Eyeo sine regler)
! Translated title: Dandelion Sprout's West Nordic filters for tidier websites (for Adblock Plus with Eyeo compliance)
! Expires: 12 hours
@@ -1,5 +1,5 @@
[Adblock Plus 3.4]
! Version: 100620203
! Version: 120620201
! Title: 🏔️ Dandelion Sprouts vestnordiske filtre for ryddigere nettsider (for AdBlock og Adblock Plus)
! Translated title: Dandelion Sprout's West Nordic filters for tidier websites (for AdBlock and Adblock Plus)
! Expires: 12 hours
@@ -1,4 +1,4 @@
! Version: 10June2020v3
! Version: 12June2020v1
! Title: 🏔️ Dandelion Sprouts nordiske filtre for ryddigere nettsider (for AdGuard)
! Translated title: Dandelion Sprout's Nordic filters for tidier websites (for AdGuard)
! Expires: 12 hours
@@ -916,9 +916,7 @@ krom.is#@#.share-container
!#endif
!#if !adguard
!#include NorwegianExperimentalList%20alternate%20versions/AntiAdblockEntries.txt
!#endif
!#include AntiAdblockEntries.txt
! 🇳🇴: ——— Forsøker å få nettleseren til å laste inn filer i HTTPS, dersom nettstedet ikke automatisk omdirigerer HTTP til dens HTTPS-versjon ———
@@ -1361,44 +1359,3 @@ finans.dk##.baPosition
||storustovu.dk^
!+ NOT_OPTIMIZED
||campingnews.dk^
! 🇳🇴/🇩🇰: ——— Anti-anti-reklameblokkering ———
! 🇮🇸: ——— And-and-auglýsingshindrun ———
! 🇬🇧: ——— Anti-anti-adblocking ———
! Last updated: 10June2020v1-Extension
gratiskostplaner.dk##+js(aopw, KillAdBlock)
aftenposten.no##div[style*="width: 10"][style*="z-index: 2147"]
csp.screen9.com#@#.adsbox
dagensbyggeri.dk##+js(std, (), 2500)
eurosport.*##+js(aeld, contextmenu)
godt.no##.adblock-info-box
gratisspil.dk##+js(aopw, AdBlockerInfo)
langaa-guiden.dk,madforfattigroeve.dk##div[class][style*="z-index: 9999999; opacity"]
langaa-guiden.dk,madforfattigroeve.dk##div[class][style^="z-index: 999999; background: rgba"]
minmote.no,godt.no##.adblock-info
techstart.dk##+js(set, adblock, false)
tv2.no##+js(acis, adblockDetector)
vg.no##+js(aeld, load, concat)
tipsbladet.dk##.js-isblured:style(-webkit-filter: none !important; filter: none !important)
tipsbladet.dk###js-promo-welcome
abcnyheter.no##div[style^="bottom: 0px;"]
||aftenposten.no/seksjon/dist/ads-$script
||dni-adops-proxy-prod-adopsmediaconverter.mercury.dnitv.com/$media,redirect=noopmp3-0.1s,domain=dplay.*
||elderlyscissors.com^
||imasdk.googleapis.com/pal/sdkloader/pal.js$script,redirect=noopjs,domain=dplay.*
||vg.no/cnp-assets/src/sites/vg/components/AdblockModal$script,~third-party
@@.dk/assets/templates/*/ads.png$image,domain=maskinbladet.dk|agrar-plus.dk|fritidsmarkedet.dk|dagensbyggeri.dk|maskinteknik.dk|gronteknik.dk
@@/js/ads.js$~third-party,domain=tvkampen.com|tvsporten.dk
@@||bondebladet.screen9.tv^$generichide
@@||eurosport.*^$generichide
@@||fwmrm.net/ad/$script,domain=dplay.*
@@||sixscissors.com^$third-party,domain=itavisen.no
@@||www.tv2.no/s/js/ads.js$script,~third-party
gamereactor.*##+js(set, adblockEnabled, noopFunc)
gamereactor.*##+js(set, trackAdblock, noopFunc)
!#if !ext_ublock
@@||bildeler.name$generichide
@@||reservedele.name$generichide
!#endif
!#if env_firefox
gamereactor.*##^script[onError="adblockEnabled()"]
!#endif
@@ -1,5 +1,5 @@
[Adblock Plus 3.4]
! Version: 10June2020v3-Alpha
! Version: 12June2020v1-Alpha
! Title: 🏔️ Dandelion Sprouts nordiske filtre for ryddigere nettsider (for Brave Browser)
! Translated title: Dandelion Sprout's Nordic filters for tidier websites (for Brave Browser)
! Expires: 12 hours
@@ -1,4 +1,4 @@
! Version: 10June2020v3
! Version: 12June2020v1
! Title: 🏔️ Dandelion Sprouts nordiske filtre for ryddigere nettsider (uten sporerhvitelisting)
! Translated title: Dandelion Sprout's Nordic filters for tidier websites (without tracker whitelistings)
! Expires: 12 hours
@@ -916,9 +916,7 @@ krom.is#@#.share-container
!#endif
!#if !adguard
!#include NorwegianExperimentalList%20alternate%20versions/AntiAdblockEntries.txt
!#endif
! 🇳🇴: ——— Forsøker å få nettleseren til å laste inn filer i HTTPS, dersom nettstedet ikke automatisk omdirigerer HTTP til dens HTTPS-versjon ———
@@ -1,4 +1,4 @@
# Version: 10June2020v3-Alpha
# Version: 12June2020v1-Alpha
# Title: 🏔️ Dandelion Sprouts nordiske filtre for ryddigere nettsider (for Privoxy)
# Translated title: Dandelion Sprout's Nordic filters for tidier websites (for Privoxy)
# Expires: 12 hours
@@ -301,8 +301,6 @@ contentMarketing
#
#
#
#
#
# 🇳🇴: ——— Forsøker å få nettleseren til å laste inn filer i HTTPS, dersom nettstedet ikke automatisk omdirigerer HTTP til dens HTTPS-versjon ———
{+block{——— Tries to make the web browser load files in HTTPS, if the website itself doesn't automatically redirect from HTTP to its HTTPS version ———}}
# Credit to https://raw.githubusercontent.com/Cybo1927/Hosts/master/Anti/Anti%2520Third-Party%2520HTTP for showing me the existence of this particular CSP command.
@@ -10,7 +10,6 @@ UNSUPPORTED_PRIVOXY = ['##', '#@#', '#?#', '@@', '!#']
UNSUPPORTED_BRAVE = ['##', '#@#', '#?#', '!#', '!+', '$csp', '$generichide', '$elemhide', '$specificblock', '$redirect', ',redirect', 'emty.gif', '1pix.gif', '730.no/banner/', 'gaysir.no/rek/', '85.17.76.181', 'youtube.jpg', 'instagram', 'cookieinformation', 'Social Blocking', '/admark_', 'PFBLOCKERNG', 'boks', 'rammar', ' spaces', 'services.api.no', 'Viatrumf', 'Internet Explorer', 'Elkjøp', ' elding.fo', ' background', 'baggrund', 'EasyList —', 'baksýn']
OUTPUT = 'xyzzyx.txt'
OUTPUT_AG = 'NordicFiltersAdGuard.txt'
OUTPUT_ABP = 'NordicFiltersABP.txt'
OUTPUT_TPL = 'DandelionSproutsNorskeFiltre.tpl'
OUTPUT_PRIVOXY = 'NordicFiltersPrivoxy.action'
@@ -25,217 +24,6 @@ def download_filters() -> str:
text += r.text
return text
# ——— AdGuard version ———
# 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]{4}.*",
"",
line
)
line = re.sub(
"\[Adblock Plus 3.4\]",
"[AdGuard ≥7.2]",
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(
"redirect=noopmp4-1s",
"mp4",
line
)
line = re.sub(
r"^!.*PFBLOCKERNG.*",
r"",
line
)
line = re.sub(
r"^\|\|(([1-2]?[0-9]?[0-9]\.?){4})\^\$.*",
r"\1$network",
line
)
line = re.sub(
r"^\|\|(([1-2]?[0-9]?[0-9]\.?){4})\^",
r"\1$network",
line
)
line = re.sub(
r"([a-z*])#[?]?#(.*):(upward|nth-ancestor)\(1\)",
r"\1#?#*:has(> \2)",
line
)
line = re.sub(
r"([a-z*])#[?]?#(.*):(upward|nth-ancestor)\(2\)",
r"\1#?#*:has(> * > \2)",
line
)
line = re.sub(
r"([a-z*])#[?]?#(.*):(upward|nth-ancestor)\(3\)",
r"\1#?#*:has(> * > * > \2)",
line
)
line = re.sub(
r"([a-z*])#[?]?#(.*):(upward|nth-ancestor)\(4\)",
r"\1#?#*:has(> * > * > * > \2)",
line
)
line = re.sub(
r"([a-z*])#[?]?#(.*):(upward|nth-ancestor)\(5\)",
r"\1#?#*:has(> * > * > * > * > \2)",
line
)
line = re.sub(
r"([a-z*])#[?]?#(.*):(upward|nth-ancestor)\(6\)",
r"\1#?#*:has(> * > * > * > * > * > \2)",
line
)
line = re.sub(
r"([a-z*])#[?]?#(.*):(upward|nth-ancestor)\(7\)",
r"\1#?#*:has(> * > * > * > * > * > * > \2)",
line
)
line = re.sub(
r"([a-z*])#[?]?#(.*):(upward|nth-ancestor)\(8\)",
r"\1#?#*:has(> * > * > * > * > * > * > * > \2)",
line
)
line = re.sub(
r"([a-z*])#[?]?#(.*):(upward|nth-ancestor)\(9\)",
r"\1#?#*:has(> * > * > * > * > * > * > * > * > \2)",
line
)
line = re.sub(
r"([a-z*])#[?]?#(.*):(upward|nth-ancestor)\(10\)",
r"\1#?#*:has(> * > * > * > * > * > * > * > * > * > \2)",
line
)
line = re.sub(
r"has\(:scope >",
r"has(>",
line
)
line = re.sub(
r":-abp-has\(",
r":has(",
line
)
line = re.sub(
r":-abp-contains\(",
r":has-text(",
line
)
line = re.sub(
r"domain=dplay\.no\|dplay\.dk",
r"domain=dplay.*",
line
)
line = re.sub(
r"domain=auth.dplay\.no\|auth.dplay\.dk",
r"domain=auth.dplay.*",
line
)
line = re.sub(
r"domain=gamereactor\.no\|gamereactor\.dk",
r"domain=gamereactor.*",
line
)
line = re.sub(
r"\|gamereactor\.no\|gamereactor\.dk",
r"|gamereactor.*",
line
)
line = re.sub(
r"domain=viafree\.no\|viafree\.dk",
r"domain=viafree.*",
line
)
line = re.sub(
r"domain=eniro.se\|eniro\.no\|eniro\.dk",
r"domain=eniro.*",
line
)
line = re.sub(
r"domain=eurosport\.no\|eurosport\.dk",
r"domain=eurosport.*",
line
)
line = re.sub(
r"\|proff.se\|proff\.no\|proff\.dk",
r"|proff.*",
line
)
text += line + '\r\n'
return text
# ——— Adblock Plus version ———
def is_supported_abp(line) -> bool:
@@ -1423,7 +1211,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)
@@ -1433,9 +1220,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)
@@ -1466,6 +1250,7 @@ UNSUPPORTED_ABP = ['$important', ',important', '$redirect=', ',redirect=',
OUTPUT = 'xyzzyxeyeo.txt'
OUTPUT_ABP = 'NordicFiltersABP-Eyeo.txt'
OUTPUT_AG = 'NordicFiltersAdGuard.txt'
# function that downloads the filter list
def download_filters() -> str:
@@ -1906,6 +1691,223 @@ def prepare_abp(lines) -> str:
return text
# ——— AdGuard version ———
# 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]{4}.*",
"",
line
)
line = re.sub(
"\[Adblock Plus 3.4\]",
"[AdGuard ≥7.2]",
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(
"redirect=noopmp4-1s",
"mp4",
line
)
line = re.sub(
r"^!.*PFBLOCKERNG.*",
r"",
line
)
line = re.sub(
r"^\|\|(([1-2]?[0-9]?[0-9]\.?){4})\^\$.*",
r"\1$network",
line
)
line = re.sub(
r"^\|\|(([1-2]?[0-9]?[0-9]\.?){4})\^",
r"\1$network",
line
)
line = re.sub(
r"([a-z*])#[?]?#(.*):(upward|nth-ancestor)\(1\)",
r"\1#?#*:has(> \2)",
line
)
line = re.sub(
r"([a-z*])#[?]?#(.*):(upward|nth-ancestor)\(2\)",
r"\1#?#*:has(> * > \2)",
line
)
line = re.sub(
r"([a-z*])#[?]?#(.*):(upward|nth-ancestor)\(3\)",
r"\1#?#*:has(> * > * > \2)",
line
)
line = re.sub(
r"([a-z*])#[?]?#(.*):(upward|nth-ancestor)\(4\)",
r"\1#?#*:has(> * > * > * > \2)",
line
)
line = re.sub(
r"([a-z*])#[?]?#(.*):(upward|nth-ancestor)\(5\)",
r"\1#?#*:has(> * > * > * > * > \2)",
line
)
line = re.sub(
r"([a-z*])#[?]?#(.*):(upward|nth-ancestor)\(6\)",
r"\1#?#*:has(> * > * > * > * > * > \2)",
line
)
line = re.sub(
r"([a-z*])#[?]?#(.*):(upward|nth-ancestor)\(7\)",
r"\1#?#*:has(> * > * > * > * > * > * > \2)",
line
)
line = re.sub(
r"([a-z*])#[?]?#(.*):(upward|nth-ancestor)\(8\)",
r"\1#?#*:has(> * > * > * > * > * > * > * > \2)",
line
)
line = re.sub(
r"([a-z*])#[?]?#(.*):(upward|nth-ancestor)\(9\)",
r"\1#?#*:has(> * > * > * > * > * > * > * > * > \2)",
line
)
line = re.sub(
r"([a-z*])#[?]?#(.*):(upward|nth-ancestor)\(10\)",
r"\1#?#*:has(> * > * > * > * > * > * > * > * > * > \2)",
line
)
line = re.sub(
r"has\(:scope >",
r"has(>",
line
)
line = re.sub(
r":-abp-has\(",
r":has(",
line
)
line = re.sub(
r":-abp-contains\(",
r":has-text(",
line
)
line = re.sub(
r"domain=dplay\.no\|dplay\.dk",
r"domain=dplay.*",
line
)
line = re.sub(
r"domain=auth.dplay\.no\|auth.dplay\.dk",
r"domain=auth.dplay.*",
line
)
line = re.sub(
r"domain=gamereactor\.no\|gamereactor\.dk",
r"domain=gamereactor.*",
line
)
line = re.sub(
r"\|gamereactor\.no\|gamereactor\.dk",
r"|gamereactor.*",
line
)
line = re.sub(
r"domain=viafree\.no\|viafree\.dk",
r"domain=viafree.*",
line
)
line = re.sub(
r"domain=eniro.se\|eniro\.no\|eniro\.dk",
r"domain=eniro.*",
line
)
line = re.sub(
r"domain=eurosport\.no\|eurosport\.dk",
r"domain=eurosport.*",
line
)
line = re.sub(
r"\|proff.se\|proff\.no\|proff\.dk",
r"|proff.*",
line
)
line = re.sub(
r"!#include NorwegianExperimentalList%20alternate%20versions/AntiAdblockEntries\.txt",
r"!#include AntiAdblockEntries.txt",
line
)
text += line + '\r\n'
return text
if __name__ == "__main__":
print('Starting the script')
text = download_filters()
@@ -1913,6 +1915,7 @@ if __name__ == "__main__":
print('Total number of rules: ' + str(len(lines)))
abp_filter = prepare_abp(lines)
ag_filter = prepare_ag(lines)
with open(OUTPUT, "w") as text_file:
text_file.write(text)
@@ -1920,7 +1923,10 @@ if __name__ == "__main__":
with open(OUTPUT_ABP, "w") as text_file:
text_file.write(abp_filter)
print('The Eyeo list version has been generated.')
with open(OUTPUT_AG, "w") as text_file:
text_file.write(ag_filter)
print('The Eyeo and AdGuard list versions have been generated.')