diff options
Diffstat (limited to 'src/shared/script-injector.ts')
| -rw-r--r-- | src/shared/script-injector.ts | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/shared/script-injector.ts b/src/shared/script-injector.ts index 697c8d6..16cb17c 100644 --- a/src/shared/script-injector.ts +++ b/src/shared/script-injector.ts @@ -2,6 +2,15 @@ type DataType = { [key: string]: string }; +/** + * Injects a `<script>` element into the document head (or `<html>`) with + * the given `src` pointing to an extension resource. Optional key/value + * data is attached as `data-*` attributes so the injected script can + * read them via `document.currentScript`. + * + * @param src - The extension-relative script path. + * @param data - Optional key/value pairs to set as `data-*` attributes. + */ export function injectScriptHead(src: string, data: DataType = {}) { const s = document.createElement("script") as HTMLScriptElement; s.src = chrome.runtime.getURL(src); |
