import os import zipfile import shutil import json def create_zip(source_dir, output_filename, manifest_filename='manifest.json'): with zipfile.ZipFile(output_filename, 'w', zipfile.ZIP_DEFLATED) as zipf: for root, dirs, files in os.walk(source_dir): for file in files: if file.startswith('manifest') and file.endswith('.json'): continue file_path = os.path.join(root, file) arcname = os.path.relpath(file_path, source_dir) zipf.write(file_path, arcname) manifest_path = os.path.join(source_dir, manifest_filename) zipf.write(manifest_path, 'manifest.json') def main(): if os.path.exists('release'): shutil.rmtree('release') os.makedirs('release') # Userscript shutil.copy('userscript.js', 'release/ely-userscript.user.js') # Chrome Extension (Manifest V3) create_zip('chrome-extension', 'release/ely-extension-chrome.zip', 'manifest-v3.json') # Firefox Extension (Manifest V2) create_zip('chrome-extension', 'release/ely-extension-firefox.zip', 'manifest-firefox.json') print("Build complete in /release folder.") if __name__ == "__main__": main()