From 38328ce473f61908eb41a75962c372cc5f3ef737 Mon Sep 17 00:00:00 2001 From: z0ccc Date: Thu, 12 Jan 2023 20:39:49 -0500 Subject: [PATCH] switched tab api for webNavigation --- src/Background/index.ts | 18 ++++-------------- src/manifest.json | 2 +- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/src/Background/index.ts b/src/Background/index.ts index 0d1bb62..a66e4a0 100644 --- a/src/Background/index.ts +++ b/src/Background/index.ts @@ -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) diff --git a/src/manifest.json b/src/manifest.json index 540d835..535e99b 100755 --- a/src/manifest.json +++ b/src/manifest.json @@ -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",