|
|
@ -9,6 +9,10 @@ const Database = require("../database");
|
|
|
|
const jwt = require("jsonwebtoken");
|
|
|
|
const jwt = require("jsonwebtoken");
|
|
|
|
const config = require("../config");
|
|
|
|
const config = require("../config");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Cached instance of a browser
|
|
|
|
|
|
|
|
* @type {import ("playwright-core").Browser}
|
|
|
|
|
|
|
|
*/
|
|
|
|
let browser = null;
|
|
|
|
let browser = null;
|
|
|
|
|
|
|
|
|
|
|
|
let allowedList = [];
|
|
|
|
let allowedList = [];
|
|
|
@ -62,8 +66,15 @@ async function isAllowedChromeExecutable(executablePath) {
|
|
|
|
return allowedList.includes(executablePath);
|
|
|
|
return allowedList.includes(executablePath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Get the current instance of the browser. If there isn't one, create
|
|
|
|
|
|
|
|
* it.
|
|
|
|
|
|
|
|
* @returns {Promise<import ("playwright-core").Browser>} The browser
|
|
|
|
|
|
|
|
*/
|
|
|
|
async function getBrowser() {
|
|
|
|
async function getBrowser() {
|
|
|
|
if (!browser) {
|
|
|
|
if (browser && browser.isConnected()) {
|
|
|
|
|
|
|
|
return browser;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
let executablePath = await Settings.get("chromeExecutable");
|
|
|
|
let executablePath = await Settings.get("chromeExecutable");
|
|
|
|
|
|
|
|
|
|
|
|
executablePath = await prepareChromeExecutable(executablePath);
|
|
|
|
executablePath = await prepareChromeExecutable(executablePath);
|
|
|
@ -72,9 +83,10 @@ async function getBrowser() {
|
|
|
|
//headless: false,
|
|
|
|
//headless: false,
|
|
|
|
executablePath,
|
|
|
|
executablePath,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return browser;
|
|
|
|
return browser;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async function prepareChromeExecutable(executablePath) {
|
|
|
|
async function prepareChromeExecutable(executablePath) {
|
|
|
|
// Special code for using the playwright_chromium
|
|
|
|
// Special code for using the playwright_chromium
|
|
|
|