From a6f6b7372c816bef6fa22d4a5ccbbf0fe7be3215 Mon Sep 17 00:00:00 2001 From: Imre Eilertsen Date: Sat, 7 Jun 2025 03:37:38 +0200 Subject: [PATCH] Fix #1146 --- .../NordicHosts.txt | 4 +- .../XYZPrepareFilters.py | 161 ++++++++++++++++-- 2 files changed, 152 insertions(+), 13 deletions(-) diff --git a/NorwegianExperimentalList alternate versions/NordicHosts.txt b/NorwegianExperimentalList alternate versions/NordicHosts.txt index edb0acf6b..d8a5eda69 100644 --- a/NorwegianExperimentalList alternate versions/NordicHosts.txt +++ b/NorwegianExperimentalList alternate versions/NordicHosts.txt @@ -6,7 +6,6 @@ # 🇳🇴:Beskrivelse: Dette er en mindre versjon av «Dandelion Sprouts nordiske filtre", designet for brukere av programvarer som ikke støtter adblocker-syntaker. Den tar primært for seg svindler, skadevare, og reklamer på norske, danske, islandske, og færøyske nettsteder. # 🇩🇰:Beskrivelse: Dette er en slankere version af »Dandelion Sprouts nordiske filtre« beregnet til brugere af softwareværktøjer, der ikke understøtter adblocker-syntakser. Den er primært rettet mod svindel, malware og reklamer på danske, norske, islandske og færøske hjemmesider. # Description: This is a slimmer version of "Dandelion Sprout's Nordic Filters", intended for users of software tools that doesn't support adblocker syntaxes. It chiefly targets scams, malware and adverts, on Norwegian, Danish, Icelandic and Faroese websites. -!#if !env_mv3 # Platform notes: This list version is intended for tools that deal with so-called «hosts» system files, including pfBlockerNG, Gas Mask, Diversion, Hosts File Editor, and many others; as well as those who edit their OS' «hosts» system file. # If you use a tool that edits the system's own hosts file, such as Hosts File Editor, Gas Mask, or Magisk Manager, make sure to also use the IPv6 version at https://raw.githubusercontent.com/DandelionSprout/adfilt/master/NorwegianExperimentalList%20alternate%20versions/NordicFiltersHostsIPv6.txt # # If you're using Pi-Hole, the "AdGuard Home" list version should be used instead. @@ -765,5 +764,4 @@ -127.0.0.1 if-a-large-hosts-file-contains-this-entry-then-it.uses-dandelion-sprouts-nordic-domains-as-a-source-list.data www.if-a-large-hosts-file-contains-this-entry-then-it.uses-dandelion-sprouts-nordic-domains-as-a-source-list.data -!#endif + diff --git a/NorwegianExperimentalList alternate versions/XYZPrepareFilters.py b/NorwegianExperimentalList alternate versions/XYZPrepareFilters.py index 0f2cf9212..7dafeccb1 100644 --- a/NorwegianExperimentalList alternate versions/XYZPrepareFilters.py +++ b/NorwegianExperimentalList alternate versions/XYZPrepareFilters.py @@ -3536,14 +3536,8 @@ def prepare_hosts(lines) -> str: ) line = re.sub( - r"(Description: .*)$", - r"\1\n!#if !env_mv3", - line - ) - - line = re.sub( - r"(if-a-large-hosts-file.*)", - r"\1\n!#endif", + r"^.* if-a-.*$", + r"", line ) @@ -6956,6 +6950,12 @@ def prepare_agh(lines) -> str: line ) + line = re.sub( + r"^(.*[a-z])\^([a-z].*)$", + r"\1^$\2", + line + ) + if is_supported_agh(line): text += line + '\n' @@ -7678,6 +7678,7 @@ SOURCES = ['https://raw.githubusercontent.com/DandelionSprout/adfilt/master/Alte OUTPUT = 'Anti-Malware List/xyzzyxips.txt' OUTPUT_DOMAINS = 'Anti-Malware List/Dandelion Sprout\'s and other adblocker lists\' IPs.ipset' +OUTPUT_P2P = 'Anti-Malware List/Dandelion Sprout\'s and other adblocker lists\' IPs for P2P.p2p' # function that downloads the filter list def download_filters() -> str: @@ -7687,7 +7688,7 @@ def download_filters() -> str: text += r.text return text -# function that prepares the filter list for AdGuard Home +# function that prepares the filter list for the standard IP version def prepare_domains(lines) -> str: text = '' @@ -7783,7 +7784,7 @@ def prepare_domains(lines) -> str: ) line = re.sub( - r"^# ?([a-zABCGI-SU-Z0-9]|\(|F[a-np-z0-9]|T[a-hj-z0-9]).*$", + r"^# ?([a-zABCGI-SU-Z0-9#🇬🇧🇳🇴]|\(|F[a-np-z0-9]|T[a-hj-z0-9]).*$", r"", line ) @@ -7793,6 +7794,142 @@ def prepare_domains(lines) -> str: return text +# function that prepares the filter list for P2P +def prepare_p2p(lines) -> str: + text = '' + + previous_line = None + + for line in lines: + + if line == previous_line: + continue + + line = re.sub( + r"^[a-zA-Z!_*/İ=%&-].*$", + r"", + line + ) + + line = re.sub( + r"^\d.*[a-zA-Z!_*-].*$", + r"", + line + ) + + line = re.sub( + r"^# [—¤|].*$", + r"", + line + ) + + line = re.sub( + r"^# [a-zA-Z0-9 ,.'\"()/→≥İ-]{1,}$", + r"", + line + ) + + line = re.sub( + r"^# (Translated title|Source|Note|Platform notes):.*$", + r"", + line + ) + + line = re.sub( + r"^# Title: 📔.*$", + r"", + line + ) + + line = re.sub( + r"^# (Version|Last[ -]?[Mm]odified): [a-zA-Z0-9]{1,}$", + r"", + line + ) + + line = re.sub( + r"^# For m.*$", + r"", + line + ) + + line = re.sub( + r"^.*Nordic Filters.*$", + r"", + line + ) + + line = re.sub( + r"^.*nordiske filtre.*$", + r"", + line + ) + + line = re.sub( + r"^# Title: .*$", + r"# Title: Dandelion Sprout's and other adblocker lists' IPs (P2P)", + line + ) + + line = re.sub( + r"^# Description: .*$", + r"# Description: This IP set combines IP and CIDR addresses from plentiful of major adblocker lists. It contains heavily altered content from Dandelion Sprout's Anti-Malware List, Dandelion Sprout's Nordic Filters, EasyList, uBlock Filters, uBlock Filters - Badware Risks, AdGuard Base Filter, AdGuard French Filter, EasyList Germany, ABP Anti-Circumvention Filters, RU AdList, Liste AR, and EasyList Spanish.\n# For more information and details about this list and other lists of mine, go to https://github.com/DandelionSprout/adfilt/blob/master/Wiki/General-info.md#english", + line + ) + + line = re.sub( + r"^# (These|Google|Gigabyte|Copied).*$", + r"", + line + ) + + line = re.sub( + r"^:.*$", + r"", + line + ) + + line = re.sub( + r"^# ?([a-zABCGI-SU-Z0-9#🇬🇧🇳🇴]|\(|F[a-np-z0-9]|T[a-hj-z0-9]).*$", + r"", + line + ) + + line = re.sub( + r"^(\d.*)$", + r"F:\1-\1", + line + ) + + line = re.sub( + ".0/24-", + ".0-", + line + ) + + line = re.sub( + r"^(.*)\.0/24$", + r"\1.255", + line + ) + + line = re.sub( + r"^.*\.\d{1,3}:\d.*$", + r"", + line + ) + + line = re.sub( + r"^\[(.*)\]$", + r"F-IPv6:[\1]-[\1]", + line + ) + + if not line == '': + text += line + '\n' + + return text + if __name__ == "__main__": print('Starting the script') text = download_filters() @@ -7800,6 +7937,7 @@ if __name__ == "__main__": print('Total number of rules: ' + str(len(lines))) domains_filter = prepare_domains(lines) + p2p_filter = prepare_p2p(lines) with open(OUTPUT, "w", encoding="utf-8", newline='\n') as text_file: text_file.write(text) @@ -7807,6 +7945,9 @@ if __name__ == "__main__": with open(OUTPUT_DOMAINS, "w", encoding="utf-8", newline='\n') as text_file: text_file.write(domains_filter) + with open(OUTPUT_P2P, "w", encoding="utf-8", newline='\n') as text_file: + text_file.write(p2p_filter) + print('The combined IP list has been generated.') #/•\/•\/•\/•\/•\/•\/•\/•\/•\/•\/•\/•\/•\/•\/•\/•\/•\/•\/•\/•\/•\/•\/•\/•\/•\/•\/•\/•\/•\/•\