From 79f1f2e5e4a7c574fde8d9c45ac0da271be5422f Mon Sep 17 00:00:00 2001 From: Cleiton Carvalho Date: Wed, 27 Mar 2024 21:14:38 -0300 Subject: [PATCH] fix: Fixed injecting webpack (#1783) (close #1778) --- src/tools/browser.ts | 2 +- src/webpack/index.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/tools/browser.ts b/src/tools/browser.ts index a19a80a7a3..2b6ec0faa0 100644 --- a/src/tools/browser.ts +++ b/src/tools/browser.ts @@ -127,7 +127,7 @@ export async function preparePage(page: playwright.Page) { }, 500); }); - page.on('domcontentloaded', async (page) => { + page.on('load', async (page) => { await page.addScriptTag({ url: `${URL}dist/wppconnect-wa.js`, }); diff --git a/src/webpack/index.ts b/src/webpack/index.ts index 9b14cc0bde..f763b71b25 100644 --- a/src/webpack/index.ts +++ b/src/webpack/index.ts @@ -14,6 +14,7 @@ * limitations under the License. */ +import { compare } from 'compare-versions'; import Debug from 'debug'; import { internalEv } from '../eventEmitter'; @@ -159,8 +160,8 @@ export function injectLoader(): void { const chunkName = 'webpackChunkwhatsapp_web_client'; const chunk = global[chunkName] || []; - if (typeof global[chunkName] === 'undefined') { - global[chunkName] = chunk; + if (compare(self.Debug.VERSION, '2.3000.0', '>=')) { + Object.defineProperty(global, chunkName, chunk); } else { loaderType = 'webpack'; }