aboutsummaryrefslogtreecommitdiffstats
path: root/config/webpack/utils/script-runtime.js
diff options
context:
space:
mode:
Diffstat (limited to 'config/webpack/utils/script-runtime.js')
-rw-r--r--config/webpack/utils/script-runtime.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/config/webpack/utils/script-runtime.js b/config/webpack/utils/script-runtime.js
index a7c02f7..1c23922 100644
--- a/config/webpack/utils/script-runtime.js
+++ b/config/webpack/utils/script-runtime.js
@@ -1,3 +1,14 @@
+/**
+ * Maps a human-readable script type to a Chrome content-script
+ * `run_at` value.
+ *
+ * - `"before"`, `"injected-after"`, `"injected-before"` → `document_start`
+ * - `"rendered"` → `document_end`
+ * - `"loaded"` (or unknown) → `document_idle`
+ *
+ * @param {string} scriptType - The script type from scripts.json.
+ * @returns {string} The corresponding `run_at` value.
+ */
export const getScriptRuntimeFromType = scriptType => {
switch (scriptType) {
case "before":