|
@@ -180,7 +180,8 @@ function _publishTweetEvent(params, cb) {
|
|
|
function checkIsShowReSend(dom, params) {
|
|
|
let str = dom.querySelector('div[data-contents="true"]').innerHTML;
|
|
|
if (str.indexOf('#DeNet') < 0 || str.indexOf(params.postId) < 0) {
|
|
|
- noticeBindTweet({ postId: params.postId, taskLuckdropId: '' });
|
|
|
+ let taskLuckdropId = JSON.parse(params.postBizData).taskLuckdropId;
|
|
|
+ noticeBindTweet({ postId: params.postId, taskLuckdropId});
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -303,10 +304,12 @@ function addPublishTipsIframe({ srcContent }) {
|
|
|
if (dialog) {
|
|
|
let right = dialog.offsetLeft - 15 - 266, top = window.innerHeight * 0.05 + dialog.offsetHeight - 60 - 160;
|
|
|
|
|
|
+ top = top - 80 > 0 ? top - 80 : 0;
|
|
|
+
|
|
|
let iframe = document.createElement('iframe');
|
|
|
iframe.id = 'de-publish-tips'
|
|
|
iframe.src = chrome.runtime.getURL('/iframe/publish-tips.html');
|
|
|
- iframe.style.cssText = `border: medium none; width:266px;min-height:178px;position: fixed; right: ${right}px; top: ${top}px;`
|
|
|
+ iframe.style.cssText = `border: medium none; width:270px;height:500px;position: fixed; right: ${right}px; top: ${top}px;z-index: -1`
|
|
|
let iframeContent = document.getElementById('de-publish-tips');
|
|
|
if (!iframeContent) {
|
|
|
dialog.appendChild(iframe)
|
|
@@ -742,43 +745,80 @@ export function replyHandle(params) {
|
|
|
if (replyBtn) {
|
|
|
replyBtn.click();
|
|
|
}
|
|
|
+ onReplyDialogOpen(params, iframe);
|
|
|
+
|
|
|
+ // 详情页推文底部评论处理
|
|
|
+ let pathNameArr = window.location.pathname.split('/');
|
|
|
+ if (pathNameArr.length >= 2 && pathNameArr[pathNameArr.length - 2] == 'status') {
|
|
|
+ let tweetReply = document.querySelector('div[data-testid="tweetButtonInline"]');
|
|
|
+ if(tweetReply) {
|
|
|
+ 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: {} }, '*');
|
|
|
+ });
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+export function onTweetReplyClick(params) {
|
|
|
+ let iframe = window.parent.document.getElementById(params.postId);
|
|
|
+ let replyBtn = iframe.parentNode.parentNode.querySelector('div[data-testid="reply"]') ||
|
|
|
+ iframe.parentNode.parentNode.parentNode.querySelector('div[data-testid="reply"]');
|
|
|
+ if (replyBtn) {
|
|
|
+ replyBtn.addEventListener('click', () => {
|
|
|
+ onReplyDialogOpen(params, iframe);
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
+function onReplyDialogOpen(params, iframe) {
|
|
|
setTimeout(() => {
|
|
|
let dialog = document.querySelector('div[role="dialog"]');
|
|
|
if (dialog) {
|
|
|
let replyBtn = dialog.querySelector('div[data-testid="toolBar"]').querySelector('div[data-testid="tweetButton"]');
|
|
|
replyBtn.addEventListener('click', function () {
|
|
|
let eleList = dialog.querySelector('div[contenteditable="true"]').querySelectorAll('span[data-text="true"]');
|
|
|
- if (eleList && eleList.length) {
|
|
|
- let atList = [];
|
|
|
- for (let i = 0; i < eleList.length; i++) {
|
|
|
- let item = eleList[i];
|
|
|
- // 是否有中文
|
|
|
- let reg = /[\u4E00-\u9FA5]|[\uFE30-\uFFA0]/g;
|
|
|
-
|
|
|
- if (item && item.innerText.startsWith('@') && !reg.test(item.innerText)) {
|
|
|
- atList.push({
|
|
|
- text: item.innerText
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (atList.length >= 3) {
|
|
|
- fetchAddFinishEvent({
|
|
|
- eventType: params.type,
|
|
|
- luckdropId: params.taskLuckdropId
|
|
|
- }).then(res => {
|
|
|
- if (res.code == 0) {
|
|
|
- // 上報完成
|
|
|
- iframe.contentWindow.postMessage({ actionType: 'CONTENT_RED_PACKET_REPLY_RASK_FINSH', data: {} }, '*');
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
+ reportReplyResult(eleList, params, () => {
|
|
|
+ // 上報完成
|
|
|
+ iframe.contentWindow.postMessage({ actionType: 'CONTENT_RED_PACKET_REPLY_RASK_FINSH', data: {} }, '*');
|
|
|
+ })
|
|
|
});
|
|
|
}
|
|
|
}, 1000);
|
|
|
}
|
|
|
+
|
|
|
+const reportReplyResult = throttle(function (eleList, params, cb) {
|
|
|
+ if (eleList && eleList.length) {
|
|
|
+ let atList = [];
|
|
|
+ for (let i = 0; i < eleList.length; i++) {
|
|
|
+ let item = eleList[i];
|
|
|
+ // 是否有中文
|
|
|
+ let reg = /[\u4E00-\u9FA5]|[\uFE30-\uFFA0]/g;
|
|
|
+
|
|
|
+ if (item && item.innerText.startsWith('@') && !reg.test(item.innerText)) {
|
|
|
+ atList.push(item.innerText);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ atList = Array.from(new Set(atList));
|
|
|
+
|
|
|
+ if (atList.length >= 3) {
|
|
|
+ fetchAddFinishEvent({
|
|
|
+ eventType: params.type,
|
|
|
+ luckdropId: params.taskLuckdropId
|
|
|
+ }).then(res => {
|
|
|
+ if (res.code == 0) {
|
|
|
+ cb && cb();
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+}, 800);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
// 根据推特id找到dom,完成任务
|
|
|
export function findTweetByIdDoTask({ tweet_Id = '', follow_names = [] }, task_type = 'like') {
|
|
|
// 1.根据推特ID寻找推文,获取卡片
|