From 40ef21e792512067fcf25d203913f672e9bb7711 Mon Sep 17 00:00:00 2001 From: Sav22999 Date: Wed, 13 Sep 2023 01:00:34 +0200 Subject: [PATCH] 2.0.1 - When the browser lost focus (or minimized) the timer has been paused --- .DS_Store | Bin 8196 -> 8196 bytes js/background.js | 16 +++++++++++++++- manifest.json | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.DS_Store b/.DS_Store index 4d5997ba1b56bdbef1b7dabf7414780d6ee4e92a..eb666dcd8078a2a206e2c022b3315a362429e7a9 100644 GIT binary patch delta 18 ZcmZp1XmQw3Bf@Ajd4quc<~<@F+yFpO24nyL delta 18 ZcmZp1XmQw3Bf@And4quc<~<@F+yFpE24esK diff --git a/js/background.js b/js/background.js index fe0a35f..b92d054 100644 --- a/js/background.js +++ b/js/background.js @@ -14,6 +14,8 @@ var checkTimer = null; var changedEdits = false; var changedTab = false; +var minimized = false; + var activeTabId; const linkReview = ["https://addons.mozilla.org/firefox/addon/limite/"]; //{firefox add-ons} @@ -24,6 +26,18 @@ function loaded() { //catch changing of tab browser.tabs.onActivated.addListener(tabUpdated); browser.tabs.onUpdated.addListener(tabUpdated); + browser.windows.onFocusChanged.addListener(checkLostFocus); +} + +function checkLostFocus(windowId) { + if (windowId === browser.windows.WINDOW_ID_NONE) { + // The browser window is minimized or lost focus + minimized = true; + } else { + //browser has focus + minimized = false; + } + //console.log("Minimized: " + minimized); } function reload() { @@ -289,7 +303,7 @@ function checkEverySecond(url) { } function increaseTime(url) { - if (enabledOrNot) { + if (enabledOrNot && !minimized) { if (url === currentUrl) { saveUrlToData(true, 1); } diff --git a/manifest.json b/manifest.json index 67dbde6..616d991 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Limite", - "version": "2.0.0.1", + "version": "2.0.1", "author": "Saverio Morelli (Sav22999)", "description": "Check how much time you spend on each website every day.\nOptimise your productivity, your time and your life as well.\nDon't lose precious time!", "icons": {