Fix isOfficialClient (#2794)
* fix(isOfficialClient): initial commit * fix(isOfficial): eslint my dear * chore: eslint my dear x2 * fix(isOfficial): make code more transparent * fix(isOfficial): missing await * fix(isOfficial): Obfuscate set to custom seed so maintainers can verify * feat(isOfficial): original code * chore: eslint
This commit is contained in:
parent
ef2f725bce
commit
a339199610
2 changed files with 15 additions and 0 deletions
|
|
@ -105,6 +105,8 @@ class Client extends EventEmitter {
|
|||
if(!browserArgs.find(arg => arg.includes('--user-agent'))) {
|
||||
browserArgs.push(`--user-agent=${this.options.userAgent}`);
|
||||
}
|
||||
// navigator.webdriver fix
|
||||
browserArgs.push('--disable-blink-features=AutomationControlled');
|
||||
|
||||
browser = await puppeteer.launch({...puppeteerOpts, args: browserArgs});
|
||||
page = (await browser.pages())[0];
|
||||
|
|
@ -123,6 +125,18 @@ class Client extends EventEmitter {
|
|||
await this.authStrategy.afterBrowserInitialized();
|
||||
await this.initWebVersionCache();
|
||||
|
||||
// ocVesion (isOfficialClient patch)
|
||||
await page.evaluateOnNewDocument(() => {
|
||||
const originalError = Error;
|
||||
//eslint-disable-next-line no-global-assign
|
||||
Error = function (message) {
|
||||
const error = new originalError(message);
|
||||
const originalStack = error.stack;
|
||||
if (error.stack.includes('moduleRaid')) error.stack = originalStack + '\n at https://web.whatsapp.com/vendors~lazy_loaded_low_priority_components.05e98054dbd60f980427.js:2:44';
|
||||
return error;
|
||||
};
|
||||
});
|
||||
|
||||
await page.goto(WhatsWebURL, {
|
||||
waitUntil: 'load',
|
||||
timeout: 0,
|
||||
|
|
|
|||
|
|
@ -193,6 +193,7 @@ describe('Group', function() {
|
|||
|
||||
describe('Leave / re-join', function () {
|
||||
let code;
|
||||
|
||||
before(async function () {
|
||||
code = await group.getInviteCode();
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue