aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArpit Chakladar <arpitchakladar@gmail.com>2026-09-29 21:36:50 +0530
committerArpit Chakladar <arpitchakladar@gmail.com>2026-09-29 21:36:50 +0530
commitfb74d5fcaa948f6a37f9fd0573794912d8948c19 (patch)
treeffe5c764e1dbe15573cd46d19440885fce142e9b
parent9a4ff431ae2d9788de80bad243fb055cd488e6ac (diff)
downloadbanglar-bhumi-utils-fb74d5fcaa948f6a37f9fd0573794912d8948c19.tar.gz
banglar-bhumi-utils-fb74d5fcaa948f6a37f9fd0573794912d8948c19.zip
ci(config): fix manifest for firefox mv3 compatibility
-rw-r--r--config/webpack/plugins/create-manifest-webpack-plugin/index.js23
-rw-r--r--config/webpack/plugins/create-manifest-webpack-plugin/manifest-template.json6
2 files changed, 25 insertions, 4 deletions
diff --git a/config/webpack/plugins/create-manifest-webpack-plugin/index.js b/config/webpack/plugins/create-manifest-webpack-plugin/index.js
index e28c695..99feb58 100644
--- a/config/webpack/plugins/create-manifest-webpack-plugin/index.js
+++ b/config/webpack/plugins/create-manifest-webpack-plugin/index.js
@@ -7,6 +7,13 @@ import { getFileName } from "../../utils/build-file.js";
import { getScriptRuntimeFromType } from "../../utils/script-runtime.js";
import scripts from "../../utils/scripts.js";
+/** The only host this extension ever touches, used for every match pattern. */
+const SITE_HOST = "banglarbhumi.gov.in";
+/** Site-wide access: covers `web_accessible_resources` and `host_permissions`. */
+const SITE_MATCH = `*://${SITE_HOST}/*`;
+/** The application section of the site, where every content script runs. */
+const APP_MATCH = `*://${SITE_HOST}/BanglarBhumi/*`;
+
const manifest = JSON.parse(
fs.readFileSync(
path.resolve("config/webpack/plugins/create-manifest-webpack-plugin/manifest-template.json")
@@ -21,6 +28,10 @@ const manifest = JSON.parse(
* page URL patterns. Shared modules, injected scripts, and
* web-accessible resources are added automatically based on import
* counts collected during the build.
+ *
+ * Every generated pattern is scoped to {@link SITE_HOST}: match patterns
+ * allow a single trailing `*` in the path, so the `"*"` script path maps to
+ * {@link APP_MATCH} rather than the invalid `BanglarBhumi/**`.
*/
class CreateManifestPlugin {
/**
@@ -72,7 +83,7 @@ class CreateManifestPlugin {
}
manifest.content_scripts.push({
- matches: ["*://banglarbhumi.gov.in/BanglarBhumi/*"],
+ matches: [APP_MATCH],
js: this.sortedSharedModules
.filter((sharedModule) => this.sharedModulesImportedCount[sharedModule] > 0)
.map((sharedModule) => `shared/${getFileName(sharedModule, "shared")}.js`)
@@ -84,10 +95,14 @@ class CreateManifestPlugin {
delete arrangedScripts["*"]["document_start"];
for (const scriptPath in arrangedScripts) {
- const matches = [`*://banglarbhumi.gov.in/BanglarBhumi/${scriptPath}*`];
+ // Match patterns allow at most one trailing `*`, so `"*"` cannot
+ // be interpolated into the path the way a literal segment can.
+ const matches = [scriptPath === "*"
+ ? APP_MATCH
+ : `*://${SITE_HOST}/BanglarBhumi/${scriptPath}*`];
if (scriptPath === "Home")
- matches.push(`*://banglarbhumi.gov.in/BanglarBhumi/${scriptPath}.action*`);
+ matches.push(`*://${SITE_HOST}/BanglarBhumi/${scriptPath}.action*`);
for (const scriptRuntime in arrangedScripts[scriptPath]) {
manifest.content_scripts.push({
@@ -125,7 +140,7 @@ class CreateManifestPlugin {
manifest.web_accessible_resources = [
{
resources,
- matches: ["<all_urls>"]
+ matches: [SITE_MATCH]
}
];
}
diff --git a/config/webpack/plugins/create-manifest-webpack-plugin/manifest-template.json b/config/webpack/plugins/create-manifest-webpack-plugin/manifest-template.json
index ca5fa7b..cc72d02 100644
--- a/config/webpack/plugins/create-manifest-webpack-plugin/manifest-template.json
+++ b/config/webpack/plugins/create-manifest-webpack-plugin/manifest-template.json
@@ -2,6 +2,12 @@
"manifest_version": 3,
"name": "Banglar Bhumi Utils",
"permissions": ["scripting", "declarativeNetRequest"],
+ "host_permissions": ["*://banglarbhumi.gov.in/*"],
+ "browser_specific_settings": {
+ "gecko": {
+ "id": "banglar-bhumi-utils@arpitchakladar.github.io"
+ }
+ },
"description": "A chrome extension to improve functionality of the banglarbhumi.gov.in website.",
"icons": {
"512": "icon512.png"