From ecdbd412bc3e2e4fddd490ddf83cd277465c3bee Mon Sep 17 00:00:00 2001 From: AAABBBCCCAAAA Date: Wed, 19 Jan 2022 20:35:59 +0100 Subject: [PATCH] fix for #37 --- script.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/script.js b/script.js index d5a06dd9..7433a649 100644 --- a/script.js +++ b/script.js @@ -116,9 +116,14 @@ addOneMinute = () => { }; let addOneMinuteInterval; +let currentState = ''; handleMessage = (request) => { if ('start' === request.action) { + if ( currentState === request.action ) { + return; + } + currentState = request.action; setBrowserIcon('on'); chrome.webRequest.onHeadersReceived.addListener( @@ -140,9 +145,11 @@ handleMessage = (request) => { } return; - } - - if ('stop' === request.action) { + } else if ('stop' === request.action) { + if ( currentState === request.action ) { + return; + } + currentState = request.action; setBrowserIcon('off'); chrome.webRequest.onHeadersReceived.removeListener(headersReceivedListener); chrome.downloads.onCreated.removeListener(downloadCompletedCheckLoop);