nieyuge 2 years ago
parent
commit
eff7d2b6ec
2 changed files with 37 additions and 33 deletions
  1. 2 2
      src/logic/content/nft.js
  2. 35 31
      src/logic/content/twitter.js

+ 2 - 2
src/logic/content/nft.js

@@ -1,7 +1,7 @@
 import { getOffsetRect, nextTick } from '@/uilts/help'
 import { listJoinNftGroup } from '@/http/nft';
 import { getChromeStorage } from '@/uilts/chromeExtension.js'
-import { _setPublishContent, publishNFTTweetEvent } from './twitter';
+import { _setPublishContent, publishNFTTweetPost } from './twitter';
 
 var ifShowNftGroup = false;
 var tempNftGroupPost = null;
@@ -204,6 +204,6 @@ function _addTweetButtonListen() {
 }
 function _postTweetContent() {
     if (tempNftGroupPost && tempNftGroupPost.groupId) {
-        publishNFTTweetEvent(tempNftGroupPost)
+        publishNFTTweetPost(tempNftGroupPost)
     }
 }

+ 35 - 31
src/logic/content/twitter.js

@@ -1330,37 +1330,7 @@ export function publishNFTTweetEvent({ groupId, postId, srcContent }) {
         }
         publishTweetBtn && publishTweetBtn.addEventListener('click', function () {
             // 获取文案上报
-            let inputEle = document.querySelector('div[contenteditable="true"]');
-            let textContent = inputEle.innerText
-            let arr = srcContent.split(' ') || []
-            let text_content_arr = textContent.split(' ') || []
-            arr.forEach((item) => {
-                if (textContent.includes(item)) {
-                    textContent = textContent.replaceAll(item, '')
-                }
-            })
-            text_content_arr.forEach((item) => {
-                if (item.includes('#DNFT') || item.includes('⬇️')) {
-                    textContent = textContent.replaceAll(item, '')
-                }
-            })
-            textContent = textContent.replaceAll('#DNFT', '')
-            textContent = textContent.replaceAll('⬇️', '')
-
-            let formData = {
-                groupId,
-                textContent
-            }
-            let params = {
-                postBizData: JSON.stringify(formData),
-                postSrc: 1, //1 twitter
-                postType: 2, //2 nft
-                postId
-            }
-            chrome.runtime.sendMessage({
-                actionType: "CONTENT_NFT_TXT_PUBLISH",
-                data: params
-            }, () => { });
+            publishNFTTweetPost({ postId, srcContent, groupId })
             jumpTwitterDetailByAlert()
             setTimeout(() => {
                 setGroupTabSelfStyle({
@@ -1377,6 +1347,40 @@ export function publishNFTTweetEvent({ groupId, postId, srcContent }) {
     }, 800)
 }
 
+export const publishNFTTweetPost = ({ postId, srcContent, groupId }) => {
+    let inputEle = document.querySelector('div[contenteditable="true"]');
+    let textContent = inputEle.innerText
+    let arr = srcContent.split(' ') || []
+    let text_content_arr = textContent.split(' ') || []
+    arr.forEach((item) => {
+        if (textContent.includes(item)) {
+            textContent = textContent.replaceAll(item, '')
+        }
+    })
+    text_content_arr.forEach((item) => {
+        if (item.includes('#DNFT') || item.includes('⬇️')) {
+            textContent = textContent.replaceAll(item, '')
+        }
+    })
+    textContent = textContent.replaceAll('#DNFT', '')
+    textContent = textContent.replaceAll('⬇️', '')
+
+    let formData = {
+        groupId,
+        textContent
+    }
+    let params = {
+        postBizData: JSON.stringify(formData),
+        postSrc: 1, //1 twitter
+        postType: 2, //2 nft
+        postId
+    }
+    chrome.runtime.sendMessage({
+        actionType: "CONTENT_NFT_TXT_PUBLISH",
+        data: params
+    }, () => { });
+}
+
 const content_get_nft_post_pre = (data) => {
     chrome.runtime.sendMessage({
         actionType: "CONTENT_GET_TWITTER_NFT_POST_PRE",