Browse Source

Merge branch 'test' into feature_220509_new

wenliming 3 năm trước cách đây
mục cha
commit
cd9d6059c8

+ 1 - 1
src/logic/background/fetch/twitter.js

@@ -35,7 +35,7 @@ export async function fetchTwitterLogin(oauthToken, oauthVerifier, receivedIds =
     let storage_mid = await getChromeStorage('mid') || ''
     const { mid } = storage_mid || {}
     return new Promise(function (resolve, reject) {
-        let _url = `${baseAPIUrl}/user/fetchTwitterLogin`
+        let _url = `${baseAPIUrl}/user/twitterLogin`
         fetch(_url, {
             method: 'POST', // or 'PUT'
             headers: {

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

@@ -545,16 +545,26 @@ function parseDOMRedPacket() {
         }
     }
 }
+function getTwitterIdByDOM(dom) {
+    let _twitter_id = ''
+    for (let i in dom) {
+        if (dom[i].href.indexOf('/status/') > 0) {
+            _twitter_id = dom[i].href.split('/status/')[1] || ''
+            break
+        }
+    }
+    return _twitter_id
+}
 
 let parse_dom = {}
 
 async function parseDOMRedPacketByShortUrl(port) {
-    // let _new_time = new Date().getTime()
-    // if ((_new_time - change_time) > 1000) {
-    //     change_time = _new_time
-    // } else {
-    //     return
-    // }
+    let _new_time = new Date().getTime()
+    if ((_new_time - change_time) > 1000) {
+        change_time = _new_time
+    } else {
+        return
+    }
     // 为了减少声明变量次数
     parse_dom.dom = null
     parse_dom.txt_area = null
@@ -578,16 +588,11 @@ async function parseDOMRedPacketByShortUrl(port) {
                 continue
             }
             parse_dom.short_url = getTwitterShortUrl(parse_dom.article)
-            parse_dom.a_tweetId = parse_dom.article.querySelector('a[aria-label]')
-            if (parse_dom.a_tweetId && parse_dom.a_tweetId.getAttribute('href')) {
-                parse_dom.tweetId = parse_dom.a_tweetId.getAttribute('href').split('/status/')[1] || ''
-            }
+            parse_dom.tweetId = getTwitterIdByDOM(parse_dom.article.querySelectorAll('a'))
             parse_dom.postId = await handleShortUrl(port, parse_dom.short_url)
-            console.log('_postId', parse_dom.postId)
-            console.log('short_url', parse_dom.short_url)
 
             // 获取到postId了
-            if (parse_dom.postId) {
+            if (parse_dom.postId && parse_dom.tweetId) {
                 console.log('bindTwitterArt.postId', bindTwitterArt.postId)
                 console.log('parse_dom.postId', parse_dom.postId)
                 if (bindTwitterArt.needBind) {
@@ -697,17 +702,17 @@ function replaceDOMRedPacket(_type, _dom, postId, tweetId) {
     }
 }
 
-// let change_time = new Date().getTime()
-// function onChangePageMain(port, targetNode) {
-//     const config = { attributes: true, childList: true, subtree: true };
-//     const callback = (mutationsList, observer) => {
-//         setTimeout(() => {
-//             parseDOMRedPacketByShortUrl(port)
-//         }, 2000)
-//     }
-//     const observer = new MutationObserver(callback);
-//     observer.observe(targetNode, config);
-// }
+let change_time = new Date().getTime()
+function onChangePageMain(port, targetNode) {
+    const config = { attributes: true, childList: true, subtree: true };
+    const callback = (mutationsList, observer) => {
+        setTimeout(() => {
+            parseDOMRedPacketByShortUrl(port)
+        }, 1500)
+    }
+    const observer = new MutationObserver(callback);
+    observer.observe(targetNode, config);
+}
 
 function setIframeRedPacket(port) {
     // let elment = document.documentElement
@@ -715,19 +720,19 @@ function setIframeRedPacket(port) {
     if (window.location.href.includes('twitter.com)')) {
         return
     }
-    setInterval(() => {
-        parseDOMRedPacketByShortUrl(port)
-    }, 1000)
+    // setInterval(() => {
+    //     parseDOMRedPacketByShortUrl(port)
+    // }, 1000)
 
 
-    // let targetNode = null
-    // let timer = setInterval(() => {
-    //     targetNode = document.querySelector('main')
-    //     if (targetNode) {
-    //         clearInterval(timer)
-    //         onChangePageMain(port, targetNode)
-    //     }
-    // }, 1000);
+    let targetNode = null
+    let timer = setInterval(() => {
+        targetNode = document.querySelector('main')
+        if (targetNode) {
+            clearInterval(timer)
+            onChangePageMain(port, targetNode)
+        }
+    }, 1000);
 }
 
 export function initExecuteScript(changes) {

+ 16 - 5
src/view/iframe/red-packet/red-packet.vue

@@ -247,6 +247,7 @@ import { message } from 'ant-design-vue';
 import FontAmount from '@/view/components/font-amount.vue'
 import { getChromeStorage } from '@/uilts/chromeExtension.js'
 import Report from "@/log-center/log"
+import { srcPublishSuccess } from '@/http/publishApi'
 
 var moment = require('moment');
 
@@ -521,11 +522,21 @@ function init() {
     data.loading_show = false
     if (res.code == 0) {
       data.srcContentId = res.data.srcContentId
-      // if (data.tweetId != data.srcContentId) {
-      //   data.error_txt = 'Giveaways link Error'
-      //   data.status = 'error'
-      //   return
-      // }
+      if (data.tweetId != data.srcContentId) {
+        // 重新绑定
+        srcPublishSuccess({
+          params: {
+            postId: data.postId,
+            srcContentId: data.tweetId
+          }
+        }).then((res) => {
+          Report.reportLog({
+            objectType: Report.objectType.tweetPostBinded
+          });
+          init()
+        })
+        return
+      }
       data.detail = JSON.parse(res.data.postBizData)
       console.log(data.detail)
 

+ 1 - 1
src/view/options.vue

@@ -1,6 +1,6 @@
 <template>
   <div class="main_app">
-    <h1>Hello {{msg}}</h1>
+    <!-- <h1>Hello {{msg}}</h1> -->
   </div>
 </template>
 

+ 5 - 3
src/view/popup/withdraw/info.vue

@@ -100,14 +100,14 @@ const inputWithdrawCalcFee = () => {
         state.fee_amount = res.data.feeAmountValue || 0
         state.amount = res.data.finalAmountValue || 111
         state.is_enter_state = true
-        inputText()
+        inputText('yes')
       }
     }
 
   })
 }
 
-const inputText = () => {
+const inputText = (is_check_input) => {
   if (!state.withdraw_switch) {
     return
   }
@@ -138,7 +138,9 @@ const inputText = () => {
     return
   } else {
     state.error_msg = ''
-    inputWithdrawCalcFee()
+    if (is_check_input != 'yes') {
+      inputWithdrawCalcFee()
+    }
   }
 }