Skip to content

Commit

Permalink
fix for carbonalyser#37
Browse files Browse the repository at this point in the history
  • Loading branch information
AAABBBCCCAAAA committed Jan 19, 2022
1 parent 29e6b5c commit ecdbd41
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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);
Expand Down

0 comments on commit ecdbd41

Please sign in to comment.