From 3f281a9e5ed725050e4f7ae05d740fb78ea42a72 Mon Sep 17 00:00:00 2001 From: Arpit Chakladar Date: Thu, 13 Aug 2026 21:21:02 +0530 Subject: refactor: using python scripts for preparing extensions for chromium --- .../chromium/extensions/inject_extension_key.py | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 modules/web/chromium/extensions/inject_extension_key.py (limited to 'modules/web/chromium/extensions/inject_extension_key.py') diff --git a/modules/web/chromium/extensions/inject_extension_key.py b/modules/web/chromium/extensions/inject_extension_key.py new file mode 100644 index 0000000..f1b7055 --- /dev/null +++ b/modules/web/chromium/extensions/inject_extension_key.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 +import json +import re +import sys + +manifest_path = sys.argv[1] +ext_key = sys.argv[2] + +with open(manifest_path, "r", encoding="utf-8", errors="ignore") as f: + content = f.read() + +pattern = r"(\"[^\"]*?\")|//.*?$|/\*.*?\*/" +clean = re.sub( + pattern, + lambda m: m.group(1) if m.group(1) else "", + content, + flags=re.DOTALL | re.MULTILINE, +) + +clean = re.sub(r",\s*([\]}])", r"\1", clean) + +data = json.loads(clean) +data["key"] = ext_key + +with open(manifest_path, "w", encoding="utf-8") as f: + json.dump(data, f, indent=2) -- cgit v1.2.3