Browse Source

[bug fix]

A\An 2 years ago
parent
commit
9504f594e4
2 changed files with 35 additions and 2 deletions
  1. 29 2
      src/logic/content/twitter.js
  2. 6 0
      src/view/iframe/red-packet/red-packet.vue

+ 29 - 2
src/logic/content/twitter.js

@@ -409,6 +409,10 @@ let isSetContent = false;
 const _setPublishContent = throttle(function (content) {
     if (!isSetContent) {
         isSetContent = true;
+        let inputEle = document.querySelector('div[contenteditable="true"]');
+        if(inputEle) {
+            inputEle.focus();
+        }
         setTimeout(() => {
             document.execCommand("insertText", false, content);
             setTimeout(() => {
@@ -723,6 +727,7 @@ export function init() {
                 }
                 setIframeRedPacket()
                 checkHasDeBtn()
+                checkHasSliderDeBtn();
                 changeQueueNum(-1)
             }, 1000)
         } else if (inFacebook && inFacebookNode) {
@@ -767,6 +772,14 @@ export function init() {
     });
 }
 
+function checkHasSliderDeBtn() {
+    let deBtn = document.getElementById('de-btn');
+    let deBtn3 = document.getElementById('de-btn3');
+    if(!deBtn && !deBtn3) {
+        addSliderNavDeBtn();
+    }
+}
+
 export function facebookReplyTweet(params) {
     if (window.location.origin.indexOf('twitter.com')) {
         const urlParams = new URLSearchParams(window.location.search);
@@ -799,7 +812,8 @@ export function replyHandle(params) {
             tweetReply.addEventListener('click', function() {
                 let eleList = tweetReply.parentNode.parentNode.parentNode.parentNode.parentNode.querySelectorAll('span[data-text="true"]');
                 reportReplyResult(eleList, params, () => {
-                    iframe.contentWindow.postMessage({ actionType: 'CONTENT_RED_PACKET_REPLY_RASK_FINSH', data: {} }, '*');
+                    // iframe.contentWindow.postMessage({ actionType: 'CONTENT_RED_PACKET_REPLY_RASK_FINSH', data: {} }, '*');
+                    chrome.runtime.sendMessage({ actionType: "CONTENT_RED_PACKET_REPLY_RASK_FINSH", data : {postId: params.postId}}, () => { })
                 });
             })
         }
@@ -823,7 +837,19 @@ function onReplyDialogOpen(params, iframe) {
         let replyBtn; 
         
         if (dialog) {
+            let dialogContent  = dialog.querySelector('div[role="dialog"]');
             replyBtn = dialog.querySelector('div[data-testid="toolBar"]').querySelector('div[data-testid="tweetButton"]');
+            if(dialogContent) {
+                let width = dialogContent.offsetWidth;
+                let ele = document.createElement('div');
+                ele.innerText = 'Tag 3 friends to complete the task';
+                ele.style.cssText = `width: ${width}px; height: 38px; color: #fff; font-weight: 600;
+                font-size: 16px; display: flex; align-items: center; justify-content: center; background: #1D9BF0;
+                opacity: 0.8; position: absolute; top: 18px; left: 50%; transform: translateX(-50%); z-index: 1000`;
+    
+                dialogContent.style.top = '80px';
+                dialogContent.parentNode.appendChild(ele);
+            }
         } else {
             dialog = document.querySelector('main[role="main"]');
             if(dialog) {
@@ -836,7 +862,8 @@ function onReplyDialogOpen(params, iframe) {
                 let eleList = dialog.querySelector('div[contenteditable="true"]').querySelectorAll('span[data-text="true"]');
                 reportReplyResult(eleList, params, () => {
                     // 上報完成
-                    iframe.contentWindow.postMessage({ actionType: 'CONTENT_RED_PACKET_REPLY_RASK_FINSH', data: {} }, '*');
+                    // iframe.contentWindow.postMessage({ actionType: 'CONTENT_RED_PACKET_REPLY_RASK_FINSH', data: {} }, '*');
+                    chrome.runtime.sendMessage({ actionType: "CONTENT_RED_PACKET_REPLY_RASK_FINSH", data : {postId: params.postId}}, () => { })
                 })
             });
         }

+ 6 - 0
src/view/iframe/red-packet/red-packet.vue

@@ -1578,6 +1578,12 @@ function onRuntimeMsg() {
         state.loading_show = false
         doTaskReport(req, sender);
         break;
+      case 'CONTENT_RED_PACKET_REPLY_RASK_FINSH':
+        if(req.data && req.data.postId == state.postId) {
+          state.done.reply = true;
+          state.done.reply_red = false;
+        }
+        break;
     }
   })
 }