Write the rules to a file

This commit is contained in:
iam-py-test
2021-11-06 16:18:12 -04:00
committed by GitHub
parent 843ff6c23a
commit 284d858d43
+6 -4
View File
@@ -24,6 +24,7 @@
import json
import sys
endrules = None
def normalize_url_pattern(url_pattern: str) -> str:
# No need for protocol and subdomain
@@ -105,8 +106,9 @@ def getrules():
import requests
return requests.get("https://raw.githubusercontent.com/ClearURLs/Rules/master/data.min.json").text
def main() -> int:
global endrules
data_min_json = json.loads(getrules())
endrules = open("uBO list extensions/clear_urls_uboified.txt","w")
# TODO: referralMarketing
providers = {
@@ -147,11 +149,11 @@ def main() -> int:
for exception in exceptions:
kind, exception = normalize_exception(exception.replace("\\\\", "\\"))
if kind == "regex":
print("@@/{0}/$removeparam".format(exception))
endrules.write("@@/{0}/$removeparam".format(exception))
elif kind == "path":
print("@@{0}$removeparam".format(exception))
endrules.write("@@{0}$removeparam".format(exception))
elif kind == "domain":
print("@@$removeparam,domain={0}".format(exception))
endrules.write("@@$removeparam,domain={0}".format(exception))
else:
raise ValueError