Kaynağa Gözat

[edit] fix mobile reply

wenliming 2 yıl önce
ebeveyn
işleme
cf70fda2d3
1 değiştirilmiş dosya ile 25 ekleme ve 3 silme
  1. 25 3
      src/logic/content/twitter.js

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

@@ -1245,13 +1245,35 @@ function onReplyDialogOpen(params, iframe) {
                     businessType: Report.businessType.buttonClick,
                     objectType: Report.objectType.replyClickByTwitterList
                 });
+                let editDom = dialog.querySelector('div[contenteditable="true"]');
+                let eleList = []
+                if(editDom) {
+                  eleList = editDom.querySelectorAll('span[data-text="true"]');
+                } else {
+                  // mobile.twitter.com
+                  editDom = dialog.querySelector('textarea');
+                  if(editDom) {
+                    let value = editDom.value;
+                    if(value) {
+                      let strArr = value.split(' ');
+                      if(strArr && strArr.length) {
+                        for(let i = 0; i < strArr.length; i++) {
+                          eleList.push({
+                            innerText: strArr[i]
+                          })
+                        }
+                      }
+                    }
+                  }
+                }
 
-                let eleList = dialog.querySelector('div[contenteditable="true"]').querySelectorAll('span[data-text="true"]');
-                reportReplyResult(eleList, params, () => {
+                if(eleList.length) {
+                  reportReplyResult(eleList, params, () => {
                     // 上報完成
                     iframe.contentWindow.postMessage({ actionType: 'CONTENT_RED_PACKET_REPLY_RASK_FINSH', data: { postId: params.postId } }, '*');
                     // chrome.runtime.sendMessage({ actionType: "CONTENT_RED_PACKET_REPLY_RASK_FINSH", data: { postId: params.postId } }, () => { })
-                })
+                  })
+                }
             });
         }
     }, 1000);