main: remove onLoad
This commit is contained in:
parent
0986f59eff
commit
420ffbdaa4
16
src/index.js
16
src/index.js
@ -245,7 +245,7 @@ const checkForDangerousOptions = ({ allowHTTP, allowNavigation }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const open = async (url, opts = {}) => {
|
export const open = async (url, opts = {}) => {
|
||||||
const { onLoad, allowHTTP = false } = opts;
|
const { allowHTTP = false } = opts;
|
||||||
|
|
||||||
if (allowHTTP !== true && url.startsWith('http://')) throw new Error(`HTTP URLs are blocked by default. Please use HTTPS, or if not possible, enable the 'allowHTTP' option.`);
|
if (allowHTTP !== true && url.startsWith('http://')) throw new Error(`HTTP URLs are blocked by default. Please use HTTPS, or if not possible, enable the 'allowHTTP' option.`);
|
||||||
|
|
||||||
@ -254,20 +254,6 @@ export const open = async (url, opts = {}) => {
|
|||||||
|
|
||||||
const Browser = await startBrowser(url, getParentDir(), opts);
|
const Browser = await startBrowser(url, getParentDir(), opts);
|
||||||
|
|
||||||
if (onLoad) {
|
|
||||||
const toRun = `(() => {
|
|
||||||
if (window.self !== window.top) return; // inside frame
|
|
||||||
|
|
||||||
(${onLoad.toString()})();
|
|
||||||
})();`;
|
|
||||||
|
|
||||||
Browser.page.eval(toRun);
|
|
||||||
|
|
||||||
await Browser.cdp.send(`Page.addScriptToEvaluateOnNewDocument`, {
|
|
||||||
source: toRun
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return Browser;
|
return Browser;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user