aboutsummaryrefslogtreecommitdiff
path: root/mkconfig.py
blob: ad04413a83af0597fd7504709b7da5cef38330d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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('.', '**', '*.user.js'), recursive=True)

# zipp
with zipfile.ZipFile("violentmonkey.zip", 'w', zipfile.ZIP_DEFLATED) as zipf:
    for path in paths:
        zipf.write(path, arcname=os.path.basename(path))
    zipf.writestr("violentmonkey", json.dumps({
        "scripts": { os.path.basename(path).removesuffix(".user.js"): {} for path in paths },
        "settings": settings,
    }))