Merge pull request #333 from iam-py-test/master

Add checks into the bot
This commit is contained in:
Imre Kristoffer Eilertsen
2021-11-09 12:58:28 +01:00
committed by GitHub
3 changed files with 24 additions and 3 deletions
+2 -2
View File
@@ -1,10 +1,10 @@
! Title: ClearURLs for uBo - List extension
! Homepage: https://github.com/DandelionSprout/adfilt/discussions/163
! Last updated: 07/11/2021
! Last updated: 09/11/2021
! Expires: 1 day
! Licence: https://github.com/DandelionSprout/adfilt/blob/master/LICENSE.md
! Note: This was based off of https://gist.github.com/rusty-snake/5cd83a87d680ecbd03e79a1a06758207, which is based off of https://github.com/ClearURLs/Rules. The maintainers of Adfilt (DandelionSprout and iam-py-test, and contributors) have made some modifications as to keep it up-to-date with the source and to fix issues
! IMPORTANT NOTE: Do not modify this file. This file is autogenerated and therefore any direct edit to it will be undone. Instead, modifications must be made to https://github.com/DandelionSprout/adfilt/blob/master/ClearURLs%20for%20uBo/compile.py or to the upstream ClearURLs rules
! IMPORTANT NOTE: Do not modify this file. This file is autogenerated and therefore any direct edit to it will be undone. Instead, modifications must be made to https://github.com/DandelionSprout/adfilt/blob/master/ClearURLs%20for%20uBo/compile.py or to the upstream ClearURLs rules. If you experience an issue, please report it to https://github.com/DandelionSprout/adfilt/discussions/163, and we (the Adfilt maintainers and community) will look into it and either add an exclusion or report it to the ClearURLs team
$removeparam=/^p[fd]_rd_[a-z]*=/,domain=amazon.*
$removeparam=qid,domain=amazon.*
+21 -1
View File
@@ -23,6 +23,7 @@
import json
import sys
import hashlib
from datetime import date
from typing import IO
@@ -35,7 +36,7 @@ HEAD = """\
! Expires: 1 day
! Licence: https://github.com/DandelionSprout/adfilt/blob/master/LICENSE.md
! Note: This was based off of https://gist.github.com/rusty-snake/5cd83a87d680ecbd03e79a1a06758207, which is based off of https://github.com/ClearURLs/Rules. The maintainers of Adfilt (DandelionSprout and iam-py-test, and contributors) have made some modifications as to keep it up-to-date with the source and to fix issues
! IMPORTANT NOTE: Do not modify this file. This file is autogenerated and therefore any direct edit to it will be undone. Instead, modifications must be made to https://github.com/DandelionSprout/adfilt/blob/master/ClearURLs%20for%20uBo/compile.py or to the upstream ClearURLs rules
! IMPORTANT NOTE: Do not modify this file. This file is autogenerated and therefore any direct edit to it will be undone. Instead, modifications must be made to https://github.com/DandelionSprout/adfilt/blob/master/ClearURLs%20for%20uBo/compile.py or to the upstream ClearURLs rules. If you experience an issue, please report it to https://github.com/DandelionSprout/adfilt/discussions/163, and we (the Adfilt maintainers and community) will look into it and either add an exclusion or report it to the ClearURLs team
"""
KNOWN_BAD_FILTERS = [
@@ -135,9 +136,28 @@ def getrules() -> str:
RULES = "https://raw.githubusercontent.com/ClearURLs/Rules/master/data.min.json"
return requests.get(RULES).text
def haschanged() -> bool:
c = False
try:
hashes = json.loads(open("hash.txt").read())
except:
hashes = []
toph = hashlib.sha256(HEAD.encode()).hexdigest()
if toph not in hashes:
c = True
ruleshash = hashlib.sha256(getrules().encode()).hexdigest()
if ruleshash not in hashes:
c = True
with open("hash.txt","w") as rulesf:
rulesf.write(json.dumps([toph,ruleshash]))
rulesf.close()
return c
def main() -> int:
data_min_json = json.loads(getrules())
if haschanged() == False:
print("No change in rules. Exiting...")
sys.exit()
filterlist = open("clear_urls_uboified.txt", "w")
filterlist.write(HEAD.format(date=date.today().strftime("%d/%m/%Y")))
+1
View File
@@ -0,0 +1 @@
["ddfdb898086c2c8451f7ac7d596f0468f0efc5863c4d1a3e3496829ef15a62bf", "a02393e204e697dc1a40b7215ab6eaec85c5c217b381c89d6f46e832cd3d2398"]