mirror of
https://github.com/webrecorder/browsertrix-crawler.git
synced 2025-10-19 06:23:16 +00:00
add default args
This commit is contained in:
parent
7c8200b7d1
commit
0e415e1d7a
1 changed files with 47 additions and 5 deletions
|
@ -58,10 +58,6 @@ export class Browser
|
|||
}
|
||||
}
|
||||
|
||||
async getFirstPageWithCDP() {
|
||||
return {page: this.firstPage, cdp: this.firstCDP};
|
||||
}
|
||||
|
||||
async loadProfile(profileFilename) {
|
||||
const targetFilename = "/tmp/profile.tar.gz";
|
||||
|
||||
|
@ -108,6 +104,7 @@ export class Browser
|
|||
chromeArgs({proxy=true, userAgent=null, extraArgs=[]} = {}) {
|
||||
// Chrome Flags, including proxy server
|
||||
const args = [
|
||||
...defaultArgs,
|
||||
...(process.env.CHROME_FLAGS ?? "").split(" ").filter(Boolean),
|
||||
//"--no-xshm", // needed for Chrome >80 (check if puppeteer adds automatically)
|
||||
"--no-sandbox",
|
||||
|
@ -360,6 +357,10 @@ export class PersistentContextBrowser extends PlaywrightBrowser
|
|||
this.firstCDP = null;
|
||||
}
|
||||
|
||||
async getFirstPageWithCDP() {
|
||||
return {page: this.firstPage, cdp: this.firstCDP};
|
||||
}
|
||||
|
||||
isLaunched() {
|
||||
if (this.context) {
|
||||
logger.warn("Context already inited", {}, "context");
|
||||
|
@ -438,8 +439,12 @@ export class PuppeteerPersistentContextBrowser extends Browser
|
|||
super();
|
||||
this.browser = null;
|
||||
|
||||
this.firstPage = null;
|
||||
this.firstCDP = null;
|
||||
this.firstPage = null;
|
||||
}
|
||||
|
||||
async getFirstPageWithCDP() {
|
||||
return {page: this.firstPage, cdp: this.firstCDP};
|
||||
}
|
||||
|
||||
isLaunched() {
|
||||
|
@ -478,6 +483,7 @@ export class PuppeteerPersistentContextBrowser extends Browser
|
|||
const target = this.browser.target();
|
||||
|
||||
this.firstCDP = await target.createCDPSession();
|
||||
this.firstPage = await target.page();
|
||||
}
|
||||
|
||||
numPages() {
|
||||
|
@ -531,3 +537,39 @@ export class PuppeteerPersistentContextBrowser extends Browser
|
|||
return await this.evaluateWithCLI_(cdp, frame, cdpContextId, funcString, logData, contextName);
|
||||
}
|
||||
}
|
||||
|
||||
export const defaultArgs = [
|
||||
"--disable-field-trial-config", // https://source.chromium.org/chromium/chromium/src/+/main:testing/variations/README.md
|
||||
"--disable-background-networking",
|
||||
"--enable-features=NetworkService,NetworkServiceInProcess",
|
||||
"--disable-background-timer-throttling",
|
||||
"--disable-backgrounding-occluded-windows",
|
||||
"--disable-back-forward-cache", // Avoids surprises like main request not being intercepted during page.goBack().
|
||||
"--disable-breakpad",
|
||||
"--disable-client-side-phishing-detection",
|
||||
"--disable-component-extensions-with-background-pages",
|
||||
"--disable-component-update", // Avoids unneeded network activity after startup.
|
||||
"--no-default-browser-check",
|
||||
"--disable-default-apps",
|
||||
"--disable-dev-shm-usage",
|
||||
"--disable-extensions",
|
||||
// AvoidUnnecessaryBeforeUnloadCheckSync - https://github.com/microsoft/playwright/issues/14047
|
||||
// Translate - https://github.com/microsoft/playwright/issues/16126
|
||||
"--disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBeforeUnloadCheckSync,Translate",
|
||||
"--allow-pre-commit-input",
|
||||
"--disable-hang-monitor",
|
||||
"--disable-ipc-flooding-protection",
|
||||
"--disable-popup-blocking",
|
||||
"--disable-prompt-on-repost",
|
||||
"--disable-renderer-backgrounding",
|
||||
"--disable-sync",
|
||||
"--force-color-profile=srgb",
|
||||
"--metrics-recording-only",
|
||||
"--no-first-run",
|
||||
"--enable-automation",
|
||||
"--password-store=basic",
|
||||
"--use-mock-keychain",
|
||||
// See https://chromium-review.googlesource.com/c/chromium/src/+/2436773
|
||||
"--no-service-autorun",
|
||||
"--export-tagged-pdf"
|
||||
];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue