Skip to content

Commit

Permalink
Performance optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
typekcz committed Dec 22, 2023
1 parent 118ba25 commit f9e85b2
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/steam-api/steam-browser-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,34 @@ export default class SteamBrowserApi {
"--reduce-security-for-testing",
"--no-sandbox",
"--disable-setuid-sandbox",
"--incognito",
"--disable-site-isolation-for-policy",
"--allow-http-background-page",
// Optimizations
"--disable-site-isolation-trials",
"--wm-window-animations-disabled",
"--renderer-process-limit=1",
"--enable-low-end-device-mode",
"--single-process"
],
userDataDir: "./chromium-user-data"
});
this.frame = (await this.browser.pages())[0];
await this.loadCookies();
await this.frame.setRequestInterception(true);
this.frame.on("request", /** @type {(req: import("puppeteer/lib/cjs/puppeteer/api-docs-entry.js").HTTPRequest) => void} */
req => {
if(["image", "font"].includes(req.resourceType()))
req.abort();
else
req.continue();
}
);
await this.frame.setBypassCSP(true);
// Steam won't accept HeadlessChrome
let userAgent = await this.frame.evaluate(() => navigator.userAgent);
userAgent = userAgent.replace("HeadlessChrome", "Chrome");
await this.frame.setUserAgent(userAgent);
this.frame.on("console", msg => pageLogFiltered);
this.frame.on("pageerror", error => console.log("Page error:", error.message) );
this.frame.on("requestfailed", request => console.log("Page request failed:", request?.failure()?.errorText, request.url));

let dealWithCaptcha = new DealWithCaptcha(this.bb);
this.requestCaptchaSolution = (img) => dealWithCaptcha.getCaptchaSolution(img);
this.requestSteamGuardCode = new DealWithSteamGuard(this.bb);
Expand Down

0 comments on commit f9e85b2

Please sign in to comment.