main: remove onLoad

This commit is contained in:
CanadaHonk 2023-04-05 15:55:17 +01:00
parent 0986f59eff
commit 420ffbdaa4

View File

@ -245,7 +245,7 @@ const checkForDangerousOptions = ({ allowHTTP, allowNavigation }) => {
};
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.`);
@ -254,20 +254,6 @@ export const open = async (url, 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;
};