From 5dd17fe3c88d8543cbff634116d76f1fb1692faf Mon Sep 17 00:00:00 2001 From: Tim Keller Date: Sun, 17 Nov 2024 20:48:17 -0600 Subject: add mkconfig.py script to generate violentmonkey zip --- mkconfig.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 mkconfig.py (limited to 'mkconfig.py') diff --git a/mkconfig.py b/mkconfig.py new file mode 100644 index 0000000..47cc0ee --- /dev/null +++ b/mkconfig.py @@ -0,0 +1,25 @@ +import json +import os +import glob +import zipfile + +# handle settings +settings = {} +if os.path.isfile("settings.json"): + with open("settings.json", 'r') as f: + settings = json.load(f) + +# get all userscripts +paths = glob.glob(os.path.join('.', '**', '*.js'), recursive=True) +paths = [ path.removesuffix(".js") for path in paths ] + +# zipp +with zipfile.ZipFile("violentmonkey.zip", 'w', zipfile.ZIP_DEFLATED) as zipf: + for path in paths: + arcname = os.path.basename(path) + ".user.js" # basename and add .user.js suffix + path += ".js" + zipf.write(path, arcname=arcname) + zipf.writestr("violentmonkey", json.dumps({ + "scripts": { os.path.basename(path): {} for path in paths }, + "settings": settings, + })) -- cgit v1.2.3