switched tab api for webNavigation

This commit is contained in:
z0ccc 2023-01-12 20:39:49 -05:00
parent 0012a62f15
commit 38328ce473
2 changed files with 5 additions and 15 deletions

View file

@ -1,22 +1,12 @@
import attachDebugger from '../utils/attachDebugger' import attachDebugger from '../utils/attachDebugger'
const attachTab = (tabId: number) => { const attachTab = (e: any) => {
chrome.debugger.getTargets((tabs) => { chrome.debugger.getTargets((tabs) => {
const currentTab = tabs.find((obj) => obj.tabId === tabId) const currentTab = tabs.find((obj) => obj.tabId === e.tabId)
if (!currentTab?.attached) { if (!currentTab?.attached) {
attachDebugger(tabId) attachDebugger(e.tabId)
} }
}) })
} }
chrome.tabs.onCreated.addListener((tab) => { chrome.webNavigation.onBeforeNavigate.addListener(attachTab)
tab.id && attachDebugger(tab.id)
})
chrome.tabs.onActivated.addListener((tab) => {
attachTab(tab.tabId)
})
chrome.tabs.onUpdated.addListener((tabId) => {
attachTab(tabId)
})

View file

@ -5,7 +5,7 @@
"description": "__MSG_extDesc__", "description": "__MSG_extDesc__",
"author": "__MSG_extName__", "author": "__MSG_extName__",
"default_locale": "en", "default_locale": "en",
"permissions": ["storage", "debugger"], "permissions": ["storage", "debugger", "webNavigation"],
"background": { "service_worker": "background.bundle.js" }, "background": { "service_worker": "background.bundle.js" },
"action": { "action": {
"default_popup": "popup.html", "default_popup": "popup.html",