Prechádzať zdrojové kódy

[edit] ach pay close

wenliming 2 rokov pred
rodič
commit
6c99a1093a
2 zmenil súbory, kde vykonal 15 pridanie a 23 odobranie
  1. 15 11
      src/logic/background/denet.js
  2. 0 12
      src/logic/content/denet.js

+ 15 - 11
src/logic/background/denet.js

@@ -1,12 +1,16 @@
-export const closeAchPayNoticeHandler = () => {
-    chrome.tabs.getCurrent((tab) => {
-        let id = tab || {};
-        console.log(tab, 'tab');
-        chrome.tabs.remove(
-            id,
-            () => {
+export const closeAchPayNoticeHandler = async () => {
+    let {id} = await getCurrentTab();
 
-            }
-        )
-    })
-}
+    chrome.tabs.remove(
+        id,
+        () => {
+            // chrome.tabs.highlight({ windowId: tab.windowId, tabs: tab.index })
+        }
+    )
+}
+
+const getCurrentTab = async () => {
+    let queryOptions = { active: true, lastFocusedWindow: true };
+    let [tab] = await chrome.tabs.query(queryOptions);
+    return tab || {};
+}

+ 0 - 12
src/logic/content/denet.js

@@ -4,18 +4,6 @@ export const injectDenet = () => {
     closeAchPayNotice();
 }
 
-const isHasTabByUrl = (url, callback) => {
-    let item
-    chrome.tabs.query({}, (tab) => {
-        for (let i in tab) {
-            if (tab[i].url.indexOf(url) >= 0) {
-                item = tab[i]
-                break
-            }
-        }
-        callback(item)
-    })
-}
 
 const closeAchPayNotice = () => {
     if (window.location.href.indexOf(payAchNoticeUrl) > -1) {