Overview
Theauto module automatically injects the Wormkey overlay script into your application when imported. It detects the overlay script URL from a meta tag or global variable and loads it without requiring manual setup.
Installation
Usage
Basic Import
Simply import the module in your application entry point:Provide Script URL via Meta Tag
Add a meta tag to your HTML with the overlay script URL:Provide Script URL via Global Variable
Alternatively, set the script URL on the window object:API Reference
auto(scriptUrl?: string): boolean
Injects the Wormkey overlay script into the document.
Optional script URL. If not provided, the function will attempt to read from:
window.__WORMKEY_OVERLAY_URL__<meta name="wormkey-overlay-url">content attribute
Returns
boolean - Returns true if the script was injected or already exists, false if no script URL was found or if running in a non-browser environment.
Behavior
- Automatically executes when the module is imported
- Checks if the script is already loaded to avoid duplicates
- Creates a
<script>tag withdeferattribute - Adds
data-wormkey-overlay="1"attribute for identification - Appends the script to
document.head - Returns
falseifdocumentis undefined (server-side rendering)
URL Priority
The script URL is resolved in the following order:scriptUrlparameter (if callingauto()directly)window.__WORMKEY_OVERLAY_URL__<meta name="wormkey-overlay-url" content="...">attribute
Example
TypeScript
The module extends the globalWindow interface: