From 45ae8b9766f1f67a22b322e5cde05b765e970914 Mon Sep 17 00:00:00 2001 From: yakshaG Date: Mon, 5 Aug 2024 19:54:15 +0530 Subject: [PATCH] Add backward compatible fix to handle new call end button HTML --- README.md | 2 +- extension/content.js | 35 +++++++++++++++++++++++------------ extension/manifest.json | 2 +- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 21742be..8816a8d 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Improve workplace communication by connecting Google Meet with Slack! **Google Meet ⇔ Slack automatically (Glack) updates your slack status in real time, when you join and exit meetings, even for unscheduled meetings or overflowing meetings.** -Extension status: 🟢 OPERATIONAL (v2.0.3 — degraded functionality for users who recieved new meet UI; fix in progress) +Extension status: 🟢 OPERATIONAL (v2.1.0) diff --git a/extension/content.js b/extension/content.js index 5f72ad4..64c5d8c 100644 --- a/extension/content.js +++ b/extension/content.js @@ -30,18 +30,14 @@ checkExtensionStatus().then(() => { joinKeyBoardShortcutListener(); exitKeyBoardShortcutListener(); + // 1. Meet UI prior to July/Aug 2024 checkElement(".google-material-icons", "call_end").then(() => { - console.log("Meeting started, setting Slack status") - chrome.runtime.sendMessage({ message: "Set status" }, function (response) { - console.log(response); - }); - - contains(".google-material-icons", "call_end")[0].parentElement.addEventListener("click", () => { - console.log("Meeting ended, clearing Slack status") - chrome.runtime.sendMessage({ message: "Clear status" }, function (response) { - console.log(response); - }); - }) + meetingRoutines(".google-material-icons", "call_end") + }) + + // 2. Meet UI post July/Aug 2024 + checkElement(".google-symbols", "call_end").then(() => { + meetingRoutines(".google-symbols", "call_end") }) } else { @@ -67,6 +63,21 @@ chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) { } }); +function meetingRoutines(selector, text) { + console.log("Meeting started, setting Slack status") + chrome.runtime.sendMessage({ message: "Set status" }, function (response) { + console.log(response); + }); + + // Event bubbling ensures this works for both cases 1 and 2. The node in case 2 is nested one level deeper than case 1. + contains(selector, text)[0].parentElement.parentElement.addEventListener("click", () => { + console.log("Meeting ended, clearing Slack status") + chrome.runtime.sendMessage({ message: "Clear status" }, function (response) { + console.log(response); + }); + }) +} + function joinKeyBoardShortcutListener() { document.addEventListener("keydown", function (event) { if ((event.ctrlKey || event.metaKey) && !(event.shiftKey) && (event.key.toLowerCase() === "v")) { @@ -84,7 +95,7 @@ function exitKeyBoardShortcutListener() { document.addEventListener("keydown", function (event) { if ((event.ctrlKey || event.metaKey) && (event.shiftKey) && (event.key.toLowerCase() === "v")) { if (contains("i", "call_end")[0]) - contains("i", "call_end")[0].parentElement.click(); + contains("i", "call_end")[0].click(); } }); } diff --git a/extension/manifest.json b/extension/manifest.json index c9c154c..5db2167 100644 --- a/extension/manifest.json +++ b/extension/manifest.json @@ -1,6 +1,6 @@ { "name": "Google Meet ⇔ Slack integration (Glack)", - "version": "2.0.3", + "version": "2.1.0", "manifest_version": 3, "description": "Real-time Google Meet status on Slack, just like Slack huddles.", "action": {