Spaces:
Build error
Build error
puppeteer: tweak the ua a bit
Browse files
backend/functions/src/services/puppeteer.ts
CHANGED
|
@@ -466,6 +466,7 @@ export class PuppeteerControl extends AsyncService {
|
|
| 466 |
livePages = new Set<Page>();
|
| 467 |
pagePhase = new WeakMap<Page, 'idle' | 'active' | 'background'>();
|
| 468 |
lastPageCratedAt: number = 0;
|
|
|
|
| 469 |
|
| 470 |
rpsCap: number = 500;
|
| 471 |
lastReqSentAt: number = 0;
|
|
@@ -527,7 +528,8 @@ export class PuppeteerControl extends AsyncService {
|
|
| 527 |
}
|
| 528 |
process.nextTick(() => this.serviceReady());
|
| 529 |
});
|
| 530 |
-
this.
|
|
|
|
| 531 |
|
| 532 |
this.emit('ready');
|
| 533 |
|
|
@@ -566,6 +568,7 @@ export class PuppeteerControl extends AsyncService {
|
|
| 566 |
}
|
| 567 |
const preparations = [];
|
| 568 |
|
|
|
|
| 569 |
// preparations.push(page.setUserAgent(`Slackbot-LinkExpanding 1.0 (+https://api.slack.com/robots)`));
|
| 570 |
// preparations.push(page.setUserAgent(`Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; GPTBot/1.0; +https://openai.com/gptbot)`));
|
| 571 |
preparations.push(page.setBypassCSP(true));
|
|
|
|
| 466 |
livePages = new Set<Page>();
|
| 467 |
pagePhase = new WeakMap<Page, 'idle' | 'active' | 'background'>();
|
| 468 |
lastPageCratedAt: number = 0;
|
| 469 |
+
ua: string = '';
|
| 470 |
|
| 471 |
rpsCap: number = 500;
|
| 472 |
lastReqSentAt: number = 0;
|
|
|
|
| 528 |
}
|
| 529 |
process.nextTick(() => this.serviceReady());
|
| 530 |
});
|
| 531 |
+
this.ua = await this.browser.userAgent();
|
| 532 |
+
this.logger.info(`Browser launched: ${this.browser.process()?.pid}, ${this.ua}`);
|
| 533 |
|
| 534 |
this.emit('ready');
|
| 535 |
|
|
|
|
| 568 |
}
|
| 569 |
const preparations = [];
|
| 570 |
|
| 571 |
+
preparations.push(page.setUserAgent(this.ua.replace(/Headless/i, '')));
|
| 572 |
// preparations.push(page.setUserAgent(`Slackbot-LinkExpanding 1.0 (+https://api.slack.com/robots)`));
|
| 573 |
// preparations.push(page.setUserAgent(`Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; GPTBot/1.0; +https://openai.com/gptbot)`));
|
| 574 |
preparations.push(page.setBypassCSP(true));
|