Skip to content

Commit

Permalink
Fix isOfficialClient (#2794)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
PurpShell authored Mar 1, 2024
1 parent ef2f725 commit a339199
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions tests/structures/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ describe('Group', function() {

describe('Leave / re-join', function () {
let code;

before(async function () {
code = await group.getInviteCode();
});
Expand Down

0 comments on commit a339199

Please sign in to comment.