|
@@ -72,14 +72,18 @@ export function hideIframeHandler() {
|
|
|
/**
|
|
|
* 展示twitter原生发布框
|
|
|
*/
|
|
|
-
|
|
|
+let tweetPublishStore = {
|
|
|
+ showPublishDialog : false
|
|
|
+}
|
|
|
export function showTwitterPublishDialogHandler(publishRes) {
|
|
|
let bigBtn = document.querySelector('a[data-testid="SideNav_NewTweet_Button"]');
|
|
|
if (bigBtn) {
|
|
|
bigBtn.click();
|
|
|
+ tweetPublishStore.showPublishDialog = true;
|
|
|
} else {
|
|
|
let smallBtn = document.querySelector('a[href="/compose/tweet"]')
|
|
|
smallBtn && smallBtn.click();
|
|
|
+ tweetPublishStore.showPublishDialog = true;
|
|
|
}
|
|
|
|
|
|
setChromeStorage({ publishData: JSON.stringify(publishRes) })
|
|
@@ -172,6 +176,7 @@ function _publishTweetEvent(params, cb) {
|
|
|
publishTweetBtn && publishTweetBtn.addEventListener('click', function () {
|
|
|
bindTwitterArt.needBind = true;
|
|
|
bindTwitterArt.postId = params.postId;
|
|
|
+ tweetPublishStore.showPublishDialog = false;
|
|
|
// checkIsShowReSend(dialog, params);
|
|
|
cb && cb()
|
|
|
});
|
|
@@ -187,10 +192,18 @@ function onClosePublishDialogHandle(dom, params) {
|
|
|
for(let i = 0; i < btnArr.length; i++) {
|
|
|
let btn = btnArr[i];
|
|
|
btn.addEventListener('click', function() {
|
|
|
+ tweetPublishStore.showPublishDialog = false;
|
|
|
let taskLuckdropId = JSON.parse(params.postBizData).taskLuckdropId;
|
|
|
noticeBindTweet({ postId: params.postId, taskLuckdropId});
|
|
|
})
|
|
|
}
|
|
|
+ } else {
|
|
|
+ setTimeout(() => {
|
|
|
+ let dialog = document.querySelector('div[role="dialog"]');
|
|
|
+ if(!dialog) {
|
|
|
+ tweetPublishStore.showPublishDialog = false;
|
|
|
+ }
|
|
|
+ }, 800)
|
|
|
}
|
|
|
}, 1000)
|
|
|
})
|
|
@@ -316,25 +329,24 @@ function _addIframe() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-function addPublishTipsIframe({ srcContent }) {
|
|
|
+function addPublishTipsIframe(params = {}) {
|
|
|
+ let {time = 1000} = params;
|
|
|
setTimeout(() => {
|
|
|
let dialog = document.querySelector('div[role="dialog"]').querySelector('div[role="dialog"]')
|
|
|
|
|
|
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 right = dialog.offsetLeft - 15 - 266;
|
|
|
|
|
|
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:270px;height:500px;position: fixed; right: ${right}px; top: ${top}px;z-index: -1`
|
|
|
+ iframe.style.cssText = `border: medium none; width:270px;height:500px;position: fixed; right: ${right}px; top: 5%;z-index: -1`
|
|
|
let iframeContent = document.getElementById('de-publish-tips');
|
|
|
if (!iframeContent) {
|
|
|
dialog.appendChild(iframe)
|
|
|
}
|
|
|
}
|
|
|
- }, 1000)
|
|
|
+ }, time)
|
|
|
}
|
|
|
|
|
|
export function noticeBindTweet(params) {
|
|
@@ -519,6 +531,14 @@ function addSliderNavDeBtn(isSmall = false) {
|
|
|
function onWindowResize() {
|
|
|
window.onresize = throttle(function () {
|
|
|
try {
|
|
|
+ if(tweetPublishStore.showPublishDialog) {
|
|
|
+ let dialog = document.querySelector('div[role="dialog"]');
|
|
|
+ let dePublishTips = document.getElementById('de-publish-tips');
|
|
|
+ if(dialog && !dePublishTips) {
|
|
|
+ addPublishTipsIframe({time: 0});
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (window.innerWidth < 1273) {
|
|
|
let bigBtn = document.querySelector('#de-btn');
|
|
|
bigBtn && bigBtn.remove();
|
|
@@ -800,8 +820,18 @@ export function onTweetReplyClick(params) {
|
|
|
function onReplyDialogOpen(params, iframe) {
|
|
|
setTimeout(() => {
|
|
|
let dialog = document.querySelector('div[role="dialog"]');
|
|
|
+ let replyBtn;
|
|
|
+
|
|
|
if (dialog) {
|
|
|
- let replyBtn = dialog.querySelector('div[data-testid="toolBar"]').querySelector('div[data-testid="tweetButton"]');
|
|
|
+ replyBtn = dialog.querySelector('div[data-testid="toolBar"]').querySelector('div[data-testid="tweetButton"]');
|
|
|
+ } else {
|
|
|
+ dialog = document.querySelector('main[role="main"]');
|
|
|
+ if(dialog) {
|
|
|
+ replyBtn = dialog.querySelector('div[data-testid="tweetButton"]');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(dialog && replyBtn) {
|
|
|
replyBtn.addEventListener('click', function () {
|
|
|
let eleList = dialog.querySelector('div[contenteditable="true"]').querySelectorAll('span[data-text="true"]');
|
|
|
reportReplyResult(eleList, params, () => {
|