diff --git a/background.js b/background.js index 8344c1e..56d079c 100644 --- a/background.js +++ b/background.js @@ -1,6 +1,6 @@ // ======== Life Scrobbler Extension ======== -// Fully self-contained version with base64 icons -// Stop scrobble code is commented out for now +const SCROBBLE_ENDPOINT = "https://life.lab.unbl.ink/?source=Firefox&scrobble_url="; +const STOP_ENDPOINT = "https://life.lab.unbl.ink/?action=stop&scrobble_url="; // ====== Default Settings ====== const DEFAULT_SETTINGS = { @@ -149,15 +149,17 @@ browser.browserAction.onClicked.addListener(async (tab) => { setPaused(tab.id, !tabPaused); }); -// ====== Clean up on Tab Close ====== browser.tabs.onRemoved.addListener((tabId) => { if (activeTabs.has(tabId)) clearTimeout(activeTabs.get(tabId)); pausedTabs.delete(tabId); }); -// ====== Web Navigation stop code is commented ====== +<<<<<<< HEAD browser.webNavigation.onBeforeNavigate.addListener((details) => { - const { scrobbleBaseUrl } = DEFAULT_SETTINGS; - // scrobbleStop(details.url, scrobbleBaseUrl); - // TODO need to fix this in Scrobbler to check if a running scrobble exists and stop if it does + stopScrobble(details.tabId, details.url); +}); + +browser.browserAction.onClicked.addListener(async () => { + const { paused } = await getSettings(); + setPaused(!paused); });