refactor(ext): tidy up background code

This commit is contained in:
Simon
2026-02-10 21:59:58 +08:00
parent 430be466fc
commit c71ffcec1c
2 changed files with 30 additions and 26 deletions

View File

@@ -105,3 +105,19 @@ export function handleTabControlMessage(
return
}
}
export function setupTabChangeEvents() {
chrome.tabs.onCreated.addListener((tab) => {
console.debug('[Background] Tab created', tab)
chrome.runtime.sendMessage({ type: 'TAB_CHANGE', action: 'created', payload: { tab } })
})
chrome.tabs.onRemoved.addListener((tabId, removeInfo) => {
console.debug('[Background] Tab removed', tabId, removeInfo)
chrome.runtime.sendMessage({
type: 'TAB_CHANGE',
action: 'removed',
payload: { tabId, removeInfo },
})
})
}