Browse Source

[bug][过滤推文]

zhangwei 2 years ago
parent
commit
2e777a2a7c

+ 1 - 1
src/entry/background.js

@@ -138,7 +138,7 @@ function onMessageMethod(req, sender, sendResponse) {
                 getTwitterNftPostPre(req.data, sender)
                 break
             case 'CONTENT_NFT_TXT_PUBLISH':
-                nftTxtPublish(req.data)
+                nftTxtPublish(req.data, sender)
                 break
         }
     }

+ 5 - 1
src/entry/content.js

@@ -34,7 +34,8 @@ import {
     pageJumpHandler,
     getTweetProfileNavTop,
     selectGroupTab,
-    setGroupInfo
+    setGroupInfo,
+    refreshTabGroup
 } from "@/logic/content/twitter.js";
 
 import { 
@@ -174,6 +175,9 @@ chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
         case 'IFRAME_JOINED_GROUP_SET_STYLE':
             setJoinedGroupIframeStyle(req.data)
             break
+        case 'BACK_NFT_PUBLISH_DONE':
+            refreshTabGroup()
+            break
     }
 })
 

+ 2 - 2
src/logic/background/twitter.js

@@ -469,10 +469,10 @@ export const getTwitterNftPostPre = (params, sender) => {
 }
 
 
-export const nftTxtPublish = (params) => {
+export const nftTxtPublish = (params,sender) => {
     fetchPublish(params).then((res) => {
         if(res.code == 0){
-
+            chrome.tabs.sendMessage(sender.tab.id, { actionType: 'BACK_NFT_PUBLISH_DONE', data: res.data }, (res) => { console.log(res) });
         }
     })
 }

+ 10 - 3
src/logic/content/twitter.js

@@ -1317,12 +1317,19 @@ function publishNFTTweetEvent({ groupId, postId, srcContent }) {
             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) || item.includes('#DNFT') || item.includes('⬇️')) {
+                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,
@@ -1871,7 +1878,7 @@ const setGroupTabSelfStyle = (params = {}) => {
 /**
  * 切换到 Group tab时 刷新列表
  */
-const refreshTabGroup = () => {
+export const refreshTabGroup = () => {
     chrome.runtime.sendMessage({
         actionType: "CONTENT_REFRESH_TAB_GROUP_LIST",
         data: {}

+ 2 - 1
src/view/iframe/group-card/card.vue

@@ -54,7 +54,7 @@ import { sendChromeTabMessage, checkIsLogin } from '@/uilts/chromeExtension.js';
 
 let state = reactive({
     show: 'arrow', //join
-    show2: '',
+    show2: 'post',
     data: {},
     twitterAccount: ''
 })
@@ -139,6 +139,7 @@ async function clickPost() {
     if (!_userInfo) {
         return
     }
+    debugger
     // 没有购买过
     if (state.data.buyNftStatus == 0) {
         sendChromeTabMessage({