From dc172e68b0add601348b1a0643fe2c29c7ef4799 Mon Sep 17 00:00:00 2001 From: Karem Date: Sun, 28 Jun 2026 03:54:00 +0300 Subject: [PATCH] feat(calls): expose a minimal window.chrome so WhatsApp enables call buttons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit WhatsApp Web disables the voice/video call buttons unless it considers the environment an eligible Chrome/Edge browser. The UA and navigator.userAgentData already report Chrome 131, but the calling-eligibility check also probes for `window.chrome`, which WebKitGTK does not expose — so the call buttons stay greyed even though this WebKitGTK build (2.52) ships WebRTC and the app already enables it + auto-grants mic/camera. Add a minimal, idempotent `window.chrome = { app:{isInstalled:false}, runtime:{} }` stand-in (section 1b in bridge.js), matching what a real Chrome minimally exposes. It is origin-guarded, wrapped in its own try/catch, and never clobbers a genuine window.chrome. Verified in a real WebKitGTK engine (origin spoofed to web.whatsapp.com): window.chrome becomes an object with runtime + app.isInstalled===false when absent; a pre-existing window.chrome is preserved; the userAgentData and Notification shims are unaffected. NOTE: whether the call button actually un-greys can only be confirmed on a logged-in WhatsApp — see the PR's human-test gate. If it is still disabled, the next lever is WebRTC codec availability (H264/VP8) in this WebKitGTK build (backlog C2). Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_016o9cWBaPy4zU4BAurUVoTp --- src-tauri/resources/bridge.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src-tauri/resources/bridge.js b/src-tauri/resources/bridge.js index 924a019..c9340dc 100644 --- a/src-tauri/resources/bridge.js +++ b/src-tauri/resources/bridge.js @@ -38,6 +38,23 @@ } } catch (e) {} + // 1b) Chrome environment marker — enables voice/video CALLING. WhatsApp Web gates + // calling behind a Chrome/Edge eligibility check that, beyond the UA and + // userAgentData (both already spoofed above), probes for `window.chrome`. WebKitGTK + // ships WebRTC (so calls CAN work once eligible) but exposes no `window.chrome`, so + // the call buttons stay disabled. Add a minimal, idempotent stand-in matching what a + // real Chrome minimally exposes; never clobber a genuine `window.chrome`. + try { + if (!window.chrome) { + Object.defineProperty(window, "chrome", { + configurable: true, + enumerable: true, + writable: true, + value: { app: { isInstalled: false }, runtime: {} }, + }); + } + } catch (e) {} + // 2) Notification override — forward to a native OS notification via Rust. try { function ShimNotification(title, options) {