diff --git a/src/background.ts b/src/background.ts index 24ab0b7..84a7f59 100644 --- a/src/background.ts +++ b/src/background.ts @@ -4,9 +4,8 @@ const APP_NAME = "com.ticklab.tpulse"; const port = browser.runtime.connectNative(APP_NAME); function isUserTab(tab: BrowserTab) { - return tab.url && ( - tab.url.startsWith("http://") - || tab.url.startsWith("https://") + return ( + tab.url && (tab.url.startsWith("http://") || tab.url.startsWith("https://")) ); } @@ -38,7 +37,6 @@ function watch() { getTabDetails(tabId) .then((tab) => { if (!isUserTab(tab)) return; - console.log("tab", tab); const message: BinaryMessage = { type: "BrowserTab", ...tab }; port.postMessage(message); }) @@ -70,7 +68,7 @@ function watch() { tab.url.startsWith("http") ) { const newMessage: BrowserMessage = { - type: "ticklabvn.tpulse.NEW_VIDEO", + type: "ticklabvn.tpulse.TAB_UPDATE", }; browser.tabs.sendMessage(tabId, newMessage); } diff --git a/src/contentScript.ts b/src/contentScript.ts index 48cccda..c673c11 100644 --- a/src/contentScript.ts +++ b/src/contentScript.ts @@ -83,7 +83,7 @@ const setupPlayerEventListeners = () => { browser.runtime.onMessage.addListener((obj) => { const { type } = obj; - if (type === "ticklabvn.tpulse.NEW_VIDEO") { + if (type === "ticklabvn.tpulse.TAB_UPDATE") { setupPlayerEventListeners(); } }); diff --git a/src/type.d.ts b/src/type.d.ts index 30cc359..2421690 100644 --- a/src/type.d.ts +++ b/src/type.d.ts @@ -11,7 +11,7 @@ type MessageTypePrefix = "ticklabvn.tpulse."; type VideoStatusPayload = Record; type BrowserMessage = { - type: `${MessageTypePrefix}${"NEW_VIDEO" | "UPDATE_VIDEO_STATUS"}`; + type: `${MessageTypePrefix}${"TAB_UPDATE" | "UPDATE_VIDEO_STATUS"}`; payload?: VideoStatusPayload; };