diff --git a/NorwegianExperimentalList alternate versions/DandelionSproutsNorskeFiltre.tpl b/NorwegianExperimentalList alternate versions/DandelionSproutsNorskeFiltre.tpl index e7433000e..603615226 100644 --- a/NorwegianExperimentalList alternate versions/DandelionSproutsNorskeFiltre.tpl +++ b/NorwegianExperimentalList alternate versions/DandelionSproutsNorskeFiltre.tpl @@ -1,6 +1,6 @@ msFilterList -# Version: 23May2019v2 -# Version: 230520192 (for Adblock Plus' issue report system) +# Version: 25May2019v4 +# Version: 250520194 (for Adblock Plus' issue report system) # Title: πŸ”οΈ Dandelion Sprouts nordiske filtre for ryddigere nettsider # Translated title: Dandelion Sprout's Nordic filters for tidier websites # expires = 1 @@ -24,6 +24,9 @@ msFilterList + + + -d 8m.com fs_img bannertype -d boligsamvirket.no promsys -d client-stream-events.mtg-api.com client-stream-events event viafree diff --git a/NorwegianExperimentalList alternate versions/LittleSnitchNorwegianList.lsrules b/NorwegianExperimentalList alternate versions/LittleSnitchNorwegianList.lsrules index 301160688..e09927807 100644 --- a/NorwegianExperimentalList alternate versions/LittleSnitchNorwegianList.lsrules +++ b/NorwegianExperimentalList alternate versions/LittleSnitchNorwegianList.lsrules @@ -1,5 +1,5 @@ { "title": "πŸ‘’ Dandelion Sprout's Nordic List for LS", -"description": "This list aims to block Norwegian and Danish scam sellers, ad servers, and a small handful of tracking servers..", +"description": "This list aims to block Norwegian and Danish scam sellers, ad servers, and a small handful of tracking servers.", "rules": [ { "action": "deny", "process": "any", "remote-hosts": "102.112.2o7.net" }, { "action": "deny", "process": "any", "remote-hosts": "abafort.us" }, diff --git a/NorwegianExperimentalList alternate versions/NordicFiltersABP.txt b/NorwegianExperimentalList alternate versions/NordicFiltersABP.txt index 1ad935f33..0e6b3d5b5 100644 --- a/NorwegianExperimentalList alternate versions/NordicFiltersABP.txt +++ b/NorwegianExperimentalList alternate versions/NordicFiltersABP.txt @@ -1,6 +1,6 @@ [Adblock Plus 3.2] -! Version: 23May2019v2 -! Version: 230520192 (for Adblock Plus' issue report system) +! Version: 25May2019v4 +! Version: 250520194 (for Adblock Plus' issue report system) ! Title: πŸ”οΈ Dandelion Sprouts nordiske filtre for ryddigere nettsider (for AdBlock og Adblock Plus) ! Translated title: Dandelion Sprout's Nordic filters for tidier websites (for AdBlock and AdBlock Plus) ! Expires: 12 hours @@ -92,6 +92,7 @@ @@||fwmrm.net/*MTG$script,domain=viasatsport.se|viasatsport.fi|tv3sport.dk|viasport.no|viafree.se|viafree.no|viafree.dk|viafree.fi @@||fwmrm.net/ad/$xmlhttprequest,domain=viasatsport.se|viasatsport.fi|tv3sport.dk|viasport.no|viafree.se|viafree.no|viafree.dk|viafree.fi @@||playapi.mtgx.tv/*/adinfo?$xmlhttprequest,domain=viafree.no|viafree.dk +@@||seher.no/reise$generichide aftenbladet.no##.brandboard-ad aftenbladet.no##.netboard-ad aftenbladet.no#?#div[class*="df-width-60"]:-abp-has(div[class*="netboard-ad"]) @@ -272,6 +273,9 @@ ramboll.no##.infoboxHolder rbnett.no##iframe[src="about:blank"] reelligestilling.dk##.googlepublisherpluginad seher.no##.css-r3dtrv +seher.no##.adunit + + sfanytime.com###ui-notification sfkids.com##hr side3.no###service-carousel @@ -504,6 +508,7 @@ sveip.net##.app_ad2 valkal.no##.ads gratiskryssord.no##.adSign gratiskryssord.no###adSign +rssnyheter.sveip.no##div[class^="ad_"] ! Empty divider spaces (Section under construction) icelandreview.com,bir.no#?#p:-abp-contains(/^\xA0$/) diff --git a/NorwegianExperimentalList alternate versions/NordicFiltersAdGuard.txt b/NorwegianExperimentalList alternate versions/NordicFiltersAdGuard.txt index 075742884..14283e9c1 100644 --- a/NorwegianExperimentalList alternate versions/NordicFiltersAdGuard.txt +++ b/NorwegianExperimentalList alternate versions/NordicFiltersAdGuard.txt @@ -1,5 +1,5 @@ [AdGuard β‰₯6] -! Version: 23May2019v2 +! Version: 25May2019v4 ! Title: πŸ”οΈ Dandelion Sprouts nordiske filtre for ryddigere nettsider (for AdGuard) ! Translated title: Dandelion Sprout's Nordic filters for tidier websites (for AdGuard) @@ -92,6 +92,7 @@ @@||fwmrm.net/*MTG$script,domain=viasatsport.se|viasatsport.fi|tv3sport.dk|viasport.no|viafree.se|viafree.no|viafree.dk|viafree.fi @@||fwmrm.net/ad/$xmlhttprequest,domain=viasatsport.se|viasatsport.fi|tv3sport.dk|viasport.no|viafree.se|viafree.no|viafree.dk|viafree.fi @@||playapi.mtgx.tv/*/adinfo?$xmlhttprequest,domain=viafree.no|viafree.dk +@@||seher.no/reise$generichide aftenbladet.no##.brandboard-ad aftenbladet.no##.netboard-ad aftenbladet.no#?#div[class*="df-width-60"]:-abp-has(div[class*="netboard-ad"]) @@ -272,6 +273,10 @@ ramboll.no##.infoboxHolder rbnett.no##iframe[src="about:blank"] reelligestilling.dk##.googlepublisherpluginad seher.no##.css-r3dtrv +seher.no##.adunit +!#if !env_mobile +seher.no##.content-marketing-ribbon:style(margin-top: 20px !important) +!#endif sfanytime.com###ui-notification sfkids.com##hr side3.no###service-carousel @@ -504,6 +509,7 @@ sveip.net##.app_ad2 valkal.no##.ads gratiskryssord.no##.adSign gratiskryssord.no###adSign +rssnyheter.sveip.no##div[class^="ad_"] ! Empty divider spaces (Section under construction) icelandreview.com,bir.no#?#p:-abp-contains(/^\xA0$/) diff --git a/NorwegianExperimentalList alternate versions/NordicFiltersPrivoxy.action b/NorwegianExperimentalList alternate versions/NordicFiltersPrivoxy.action index cd7360180..0ed8837ce 100644 --- a/NorwegianExperimentalList alternate versions/NordicFiltersPrivoxy.action +++ b/NorwegianExperimentalList alternate versions/NordicFiltersPrivoxy.action @@ -1,6 +1,6 @@ {+block} -# Version: 23May2019v2 -# Version: 230520192 (for Adblock Plus' issue report system) +# Version: 25May2019v4 +# Version: 250520194 (for Adblock Plus' issue report system) # 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 @@ -17,6 +17,8 @@ .oasfile /ad-video-log.php /prerolls/* +# +# .8m.com/fs_img/bannertype/ .boligsamvirket.no/promsys/ .client-stream-events.mtg-api.com/client-stream-events/event/viafree/ diff --git a/NorwegianExperimentalList alternate versions/xyz_nordic_lists.py b/NorwegianExperimentalList alternate versions/xyz_nordic_lists.py new file mode 100644 index 000000000..f9d875f35 --- /dev/null +++ b/NorwegianExperimentalList alternate versions/xyz_nordic_lists.py @@ -0,0 +1,689 @@ +import requests +import re + +SOURCES = ['https://gitlab.com/DandelionSprout/adfilt/raw/master/NorwegianList.txt'] + +UNSUPPORTED_ABP = ['$document', '$important', ',important' '$redirect=', ',redirect=', + ':style', '##+js', '.*#' , ':xpath', ':matches-css', 'dk,no##'] +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' + +# 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"\$document.*", + "$empty,important", + line + ) + + line = re.sub( + "Dandelion Sprouts nordiske filtre for ryddigere nettsider", + "Dandelion Sprouts nordiske filtre for ryddigere nettsider (for AdGuard)", + line + ) + + line = re.sub( + "Dandelion Sprout's Nordic filters for tidier websites", + "Dandelion Sprout's Nordic filters for tidier websites (for AdGuard)", + line + ) + + line = re.sub( + r"! Version: [0-9][0-9][0-9][0-9].*", + "", + line + ) + + line = re.sub( + "\[Adblock Plus 3.2\]", + "[AdGuard β‰₯6]", + line + ) + + line = re.sub( + r"! Redirect:.*", + "", + line + ) + + text += line + '\r\n' + + return text + +def is_supported_abp(line) -> bool: + for token in UNSUPPORTED_ABP: + if token in line: + return False + + return True + +# function that prepares the filter list for ABP +def prepare_abp(lines) -> str: + text = '' + + # remove or modifiy entries with unsupported modifiers + for line in lines: + + # remove $document modifier from the rule + line = re.sub( + "\$document.*", + "", + line + ) + + # remove $important modifier from the rule + line = re.sub( + r",important", + "", + line + ) + + line = re.sub( + r"\$important", + "", + line + ) + + line = re.sub( + "Dandelion Sprouts nordiske filtre for ryddigere nettsider", + "Dandelion Sprouts nordiske filtre for ryddigere nettsider (for AdBlock og Adblock Plus)", + line + ) + + line = re.sub( + "Dandelion Sprout's Nordic filters for tidier websites", + "Dandelion Sprout's Nordic filters for tidier websites (for AdBlock and AdBlock Plus)", + line + ) + + line = re.sub( + r"!#if.*", + "", + line + ) + + line = re.sub( + r"!#endif", + "", + line + ) + + line = re.sub( + r"^no##.*", + "", + line + ) + + line = re.sub( + r"! Redirect:.*", + "", + line + ) + + if is_supported_abp(line): + text += line + '\r\n' + + return text + +# Attempts to achieve Internet Explorer TPL support +def is_supported_tpl(line) -> bool: + for token in UNSUPPORTED_TPL: + if token in line: + return False + + return True + +# function that prepares the filter list for ABP +def prepare_tpl(lines) -> str: + text = '' + + # remove or modifiy entries with unsupported modifiers + for line in lines: + + line = re.sub( + "! ", + "# ", + line + ) + + line = re.sub( + "\[Adblock Plus 3.2\]", + "msFilterList", + line + ) + + line = re.sub( + r"^([@][@][|][|])", + "+d ", + line + ) + + line = re.sub( + r"^([|][|])", + "-d ", + line + ) + + line = re.sub( + r"^/", + "- ", + line + ) + + # TO-DO: Figure out how to make this NOT apply to lines that have the character "!" in them. + line = re.sub( + "/", + " ", + line + ) + + line = re.sub( + "\^", + "", + line + ) + + line = re.sub( + r"\$.*", + "", + line + ) + + line = re.sub( + r"! Redirect:.*", + "", + line + ) + + line = re.sub( + "-d \* ", + "- ", + line + ) + + line = re.sub( + "-d \.", + "- ", + line + ) + + line = re.sub( + "com\* ", + "com ", + line + ) + + line = re.sub( + r"([-][d].*[.][*].*)", + "", + line + ) + + line = re.sub( + r"@@\*\..*", + "", + line + ) + + line = re.sub( + "@@_", + "+d _", + line + ) + + line = re.sub( + r"^([+][d][\s][a-z].*[\s][a-z].*)", + "", + line + ) + + line = re.sub( + r"^([-][d].*[o|k|m]\.$)", + "", + line + ) + + line = re.sub( + r"!#if.*", + "", + line + ) + + line = re.sub( + "!#endif", + "", + line + ) + + line = re.sub( + "Expires: ", + "expires = ", + line + ) + + line = re.sub( + r"^\.([d|i|n]).*", + "", + line + ) + + line = re.sub( + "^\.", + "- ", + line + ) + + line = re.sub( + r"^@@ .*", + "", + line + ) + + line = re.sub( + " 12 hours", + " 1", + line + ) + + line = re.sub( + "# Redirect:.*", + "", + line + ) + + line = re.sub( + r"\+d\s[a-z0-9].*\s[a-z0-9*].*", + "", + line + ) + + line = re.sub( + "-d.*-\*$", + "", + line + ) + + if is_supported_tpl(line): + text += line + '\r\n' + + return text + +# β€”β€”β€”β€”β€” Privoxy version β€”β€”β€”β€”β€” + +# Attempts to achieve Internet Explorer TPL support +def is_supported_privoxy(line) -> bool: + for token in UNSUPPORTED_PRIVOXY: + if token in line: + return False + + return True + +def prepare_privoxy(lines) -> str: + text = '' + + # remove or modifiy entries with unsupported modifiers + for line in lines: + + line = re.sub( + "! ", + "# ", + line + ) + + line = re.sub( + r"\$.*", + "", + line + ) + + line = re.sub( + "\|\|", + ".", + line + ) + + line = re.sub( + "\^", + "", + line + ) + + line = re.sub( + "\[Adblock Plus 3.2\]", + "{+block}", + line + ) + + line = re.sub( + r"^$", + "#", + line + ) + + line = re.sub( + r"^\!.*", + "#", + line + ) + + line = re.sub( + "# πŸ‡¬πŸ‡§: ", + "{+block{", + line + ) + + # Note the use of parenthesises and "\1" combined. + line = re.sub( + r"(\{\+block{.*)", + r"\1}}", + line + ) + + line = re.sub( + "Dandelion Sprouts nordiske filtre for ryddigere nettsider", + "Dandelion Sprouts nordiske filtre for ryddigere nettsider (for Privoxy)", + line + ) + + line = re.sub( + "Dandelion Sprout's Nordic filters for tidier websites", + "Dandelion Sprout's Nordic filters for tidier websites (for Privoxy)", + line + ) + + if is_supported_privoxy(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) + abp_filter = prepare_abp(lines) + tpl_filter = prepare_tpl(lines) + privoxy_filter = prepare_privoxy(lines) + + 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) + + with open(OUTPUT_TPL, "w") as text_file: + text_file.write(tpl_filter) + + with open(OUTPUT_PRIVOXY, "w") as text_file: + text_file.write(privoxy_filter) + + print('The adblocker-based list versions have been generated.') + +import requests +import re + +SOURCES = ['https://gitlab.com/DandelionSprout/adfilt/raw/master/NorwegianExperimentalList%20alternate%20versions/DandelionSproutsNorskeFiltreDomains.txt'] + +UNSUPPORTED_HOSTS = ['*', '# β€”β€”β€”'] +UNSUPPORTED_LS = ['*', '# β€”β€”β€”', '# Translated title', '# Version', 'Don\'t be worried', 'General-info', '# Platform notes:'] +UNSUPPORTED_DNSMASQ = ['*', '# '] + +OUTPUT = 'xyzzyxdomains.txt' +OUTPUT_HOSTS = 'AdawayHosts' +OUTPUT_LS = 'LittleSnitchNorwegianList.lsrules' +OUTPUT_DNSMASQ = 'NordicFiltersDnsmasq.conf' +OUTPUT_HOSTSDENY = 'NordicFiltersHostsDeny.deny' + +# function that downloads the filter list +def download_filters() -> str: + text = '' + for url in SOURCES: + r = requests.get(url) + text += r.text + return text + +# β€”β€”β€”β€”β€” .\hosts version β€”β€”β€”β€”β€” + +def is_supported_hosts(line) -> bool: + for token in UNSUPPORTED_HOSTS: + if token in line: + return False + + return True + +def prepare_hosts(lines) -> str: + text = '' + + # remove or modifiy entries with unsupported modifiers + for line in lines: + + line = re.sub( + r"^(?!#)", + "127.0.0.1 ", + line + ) + + line = re.sub( + r"127\.0\.0\.1 $", + "", + line + ) + + line = re.sub( + "πŸ“” Dandelion Sprouts nordiske filtre \(Domenelisteversjonen\)", + "Dandelion Sprouts nordiske filtre (Β«hostsΒ»-versjonen)", + line + ) + + line = re.sub( + "Dandelion Sprout's Nordic Filters \(The domains list version\)", + "Dandelion Sprout's Nordic Filters (The Β«hostsΒ» file version)", + line + ) + + line = re.sub( + r"# Platform notes:.*", + "# Platform notes: This list version is intended for tools that deal with so-called Β«hostsΒ» system files, including Blokada, DNS66, Gas Mask, Diversion, and many others; as well as those who edit their OS' Β«hostsΒ» system file.", + line + ) + + if is_supported_hosts(line): + text += line + '\r\n' + + return text + +# β€”β€”β€”β€”β€” Little Snitch version β€”β€”β€”β€”β€” + +def is_supported_ls(line) -> bool: + for token in UNSUPPORTED_LS: + if token in line: + return False + + return True + +def prepare_ls(lines) -> str: + text = '' + + # remove or modifiy entries with unsupported modifiers + for line in lines: + + line = re.sub( + r"^(?!#)", + "{ \"action\": \"deny\", \"process\": \"any\", \"remote-hosts\": \"", + line + ) + + line = re.sub( + r"$(?<=\.com$)|(?<=\.no$)|(?<=\.dk$)|(?<=\.is$)|(?<=\.org$)|(?<=\.net$)|(?<=\.tc$)|(?<=\.it$)|(?<=\.online$)|(?<=\.top$)|(?<=\.tv$)|(?<=\.eu$)|(?<=\.us$)|(?<=\.info$)|(?<=\.club$)", + "\" },", + line + ) + + line = re.sub( + r"\.co$", + ".co\" },", + line + ) + + line = re.sub( + r"{ \"action\": \"deny\", \"process\": \"any\", \"remote-hosts\": \"$", + "", + line + ) + + line = re.sub( + r"^# Title:.*", + "{ \"title\": \"πŸ‘’ Dandelion Sprout's Nordic List for LS\",", + line + ) + + line = re.sub( + r"^# Description:.*", + "\"description\": \"This list aims to block Norwegian and Danish scam sellers, ad servers, and a small handful of tracking servers.\",\n\"rules\": [", + line + ) + + if is_supported_ls(line): + text += line + '\r\n' + + return text + +# β€”β€”β€”β€”β€” dnsmasq version β€”β€”β€”β€”β€” + +def is_supported_dnsmasq(line) -> bool: + for token in UNSUPPORTED_DNSMASQ: + if token in line: + return False + + return True + +def prepare_dnsmasq(lines) -> str: + text = '' + + # remove or modifiy entries with unsupported modifiers + for line in lines: + + line = re.sub( + r"^(?!#)", + "address=/", + line + ) + + line = re.sub( + r"$(?<=\.com$)|(?<=\.no$)|(?<=\.dk$)|(?<=\.is$)|(?<=\.org$)|(?<=\.net$)|(?<=\.tc$)|(?<=\.it$)|(?<=\.online$)|(?<=\.top$)|(?<=\.tv$)|(?<=\.eu$)|(?<=\.us$)|(?<=\.info$)|(?<=\.club$)", + "/127.0.0.1", + line + ) + + line = re.sub( + r"\.co$", + ".co/127.0.0.1", + line + ) + + line = re.sub( + r"address=/$", + "", + line + ) + + if is_supported_dnsmasq(line): + text += line + '\r\n' + + return text + +# β€”β€”β€”β€”β€” hosts.deny version β€”β€”β€”β€”β€” + +def prepare_hostsdeny(lines) -> str: + text = '' + + # remove or modifiy entries with unsupported modifiers + for line in lines: + + line = re.sub( + r"^(?!#)", + "ALL: ", + line + ) + + line = re.sub( + r"^ALL: $", + "", + line + ) + + line = re.sub( + r" Dandelion Sprouts nordiske filtre.*", + " Dandelion Sprouts nordiske filtre (Β«hosts.denyΒ»-versjonen)", + line + ) + + line = re.sub( + r" Dandelion Sprout's Nordic Filters.*", + " Dandelion Sprout's Nordic Filters (The Β«hosts.denyΒ» version)", + line + ) + + line = re.sub( + r"# Platform notes:.*", + "# Platform notes: This list version is intended for those who still use a Linux system function called Β«hosts.denyΒ».", + line + ) + + if is_supported_hosts(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))) + + hosts_filter = prepare_hosts(lines) + ls_filter = prepare_ls(lines) + dnsmasq_filter = prepare_dnsmasq(lines) + hostsdeny_filter = prepare_hostsdeny(lines) + + with open(OUTPUT, "w") as text_file: + text_file.write(text) + + with open(OUTPUT_HOSTS, "w") as text_file: + text_file.write(hosts_filter) + + with open(OUTPUT_LS, "w") as text_file: + text_file.write(ls_filter) + + with open(OUTPUT_DNSMASQ, "w") as text_file: + text_file.write(dnsmasq_filter) + + with open(OUTPUT_HOSTSDENY, "w") as text_file: + text_file.write(hostsdeny_filter) + + print('The domains-based list versions have been generated.') \ No newline at end of file