From 8234acb45cd99fc7bcd99df7f71cac02845bb534 Mon Sep 17 00:00:00 2001 From: Arpit Chakladar <54011232+arpitchakladar@users.noreply.github.com> Date: Mon, 6 Feb 2023 22:50:20 +0530 Subject: Added the ability to add page specific scripts. --- .../create-manifest-webpack-plugin/index.js | 23 +++++++++++++++++----- src/manifest.json | 10 +++++----- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/config/webpack/plugins/create-manifest-webpack-plugin/index.js b/config/webpack/plugins/create-manifest-webpack-plugin/index.js index fade66d..5dac1b2 100644 --- a/config/webpack/plugins/create-manifest-webpack-plugin/index.js +++ b/config/webpack/plugins/create-manifest-webpack-plugin/index.js @@ -29,11 +29,24 @@ class CreateManifestPlugin { for (const scriptType in this.scripts) { if (Object.keys(this.scripts[scriptType]).length > 0) { - this.manifest.content_scripts.push({ - matches: ["https://banglarbhumi.gov.in/*", "http://banglarbhumi.gov.in/*"], - js: Object.keys(this.scripts[scriptType]).map(scriptName => `${scriptName}.js`), - run_at: scriptType - }); + const currentScripts = this.scripts[scriptType]; + + let paths = {}; + for (const scriptName in currentScripts) { + const scriptPath = currentScripts[scriptName]; + if (!path[scriptPath]) { + paths[scriptPath] = []; + } + paths[scriptPath].push(scriptName); + } + + for (const scriptPath in paths) { + this.manifest.content_scripts.push({ + matches: [`*://banglarbhumi.gov.in/${scriptPath}`], + js: paths[scriptPath].map(scriptName => `${scriptName}.js`), + run_at: scriptType + }); + } } } diff --git a/src/manifest.json b/src/manifest.json index b8930ae..397ec6e 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,15 +1,15 @@ { "before": { - "block-unnecessary": true + "block-unnecessary": "*" }, "injected": { - "stop-blocking": true + "stop-blocking": "*" }, "injected_and_loaded": { - "autofill-otps": true, - "auto-login": true + "autofill-otps": "*", + "auto-login": "*" }, "loaded": { - "autofill-captcha": true + "autofill-captcha": "*" } } -- cgit v1.2.3