diff --git a/src/Client.js b/src/Client.js index ca75e66ae3..c0c1db0640 100644 --- a/src/Client.js +++ b/src/Client.js @@ -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, diff --git a/tests/structures/group.js b/tests/structures/group.js index 6c47dd57e1..133ded6cf9 100644 --- a/tests/structures/group.js +++ b/tests/structures/group.js @@ -193,6 +193,7 @@ describe('Group', function() { describe('Leave / re-join', function () { let code; + before(async function () { code = await group.getInviteCode(); });