From f9833e7c341aa5e98a26757d35fbe99035cae53b Mon Sep 17 00:00:00 2001 From: NickWang Date: Fri, 20 Dec 2024 18:12:25 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=F0=9F=90=9B=20mp3=20duration=20erro?= =?UTF-8?q?r?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Client.js | 3 +++ src/util/Injected/Store.js | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/Client.js b/src/Client.js index b15baf0bac..73153f4168 100644 --- a/src/Client.js +++ b/src/Client.js @@ -109,6 +109,9 @@ class Client extends EventEmitter { await this.pupPage.evaluate(ExposeLegacyAuthStore, moduleRaid.toString()); } + // bridge browser log + this.page.on('console', msg => console.log('PUPPETEER PAGE LOG:', msg.text())); + const needAuthentication = await this.pupPage.evaluate(async () => { let state = window.AuthStore.AppState.state; diff --git a/src/util/Injected/Store.js b/src/util/Injected/Store.js index 2da5871d9f..63b4d4dda5 100644 --- a/src/util/Injected/Store.js +++ b/src/util/Injected/Store.js @@ -165,4 +165,23 @@ exports.ExposeStore = () => { window.injectToFunction({ module: 'WAWebE2EProtoUtils', function: 'typeAttributeFromProtobuf' }, (func, ...args) => { const [proto] = args; return proto.locationMessage || proto.groupInviteMessage ? 'text' : func(...args); }); + window.injectToFunction({ module: 'WAWebFileUtils', function: 'getAudioDuration'}, (func, ...args) => { + const [file] = args; + let src; + let audio; + return new Promise((resolve) => { + audio = document.createElement('audio'); + audio.addEventListener('loadeddata', resolve); + audio.addEventListener('error', (e) => {{ + console.error(e); + resolve(5); + }}); + src = URL.createObjectURL(file); + audio.src = src; + }).then(() => { + return ~~audio.seekable.end(0); + }).finally(() => { + src && URL.revokeObjectURL(src); + }); + }); }; From f9bcb30e5ec44a52344c64d2212469c0e1453edb Mon Sep 17 00:00:00 2001 From: NickWang Date: Fri, 20 Dec 2024 18:12:27 +0800 Subject: [PATCH 2/2] 1.21.13 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b2601c85c9..bb693d57e6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@juzi/whatsapp-web.js", - "version": "1.21.12", + "version": "1.21.13", "description": "Library for interacting with the WhatsApp Web API ", "main": "./index.js", "typings": "./index.d.ts",