InjectJsParams
Parameters passed to the injectJs handler.
Example
import { BrowserWindow, InjectJsParams } from '@mobrowser/api';
const win = new BrowserWindow()
win.browser.handle('injectJs', (params: InjectJsParams) => {
if (params.isMainFrame) {
return `console.log('Injecting JS for:', ${JSON.stringify(params.url)})`
}
return ''
})
win.browser.loadUrl('https://example.com')
Properties
url
readonly url: string;
The URL of the frame being navigated to.
For the main frame this is the page URL; for sub-frames it is the iframe’s src URL.
isMainFrame
readonly isMainFrame: boolean;
true when the handler is invoked for the top-level (main) frame,
otherwise false.