aboutsummaryrefslogtreecommitdiff
path: root/mkconfig.py
diff options
context:
space:
mode:
authorTim Keller <tjkeller.xyz>2024-11-17 20:48:17 -0600
committerTim Keller <tjkeller.xyz>2024-11-17 20:48:17 -0600
commit5dd17fe3c88d8543cbff634116d76f1fb1692faf (patch)
treeb29fd0725d405ce64a5849758c66749c8231b644 /mkconfig.py
parent1299cc3ad20614e6396e71af75b6d19c08567aff (diff)
downloaduserscripts-5dd17fe3c88d8543cbff634116d76f1fb1692faf.tar.xz
userscripts-5dd17fe3c88d8543cbff634116d76f1fb1692faf.zip
add mkconfig.py script to generate violentmonkey zip
Diffstat (limited to 'mkconfig.py')
-rw-r--r--mkconfig.py25
1 files changed, 25 insertions, 0 deletions
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,
+ }))