From 675cd35e582527bd47953f6ac51608538b4d5d79 Mon Sep 17 00:00:00 2001 From: pliny <133052465+elder-plinius@users.noreply.github.com> Date: Sat, 12 Aug 2023 16:21:14 -0700 Subject: [PATCH] Update popup.js --- popup.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/popup.js b/popup.js index 592ecf3..40266a3 100644 --- a/popup.js +++ b/popup.js @@ -14,12 +14,17 @@ document.addEventListener('DOMContentLoaded', () => { }; playPauseButton.addEventListener('click', function() { - // Send a message to the background script to toggle play/pause chrome.runtime.sendMessage({action: 'togglePlayPause'}, (response) => { - if (response.status === 'playing') { - playPauseButton.textContent = 'Pause'; - } else { - playPauseButton.textContent = 'Play'; + if (chrome.runtime.lastError) { + console.error(chrome.runtime.lastError.message); + return; + } + if (response && response.status) { + if (response.status === 'playing') { + playPauseButton.textContent = 'Pause'; + } else { + playPauseButton.textContent = 'Play'; + } } }); });