Browse Source

postMessage

nieyuge 2 years ago
parent
commit
1ec2b255bf
1 changed files with 23 additions and 1 deletions
  1. 23 1
      src/logic/content/nft.js

+ 23 - 1
src/logic/content/nft.js

@@ -127,6 +127,7 @@ export const setNFTGroupContent = (res) => {
     let where = (edit.innerText === '\n') || (edit.innerText === '')
     if (where) {
         setPostContent(res)
+        _addTweetButtonListen()
     } else {
         clearPostContent(() => {
             let inputEle = document.querySelector('div[contenteditable="true"]');
@@ -134,6 +135,7 @@ export const setNFTGroupContent = (res) => {
                 inputEle.focus();
             }
             setPostContent(res)
+            _addTweetButtonListen()
         })
     }
 }
@@ -168,4 +170,24 @@ export const addJoinedGroupList = () => {
             } 
         }
     }
-};
+};
+
+
+
+
+function _addTweetButtonListen() {
+    let btn = document.querySelector('div[data-testid="tweetButton"]');
+
+    btn.removeEventListener('click', _postTweetContent);
+    btn.addEventListener('click', _postTweetContent)
+}
+function _postTweetContent() {
+    if (tempNftGroupPost && tempNftGroupPost.groupId) {
+        chrome.runtime.sendMessage({
+            actionType: "CONTENT_GET_TWITTER_NFT_POST_PRE",
+            data: {
+                groupId: tempNftGroupPost.groupId
+            }
+        }, () => { });
+    }
+}