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, }))