diff --git a/packages/wxt/src/utils/content-script-ui/iframe.ts b/packages/wxt/src/utils/content-script-ui/iframe.ts index 65968ea38..11f1b84c3 100644 --- a/packages/wxt/src/utils/content-script-ui/iframe.ts +++ b/packages/wxt/src/utils/content-script-ui/iframe.ts @@ -23,6 +23,7 @@ export function createIframeUi( let mounted: TMounted | undefined = undefined; const mount = () => { applyPosition(wrapper, iframe, options); + options.onBeforeMount?.(wrapper, iframe); mountUi(wrapper, options); mounted = options.onMount?.(wrapper, iframe); }; @@ -73,4 +74,9 @@ export type IframeContentScriptUiOptions = * Optionally return a value that can be accessed at `ui.mounted` or in the `onRemove` callback. */ onMount?: (wrapper: HTMLElement, iframe: HTMLIFrameElement) => TMounted; + /** + * Callback executed before mounting the UI. Use this function to customize the iframe or wrapper + * elements before they are injected into the DOM. It is called every time `ui.mount()` is called. + */ + onBeforeMount?: (wrapper: HTMLElement, iframe: HTMLIFrameElement) => void; };