Bladeren bron

[edit][权限]

zhangwei 2 jaren geleden
bovenliggende
commit
24e1fc4fed
2 gewijzigde bestanden met toevoegingen van 18 en 18 verwijderingen
  1. 10 11
      src/entry/content_help.js
  2. 8 7
      src/manifest.json

+ 10 - 11
src/entry/content_help.js

@@ -1,11 +1,10 @@
-window.onload = () => {
-    chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
-        sendResponse('')
-        switch (req.actionType) {
-            case 'BACK_PING':
-                console.log('BACK_PING')
-                chrome.runtime.sendMessage({ actionType: "CONTENT_PONG", data: '1' }, (res) => { console.log(res) })
-                break
-        }
-    })
-}
+
+chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
+    sendResponse('')
+    switch (req.actionType) {
+        case 'BACK_PING':
+            console.log('BACK_PING')
+            chrome.runtime.sendMessage({ actionType: "CONTENT_PONG", data: '1' }, (res) => { console.log(res) })
+            break
+    }
+})

+ 8 - 7
src/manifest.json

@@ -16,6 +16,13 @@
         "default_popup": "popup.html"
     },
     "content_scripts": [
+        {
+            "matches":["<all_urls>"],
+            "run_at": "document_start",
+            "js": [
+                "/js/content_help.js"
+            ]
+        },
         {
             "matches": [
                 "https://*.twitter.com/*",
@@ -30,16 +37,10 @@
             "js": [
                 "/js/content.js"
             ]
-        },
-        {
-            "matches":["<all_urls>"],
-            "run_at": "document_start",
-            "js": [
-                "/js/content_help.js"
-            ]
         }
     ],
     "host_permissions": [
+        "<all_urls>",
         "*://*.twitter.com/*",
         "*://twitter.com/*",
         "*://*.facebook.com/*",