#!/usr/bin/env python3 """Build a Chrome/Chromium Manifest V3 zip without changing the Firefox tree.""" from pathlib import Path import json import shutil import tempfile import zipfile ROOT = Path(__file__).resolve().parent.parent OUTPUT = ROOT / "web-ext-artifacts" / "proxyswitcherforkbywt-chrome.zip" FILES = [ "background-chrome.js", "background-service-worker.js", "browser-api.js", "config-manager.js", "options.css", "options.html", "options.js", "popup.css", "popup.html", "popup.js", ] def main(): OUTPUT.parent.mkdir(exist_ok=True) with tempfile.TemporaryDirectory() as temp: staging = Path(temp) manifest = json.loads((ROOT / "manifest.chrome.json").read_text()) (staging / "manifest.json").write_text(json.dumps(manifest, indent=2) + "\n") for name in FILES: shutil.copy2(ROOT / name, staging / name) shutil.copytree(ROOT / "icons", staging / "icons") if OUTPUT.exists(): OUTPUT.unlink() with zipfile.ZipFile(OUTPUT, "w", zipfile.ZIP_DEFLATED) as archive: for path in sorted(staging.rglob("*")): if path.is_file(): archive.write(path, path.relative_to(staging)) print(OUTPUT) if __name__ == "__main__": main()