Skip to content

Commit

Permalink
switched tab api for webNavigation
Browse files Browse the repository at this point in the history
  • Loading branch information
z0ccc committed Jan 13, 2023
1 parent 0012a62 commit 38328ce
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
18 changes: 4 additions & 14 deletions src/Background/index.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
import attachDebugger from '../utils/attachDebugger'

const attachTab = (tabId: number) => {
const attachTab = (e: any) => {
chrome.debugger.getTargets((tabs) => {
const currentTab = tabs.find((obj) => obj.tabId === tabId)
const currentTab = tabs.find((obj) => obj.tabId === e.tabId)
if (!currentTab?.attached) {
attachDebugger(tabId)
attachDebugger(e.tabId)
}
})
}

chrome.tabs.onCreated.addListener((tab) => {
tab.id && attachDebugger(tab.id)
})

chrome.tabs.onActivated.addListener((tab) => {
attachTab(tab.tabId)
})

chrome.tabs.onUpdated.addListener((tabId) => {
attachTab(tabId)
})
chrome.webNavigation.onBeforeNavigate.addListener(attachTab)
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "__MSG_extDesc__",
"author": "__MSG_extName__",
"default_locale": "en",
"permissions": ["storage", "debugger"],
"permissions": ["storage", "debugger", "webNavigation"],
"background": { "service_worker": "background.bundle.js" },
"action": {
"default_popup": "popup.html",
Expand Down

0 comments on commit 38328ce

Please sign in to comment.