diff options
author | sameerasw <[email protected]> | 2025-02-27 20:19:52 +0530 |
---|---|---|
committer | sameerasw <[email protected]> | 2025-02-27 20:19:52 +0530 |
commit | 829e117797f5185b230af508c31d0641eafc1e6a (patch) | |
tree | b8d075b1ccc8db68a91edbefe2e0b165a6a42fed /background.js | |
parent | a950299b28662029b86b61b4e9d6d5821d06912c (diff) |
Added descriptive comments
Diffstat (limited to 'background.js')
-rw-r--r-- | background.js | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/background.js b/background.js index 77f78f9..8a71095 100644 --- a/background.js +++ b/background.js @@ -1,4 +1,5 @@ function applyCSSToTab(tab) { + // Apply CSS to the specified tab const url = new URL(tab.url); const hostname = url.hostname; @@ -44,15 +45,18 @@ function applyCSSToTab(tab) { let autoUpdateInterval; function startAutoUpdate() { + // Start the auto-update interval if (autoUpdateInterval) clearInterval(autoUpdateInterval); autoUpdateInterval = setInterval(refetchCSS, 2 * 60 * 60 * 1000); } function stopAutoUpdate() { + // Stop the auto-update interval if (autoUpdateInterval) clearInterval(autoUpdateInterval); } async function refetchCSS() { + // Refetch CSS styles from the remote server try { const response = await fetch( "https://sameerasw.github.io/my-internet/styles.json", @@ -71,6 +75,7 @@ async function refetchCSS() { } browser.runtime.onMessage.addListener((message) => { + // Handle messages for enabling/disabling auto-update if (message.action === "enableAutoUpdate") { startAutoUpdate(); } else if (message.action === "disableAutoUpdate") { @@ -86,12 +91,14 @@ browser.storage.local.get("transparentZenSettings").then((settings) => { }); browser.tabs.onUpdated.addListener((tabId, changeInfo, tab) => { + // Apply CSS when a tab is updated if (changeInfo.status === "complete") { applyCSSToTab(tab); } }); browser.tabs.onActivated.addListener(async (activeInfo) => { + // Apply CSS when a tab is activated const tab = await browser.tabs.get(activeInfo.tabId); applyCSSToTab(tab); }); |