Skip to content

Commit

Permalink
fix: keep sw activated during session (#206)
Browse files Browse the repository at this point in the history
  • Loading branch information
HunnySajid authored Oct 4, 2024
1 parent 4ed4556 commit 7b256a5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/pages/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ console.log("Background script loaded");

const csHandler = initCSHandler();
const uiHandler = initUIHandler();
const SAVE_TIMESTAMP_INTERVAL_MS = 2 * 1000;
function saveTimestamp() {
const timestamp = new Date().toISOString();

browser.storage.session.set({ timestamp });
}

browser.runtime.onStartup.addListener(function () {
(async () => {
Expand Down Expand Up @@ -86,3 +92,9 @@ browser.runtime.onMessage.addListener(function (
// // return true to indicate chrome api to send a response asynchronously
// return true;
// });

async function initBackground() {
saveTimestamp();
setInterval(saveTimestamp, SAVE_TIMESTAMP_INTERVAL_MS);
}
initBackground();

0 comments on commit 7b256a5

Please sign in to comment.