Skip to content

Commit

Permalink
prevent closing
Browse files Browse the repository at this point in the history
  • Loading branch information
Nandika-A committed Jan 8, 2024
1 parent 018710e commit cbed9ba
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"version": "1.0",
"description": "Chrome extension that implements the 20 20 20 rule",
"permissions": [
"tabs",
"activeTab",
"storage"
],
Expand Down
16 changes: 16 additions & 0 deletions popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var startTime;
var elapsedTime = 0;
var isTimerRunning = false;


function startTimer() {
if (!isTimerRunning) {
startTime = localStorage.getItem("startTime") || Date.now() + 20 * 60 * 1000;
Expand All @@ -22,6 +23,21 @@ function startTimer() {
}
}

// Prevent the extension from closing on window click
window.addEventListener("click", function(event) {
event.preventDefault();
});

// Prevent the extension from closing on tab switch
window.addEventListener("visibilitychange", function(event) {
event.preventDefault();
});

// Keep the extension running even when the window is closed
window.addEventListener("beforeunload", function(event) {
event.preventDefault();
});

function updateTimer() {
var currentTime = Date.now();
elapsedTime = startTime - currentTime;
Expand Down

0 comments on commit cbed9ba

Please sign in to comment.