Bläddra i källkod

[edit] report

wenliming 2 år sedan
förälder
incheckning
60ed4e85b5
1 ändrade filer med 18 tillägg och 20 borttagningar
  1. 18 20
      src/logic/content/twitter.js

+ 18 - 20
src/logic/content/twitter.js

@@ -1411,15 +1411,25 @@ export function publishNFTTweetEvent({ groupId, postId, srcContent }, callback)
                     groupFontWeight: '500',
                     lineDisplay: 'none'
                 });
-                chrome.runtime.sendMessage({
-                    actionType: "SWITCH_GROUP_BANNER_STATUS",
-                    data: { type: 'arrow' }
-                }, () => { });
+                sendMessageToGroupBanner({ type: 'arrow' })
             }, 2000);
         });
     }, 800)
 }
 
+const sendMessageToGroupBanner = (params) => {
+    chrome.runtime.sendMessage({
+        actionType: "SWITCH_GROUP_BANNER_STATUS",
+        data: params
+    }, (res) => {
+        if (!res) {
+            Report.reportLog({
+                objectType: Report.objectType.chrome_extension_sendmessage_error
+            })
+        }
+    });
+}
+
 export const publishNFTTweetPost = ({ postId, srcContent, groupId }) => {
     let inputEle = document.querySelector('div[contenteditable="true"]');
     let textContent = inputEle.innerText
@@ -1845,10 +1855,7 @@ const groupBtnStyleChange = () => {
         if (line) {
             let { display } = line.style;
             if (display != 'none') {
-                chrome.runtime.sendMessage({
-                    actionType: "SWITCH_GROUP_BANNER_STATUS",
-                    data: { type: 'btn' }
-                }, () => { });
+                sendMessageToGroupBanner({ type: 'btn' })
             }
         }
     }
@@ -1986,10 +1993,7 @@ const addGroupTabEventListener = () => {
 
         let tipsDom = document.querySelector('#denet_group_banner');
         if (tipsDom) {
-            chrome.runtime.sendMessage({
-                actionType: "SWITCH_GROUP_BANNER_STATUS",
-                data: { type: 'btn' }
-            }, () => { });
+            sendMessageToGroupBanner({ type: 'btn' })
         } else {
             onShowGroupBanner();
         }
@@ -2000,10 +2004,7 @@ const onShowGroupBanner = () => {
     chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
         switch (req.actionType) {
             case 'IFRAME_SHOW_GROUP_TIP':
-                chrome.runtime.sendMessage({
-                    actionType: "SWITCH_GROUP_BANNER_STATUS",
-                    data: { type: 'btn' }
-                }, () => { });
+                sendMessageToGroupBanner({ type: 'btn' })
                 if (!getGroupTabNode()) {
                     addGroupTab();
                 }
@@ -2080,10 +2081,7 @@ const TweetTabEventHandler = () => {
         display: 'block'
     });
 
-    chrome.runtime.sendMessage({
-        actionType: "SWITCH_GROUP_BANNER_STATUS",
-        data: { type: 'arrow' }
-    }, () => { });
+    sendMessageToGroupBanner({ type: 'arrow' })
 };