From 86a3f358e489e0592e68617f0099140afb62ba86 Mon Sep 17 00:00:00 2001 From: Imre Kristoffer Eilertsen Date: Fri, 17 May 2019 21:40:24 +0200 Subject: [PATCH] Update NordicFiltersScriptTesting.py --- Sandbox/NordicFiltersScriptTesting.py | 37 +++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/Sandbox/NordicFiltersScriptTesting.py b/Sandbox/NordicFiltersScriptTesting.py index 07df7651e..c1d6324d7 100644 --- a/Sandbox/NordicFiltersScriptTesting.py +++ b/Sandbox/NordicFiltersScriptTesting.py @@ -1,22 +1,20 @@ import requests import re -SOURCES = ['https://raw.githubusercontent.com/DandelionSprout/adfilt/master/NorwegianList.txt', - 'https://raw.githubusercontent.com/DandelionSprout/adfilt/master/uBO%20list%20extensions/NordicExtensionsForUBO%26Nano.txt'] +SOURCES = ['https://raw.githubusercontent.com/DandelionSprout/adfilt/master/NorwegianList.txt'] UNSUPPORTED_ABP = ['$document', '$important', ',important' '$redirect=', ',redirect=', - ':style', '##+js', '.*#' , ':xpath', ':matches-css'] + ':style', '##+js', '.*#' , ':xpath', ':matches-css', 'dk,no##'] OUTPUT = 'filter.txt' OUTPUT_AG = 'filter_ag.txt' -OUTPUT_ABP = 'filter_abp.txt' +OUTPUT_ABP = 'NordicFiltersABP.txt' # function that downloads the filter list def download_filters() -> str: text = '' for url in SOURCES: r = requests.get(url) - text += '! ' + url + '\r\n' text += r.text return text @@ -68,6 +66,35 @@ def prepare_abp(lines) -> str: 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 + ) if is_supported_abp(line): text += line + '\r\n'