aboutsummaryrefslogtreecommitdiffstats
path: root/modules/web/chromium/patch_native_host.py
diff options
context:
space:
mode:
Diffstat (limited to 'modules/web/chromium/patch_native_host.py')
-rw-r--r--modules/web/chromium/patch_native_host.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/modules/web/chromium/patch_native_host.py b/modules/web/chromium/patch_native_host.py
new file mode 100644
index 0000000..38afb44
--- /dev/null
+++ b/modules/web/chromium/patch_native_host.py
@@ -0,0 +1,21 @@
+#!/usr/bin/env python3
+import argparse
+import json
+
+parser = argparse.ArgumentParser(
+ description="Set allowed_origins in a native messaging host manifest"
+)
+parser.add_argument("extension_id", help="Chrome extension ID")
+parser.add_argument("input", help="Path to the input JSON manifest")
+parser.add_argument("output", help="Path to write the patched JSON manifest")
+args = parser.parse_args()
+
+with open(args.input) as f:
+ manifest = json.load(f)
+
+origin = f"chrome-extension://{args.extension_id}/"
+manifest["allowed_origins"] = [origin]
+
+with open(args.output, "w") as f:
+ json.dump(manifest, f, indent=2)
+ f.write("\n")