fixed an error where app wouldnt launch
This commit is contained in:
@@ -1,14 +1,44 @@
|
||||
const { chromium } = require("playwright-chromium");
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
const { chromium } = require("playwright-core");
|
||||
|
||||
let browser;
|
||||
let context;
|
||||
const BLOCK_LIST = [
|
||||
"google-analytics", "doubleclick", "facebook", "twitter",
|
||||
"adsystem", "analytics", "tracker", "pixel", "quantserve", "newrelic"
|
||||
];
|
||||
|
||||
function isPackaged() {
|
||||
return process.env.IS_PACKAGED === "true";
|
||||
}
|
||||
|
||||
function getChromiumPath() {
|
||||
if (isPackaged()) {
|
||||
return path.join(
|
||||
process.resourcesPath,
|
||||
"playwright",
|
||||
"chromium",
|
||||
"chrome-headless-shell-win64",
|
||||
"chrome-headless-shell.exe"
|
||||
);
|
||||
}
|
||||
|
||||
return chromium.executablePath();
|
||||
}
|
||||
|
||||
async function initHeadless() {
|
||||
if (browser) return;
|
||||
|
||||
const exePath = getChromiumPath();
|
||||
|
||||
if (!fs.existsSync(exePath)) {
|
||||
throw new Error("Chromium not found: " + exePath);
|
||||
}
|
||||
|
||||
browser = await chromium.launch({
|
||||
headless: true,
|
||||
executablePath: exePath,
|
||||
args: [
|
||||
"--no-sandbox",
|
||||
"--disable-setuid-sandbox",
|
||||
|
||||
Reference in New Issue
Block a user