From 8d09fea648cd41e410878d6acb25081d39f41c7a Mon Sep 17 00:00:00 2001 From: Joey Parrish Date: Thu, 11 Nov 2021 16:07:57 -0800 Subject: [PATCH] fix: Fix log window focus Without a popup, we can just directly open the window from the background script. In this context, we have permission to focus a window. Fixes #23 Change-Id: I572c71fb65a9b5ac71e9d6afd1d04cefbe650eed --- log-window.js | 18 ++++++++++++------ log.html | 1 + manifest.json | 3 +-- popup.html | 20 -------------------- popup.js | 30 ------------------------------ 5 files changed, 14 insertions(+), 58 deletions(-) delete mode 100644 popup.html delete mode 100644 popup.js diff --git a/log-window.js b/log-window.js index 2419c59..d7bbb1b 100644 --- a/log-window.js +++ b/log-window.js @@ -267,9 +267,15 @@ function prettyPrint(obj, indentation = '') { * Listens for messages from the content script to append a log item to the * current frame and log file. */ -if (chrome.runtime) { - chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { - const log = request.log; - EmeLogWindow.instance.appendLog(log); - }); -} +chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { + const log = request.log; + EmeLogWindow.instance.appendLog(log); +}); + +/** + * When the extension icon is clicked, open the log window if it doesn't exist, + * and bring it to the front otherwise. + */ +chrome.browserAction.onClicked.addListener((tab) => { + EmeLogWindow.instance.open(); +}); diff --git a/log.html b/log.html index 9c0469b..ddef08c 100644 --- a/log.html +++ b/log.html @@ -15,6 +15,7 @@ --> + EME Logger