|
@@ -1,5 +1,5 @@
|
|
import { getChromeStorage, setChromeStorage } from '@/uilts/chromeExtension.js'
|
|
import { getChromeStorage, setChromeStorage } from '@/uilts/chromeExtension.js'
|
|
-import { throttle, getQueryString, getCookie } from '@/uilts/help'
|
|
|
|
|
|
+import { throttle, getQueryString, getCookie, nextTick } from '@/uilts/help'
|
|
import { discordAuthRedirectUri } from '@/http/configAPI'
|
|
import { discordAuthRedirectUri } from '@/http/configAPI'
|
|
import { reportSrcPublishEvent } from '@/http/publishApi'
|
|
import { reportSrcPublishEvent } from '@/http/publishApi'
|
|
import Report from "@/log-center/log"
|
|
import Report from "@/log-center/log"
|
|
@@ -95,7 +95,25 @@ export function showTwitterPublishDialogHandler(publishRes) {
|
|
_publishTweetEvent(publishRes, bindTwitterArtMethod);
|
|
_publishTweetEvent(publishRes, bindTwitterArtMethod);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+export function twitterPublishHandler(res) {
|
|
|
|
+ let bigBtn = document.querySelector('a[data-testid="SideNav_NewTweet_Button"]');
|
|
|
|
+ if (bigBtn) {
|
|
|
|
+ bigBtn.click();
|
|
|
|
+ } else {
|
|
|
|
+ let smallBtn = document.querySelector('a[href="/compose/tweet"]')
|
|
|
|
+ smallBtn && smallBtn.click();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ nextTick(() => {
|
|
|
|
+ document.execCommand('selectAll');
|
|
|
|
+ }, 100).then(() => {
|
|
|
|
+ _setPublishContent(res.srcContent, 500);
|
|
|
|
+ })
|
|
|
|
+}
|
|
|
|
+
|
|
export function showPinTips() {
|
|
export function showPinTips() {
|
|
|
|
+ hidePopupPage();
|
|
|
|
+ hideNoticeBindTweet();
|
|
getChromeStorage('pinData', (res) => {
|
|
getChromeStorage('pinData', (res) => {
|
|
if (!res || res.show) {
|
|
if (!res || res.show) {
|
|
let domPop = document.getElementById('de-pin-pop');
|
|
let domPop = document.getElementById('de-pin-pop');
|
|
@@ -104,6 +122,13 @@ export function showPinTips() {
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+export function hidePinTips() {
|
|
|
|
+ let pop = document.querySelector('#de-pin-pop');
|
|
|
|
+ if (pop) {
|
|
|
|
+ pop.style.display = 'none';
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
function addPinedPop() {
|
|
function addPinedPop() {
|
|
let domPop = document.getElementById('de-pin-pop');
|
|
let domPop = document.getElementById('de-pin-pop');
|
|
|
|
|
|
@@ -125,12 +150,7 @@ function addPinedPop() {
|
|
popWrapper.appendChild(img);
|
|
popWrapper.appendChild(img);
|
|
popWrapper.appendChild(contentDom);
|
|
popWrapper.appendChild(contentDom);
|
|
|
|
|
|
- let layersDom = document.getElementById('layers');
|
|
|
|
- if (layersDom) {
|
|
|
|
- layersDom.appendChild(popWrapper);
|
|
|
|
- } else {
|
|
|
|
- document.querySelector('body').appendChild(popWrapper);
|
|
|
|
- }
|
|
|
|
|
|
+ document.querySelector('body').appendChild(popWrapper);
|
|
|
|
|
|
let deCheck = document.querySelector('#de-check');
|
|
let deCheck = document.querySelector('#de-check');
|
|
let deRemind = document.querySelector('#de-remind');
|
|
let deRemind = document.querySelector('#de-remind');
|
|
@@ -237,7 +257,10 @@ function _addDeNetEditBtn(parent, dom, isClick = false) {
|
|
businessType: Report.businessType.buttonView,
|
|
businessType: Report.businessType.buttonView,
|
|
objectType: Report.objectType.buttonSecond
|
|
objectType: Report.objectType.buttonSecond
|
|
});
|
|
});
|
|
- parent.parentNode.insertBefore(dom, parent.nextElementSibling);
|
|
|
|
|
|
+ let innerDeIcon = document.getElementById('de-btn1');
|
|
|
|
+ if (!innerDeIcon) {
|
|
|
|
+ parent.parentNode.insertBefore(dom, parent.nextElementSibling);
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
parent = _getScheduleDom(isClick);
|
|
parent = _getScheduleDom(isClick);
|
|
@@ -330,13 +353,7 @@ function _addIframe() {
|
|
dom.iframe = iframe;
|
|
dom.iframe = iframe;
|
|
let iframeContent = document.getElementById('iframe-content');
|
|
let iframeContent = document.getElementById('iframe-content');
|
|
if (!iframeContent) {
|
|
if (!iframeContent) {
|
|
- let layersDom = document.getElementById('layers');
|
|
|
|
- if (layersDom) {
|
|
|
|
- layersDom.appendChild(iframe);
|
|
|
|
- } else {
|
|
|
|
- document.querySelector('body').appendChild(iframe);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ document.querySelector('body').appendChild(iframe);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -361,6 +378,8 @@ function addPublishTipsIframe(params = {}) {
|
|
}
|
|
}
|
|
|
|
|
|
export function noticeBindTweet(params) {
|
|
export function noticeBindTweet(params) {
|
|
|
|
+ hidePinTips();
|
|
|
|
+ hidePopupPage();
|
|
let iframe = document.createElement('iframe');
|
|
let iframe = document.createElement('iframe');
|
|
iframe.id = 'de-notice-bind-tweet';
|
|
iframe.id = 'de-notice-bind-tweet';
|
|
iframe.src = chrome.runtime.getURL('/iframe/bind-tweet.html') + `?params=${JSON.stringify(params)}`;
|
|
iframe.src = chrome.runtime.getURL('/iframe/bind-tweet.html') + `?params=${JSON.stringify(params)}`;
|
|
@@ -417,7 +436,7 @@ function _deNetBtnClick() {
|
|
* @private
|
|
* @private
|
|
*/
|
|
*/
|
|
let isSetContent = false;
|
|
let isSetContent = false;
|
|
-const _setPublishContent = throttle(function (content) {
|
|
|
|
|
|
+const _setPublishContent = throttle(function (content, time = 1000) {
|
|
if (!isSetContent) {
|
|
if (!isSetContent) {
|
|
isSetContent = true;
|
|
isSetContent = true;
|
|
let inputEle = document.querySelector('div[contenteditable="true"]');
|
|
let inputEle = document.querySelector('div[contenteditable="true"]');
|
|
@@ -429,7 +448,7 @@ const _setPublishContent = throttle(function (content) {
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
isSetContent = false;
|
|
isSetContent = false;
|
|
}, 2000)
|
|
}, 2000)
|
|
- }, 1000);
|
|
|
|
|
|
+ }, time);
|
|
}
|
|
}
|
|
}, 800);
|
|
}, 800);
|
|
|
|
|
|
@@ -674,7 +693,12 @@ function setIframeRedPacket(type = 'twitter') {
|
|
// 过滤出可以请求的短链接
|
|
// 过滤出可以请求的短链接
|
|
parseCard.getCardParmas(card_json_data).then((res) => {
|
|
parseCard.getCardParmas(card_json_data).then((res) => {
|
|
for (let i in res.has_post_Id_card_data) {
|
|
for (let i in res.has_post_Id_card_data) {
|
|
- parseCard.replaceDOMRedPacket(res.has_post_Id_card_data[i])
|
|
|
|
|
|
+ let item = res.has_post_Id_card_data[i];
|
|
|
|
+ if (item && item.post_Id && item.post_Id.indexOf('nft/') >= 0) {
|
|
|
|
+ parseCard.replaceNftDomRedPacket(item)
|
|
|
|
+ } else {
|
|
|
|
+ parseCard.replaceDOMRedPacket(item)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
if (res.need_net_short_url.length > 0) {
|
|
if (res.need_net_short_url.length > 0) {
|
|
// 请求短链接
|
|
// 请求短链接
|
|
@@ -708,13 +732,15 @@ export function initExecuteScript(changes) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-const createIframe = ({ url, tweet_Id }, callback) => {
|
|
|
|
|
|
+const createNFTIframe = ({ url, id }, callback) => {
|
|
let iframe = document.createElement('iframe')
|
|
let iframe = document.createElement('iframe')
|
|
- iframe.id = `tweetId${tweet_Id}`
|
|
|
|
|
|
+ iframe.id = id
|
|
iframe.src = url
|
|
iframe.src = url
|
|
|
|
+ iframe.style.cssText = 'border:medium none; width:100%; height:100%; z-index:100; position: fixed; top:0;left:0; display:none;';
|
|
iframe.onload = () => {
|
|
iframe.onload = () => {
|
|
- callback()
|
|
|
|
|
|
+ callback && callback()
|
|
}
|
|
}
|
|
|
|
+ document.body.appendChild(iframe);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -738,6 +764,7 @@ function initParseCard() {
|
|
checkHasDeBtn()
|
|
checkHasDeBtn()
|
|
checkHasSliderDeBtn();
|
|
checkHasSliderDeBtn();
|
|
changeQueueNum(-1)
|
|
changeQueueNum(-1)
|
|
|
|
+ showNFTCard()
|
|
}, 1000)
|
|
}, 1000)
|
|
} else if (inFacebook && inFacebookNode) {
|
|
} else if (inFacebook && inFacebookNode) {
|
|
clearInterval(timer)
|
|
clearInterval(timer)
|
|
@@ -758,13 +785,22 @@ function initParseCard() {
|
|
let inited = false
|
|
let inited = false
|
|
// 初始化
|
|
// 初始化
|
|
export function init() {
|
|
export function init() {
|
|
- if(inited){
|
|
|
|
- return
|
|
|
|
|
|
+ if (inited) {
|
|
|
|
+ return
|
|
}
|
|
}
|
|
inited = true
|
|
inited = true
|
|
console.log('init')
|
|
console.log('init')
|
|
|
|
|
|
getDiscordAuthCode();
|
|
getDiscordAuthCode();
|
|
|
|
+ appendPopupPage();
|
|
|
|
+
|
|
|
|
+ chrome.runtime.sendMessage({
|
|
|
|
+ actionType: "CONTENT_SET_POPUP_CONFIG",
|
|
|
|
+ data: {
|
|
|
|
+ popup: 'popup.html'
|
|
|
|
+ }
|
|
|
|
+ }, () => { });
|
|
|
|
+
|
|
let where = window.location.href.indexOf('twitter.com') < 0 && window.location.href.indexOf('facebook.com') < 0;
|
|
let where = window.location.href.indexOf('twitter.com') < 0 && window.location.href.indexOf('facebook.com') < 0;
|
|
if (where) {
|
|
if (where) {
|
|
return
|
|
return
|
|
@@ -772,10 +808,13 @@ export function init() {
|
|
twitterPinLogin();
|
|
twitterPinLogin();
|
|
// 渲染dom
|
|
// 渲染dom
|
|
initParseCard()
|
|
initParseCard()
|
|
-
|
|
|
|
|
|
+ showNFTCard()
|
|
renderDom();
|
|
renderDom();
|
|
checkTwitterTaskState();
|
|
checkTwitterTaskState();
|
|
|
|
|
|
|
|
+ onBodyClick();
|
|
|
|
+ initBuyNFT();
|
|
|
|
+
|
|
getChromeStorage("popupShowPublishDialog", (res) => {
|
|
getChromeStorage("popupShowPublishDialog", (res) => {
|
|
console.log("popupShowPublishDialog", res);
|
|
console.log("popupShowPublishDialog", res);
|
|
if (res && res.show) {
|
|
if (res && res.show) {
|
|
@@ -840,6 +879,13 @@ export function replyHandle(params) {
|
|
let tweetReply = document.querySelector('div[data-testid="tweetButtonInline"]');
|
|
let tweetReply = document.querySelector('div[data-testid="tweetButtonInline"]');
|
|
if (tweetReply) {
|
|
if (tweetReply) {
|
|
tweetReply.addEventListener('click', function () {
|
|
tweetReply.addEventListener('click', function () {
|
|
|
|
+ // 详情页回复按钮点击
|
|
|
|
+ Report.reportLog({
|
|
|
|
+ pageSource: Report.pageSource.mainPage,
|
|
|
|
+ businessType: Report.businessType.buttonClick,
|
|
|
|
+ objectType: Report.objectType.replyClickByDetailPage
|
|
|
|
+ });
|
|
|
|
+
|
|
let eleList = tweetReply.parentNode.parentNode.parentNode.parentNode.parentNode.querySelectorAll('span[data-text="true"]');
|
|
let eleList = tweetReply.parentNode.parentNode.parentNode.parentNode.parentNode.querySelectorAll('span[data-text="true"]');
|
|
reportReplyResult(eleList, params, () => {
|
|
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: {} }, '*');
|
|
@@ -889,6 +935,13 @@ function onReplyDialogOpen(params, iframe) {
|
|
|
|
|
|
if (dialog && replyBtn) {
|
|
if (dialog && replyBtn) {
|
|
replyBtn.addEventListener('click', function () {
|
|
replyBtn.addEventListener('click', function () {
|
|
|
|
+ // 推文页回复按钮点击
|
|
|
|
+ Report.reportLog({
|
|
|
|
+ pageSource: Report.pageSource.mainPage,
|
|
|
|
+ businessType: Report.businessType.buttonClick,
|
|
|
|
+ objectType: Report.objectType.replyClickByTwitterList
|
|
|
|
+ });
|
|
|
|
+
|
|
let eleList = dialog.querySelector('div[contenteditable="true"]').querySelectorAll('span[data-text="true"]');
|
|
let eleList = dialog.querySelector('div[contenteditable="true"]').querySelectorAll('span[data-text="true"]');
|
|
reportReplyResult(eleList, params, () => {
|
|
reportReplyResult(eleList, params, () => {
|
|
// 上報完成
|
|
// 上報完成
|
|
@@ -901,6 +954,15 @@ function onReplyDialogOpen(params, iframe) {
|
|
}
|
|
}
|
|
|
|
|
|
const reportReplyResult = throttle(function (eleList, params, cb) {
|
|
const reportReplyResult = throttle(function (eleList, params, cb) {
|
|
|
|
+ //未过滤的回复文本
|
|
|
|
+ Report.reportLog({
|
|
|
|
+ pageSource: Report.pageSource.mainPage,
|
|
|
|
+ businessType: Report.businessType.buttonClick,
|
|
|
|
+ objectType: Report.objectType.replyInputTextGet
|
|
|
|
+ }, {
|
|
|
|
+ replyStr: eleList
|
|
|
|
+ });
|
|
|
|
+
|
|
if (eleList && eleList.length) {
|
|
if (eleList && eleList.length) {
|
|
let atList = [];
|
|
let atList = [];
|
|
for (let i = 0; i < eleList.length; i++) {
|
|
for (let i = 0; i < eleList.length; i++) {
|
|
@@ -913,9 +975,27 @@ const reportReplyResult = throttle(function (eleList, params, cb) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 去重过滤文本
|
|
atList = Array.from(new Set(atList));
|
|
atList = Array.from(new Set(atList));
|
|
|
|
|
|
|
|
+ Report.reportLog({
|
|
|
|
+ pageSource: Report.pageSource.mainPage,
|
|
|
|
+ businessType: Report.businessType.buttonClick,
|
|
|
|
+ objectType: Report.objectType.replyFilterTextGet
|
|
|
|
+ }, {
|
|
|
|
+ replyStr: atList
|
|
|
|
+ });
|
|
|
|
+
|
|
if (atList.length >= 3) {
|
|
if (atList.length >= 3) {
|
|
|
|
+ //真实上报
|
|
|
|
+ Report.reportLog({
|
|
|
|
+ pageSource: Report.pageSource.mainPage,
|
|
|
|
+ businessType: Report.businessType.buttonClick,
|
|
|
|
+ objectType: Report.objectType.replyReport
|
|
|
|
+ }, {
|
|
|
|
+ replyStr: atList
|
|
|
|
+ });
|
|
|
|
+
|
|
fetchAddFinishEvent({
|
|
fetchAddFinishEvent({
|
|
eventType: params.type,
|
|
eventType: params.type,
|
|
luckdropId: params.taskLuckdropId
|
|
luckdropId: params.taskLuckdropId
|
|
@@ -1166,4 +1246,229 @@ const TwitterLikeAPI = (tweet_Id) => {
|
|
}).catch(() => {
|
|
}).catch(() => {
|
|
chrome.runtime.sendMessage({ actionType: "DO_TASK", do_type: 'api', tweet_Id, task_type: 'like', task_data: '', task_done: false }, () => { })
|
|
chrome.runtime.sendMessage({ actionType: "DO_TASK", do_type: 'api', tweet_Id, task_type: 'like', task_data: '', task_done: false }, () => { })
|
|
})
|
|
})
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+export const hideBuyNFT = () => {
|
|
|
|
+ let iframe = document.querySelector('#nftProjectId')
|
|
|
|
+ iframe.style.display = 'none'
|
|
|
|
+ iframe.src = ''
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+export const showBuyNFT = ({ nft_project_Id }) => {
|
|
|
|
+ if (!nft_project_Id) {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ let iframe = document.querySelector('#nftProjectId')
|
|
|
|
+ iframe.style.display = 'block'
|
|
|
|
+ iframe.src = chrome.runtime.getURL(`/iframe/buy-nft.html?nftProjectId=${nft_project_Id}`)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+const initBuyNFT = () => {
|
|
|
|
+ let url = chrome.runtime.getURL(`/iframe/buy-nft.html`)
|
|
|
|
+ let id = `nftProjectId`
|
|
|
|
+ createNFTIframe({ url, id })
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+export const showNFTCard = () => {
|
|
|
|
+ let urlInfo = new URL(window.location.href)
|
|
|
|
+ let isTwitter = urlInfo.hostname === 'twitter.com'
|
|
|
|
+ let userElem = document.querySelector('div[data-testid="UserName"]');
|
|
|
|
+ let sideElem = document.querySelector('div[data-testid="sidebarColumn"]')
|
|
|
|
+ let tabIndex = sideElem && sideElem.querySelector('div[tabindex="0"]');
|
|
|
|
+ let isAppend = document.querySelector('div[id="de-nft-node"]');
|
|
|
|
+ let where = isTwitter && userElem && tabIndex;
|
|
|
|
+ if (where) {
|
|
|
|
+ let iframe = document.createElement('iframe');
|
|
|
|
+ iframe.src = chrome.runtime.getURL(`/iframe/nft-card.html`)
|
|
|
|
+ iframe.style.cssText = 'border:medium none; width:100%; height:290px;';
|
|
|
|
+ let nftElement = document.createElement('div');
|
|
|
|
+ nftElement.id = 'de-nft-node';
|
|
|
|
+ nftElement.innerHTML = `
|
|
|
|
+ ${iframe.outerHTML}
|
|
|
|
+ <style>
|
|
|
|
+ #de-nft-node {height:290px; margin-bottom:17px; display:none;}
|
|
|
|
+ </style>
|
|
|
|
+ `;
|
|
|
|
+
|
|
|
|
+ if (tabIndex && tabIndex.firstChild && tabIndex.firstChild.childNodes && !isAppend) {
|
|
|
|
+ tabIndex.firstChild.insertBefore(nftElement, tabIndex.firstChild.childNodes[2]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+export const showNFTSale = () => {
|
|
|
|
+ document.querySelector('div[id="de-nft-node"]').style.display = 'block';
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+export const appendPopupPage = (params = {}) => {
|
|
|
|
+ let { path = '' } = params;
|
|
|
|
+
|
|
|
|
+ let iframe = document.createElement('iframe');
|
|
|
|
+ iframe.id = 'de-popup-page';
|
|
|
|
+ iframe.src = chrome.runtime.getURL('/iframe/popup-page.html') + `#${path}`;
|
|
|
|
+ iframe.style.cssText = `border: medium none; width: 375px;
|
|
|
|
+ height: 650px;position: fixed; right: 16px; top: 16px;background: #FFFFFF;border: 0.5px solid #919191;box-shadow: 0px 4px 20px rgba(0, 0, 0, 0.2);box-sizing: border-box;z-index: 90000;
|
|
|
|
+ animation-duration: 0.5s !important;
|
|
|
|
+ animation-timing-function: ease-in-out !important;
|
|
|
|
+ animation-fill-mode: forwards !important;
|
|
|
|
+ transition: all 1s ease 0s !important;right: -385px;transform: translateX(385px);`
|
|
|
|
+ let iframeContent = document.getElementById('de-popup-page');
|
|
|
|
+
|
|
|
|
+ let overlayDom = document.createElement('div');
|
|
|
|
+ overlayDom.id = 'de-popup-overlay';
|
|
|
|
+ overlayDom.style.cssText = `position: fixed;z-index: 88888;top: 0;
|
|
|
|
+ left: 0;width: 100%;height: 100%;opacity: 0;display: none`;
|
|
|
|
+
|
|
|
|
+ let overlay = document.getElementById('de-popup-overlay');
|
|
|
|
+ let body = document.querySelector('body');
|
|
|
|
+
|
|
|
|
+ if (!iframeContent && body) {
|
|
|
|
+ document.querySelector('body').appendChild(iframe);
|
|
|
|
+ if(!overlay) {
|
|
|
|
+ document.querySelector('body').appendChild(overlayDom);
|
|
|
|
+
|
|
|
|
+ overlayDom.addEventListener('click', function() {
|
|
|
|
+ hidePopupPage();
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ overlay.addEventListener('click', function() {
|
|
|
|
+ hidePopupPage();
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+let showPopupPageFrom = '';
|
|
|
|
+export const showPopupPage = (params = {}) => {
|
|
|
|
+ let { path = '', from } = params;
|
|
|
|
+ showPopupPageFrom = from;
|
|
|
|
+ hidePinTips();
|
|
|
|
+ hideNoticeBindTweet();
|
|
|
|
+
|
|
|
|
+ let iframe = document.getElementById('de-popup-page');
|
|
|
|
+ if (!iframe) {
|
|
|
|
+ appendPopupPage();
|
|
|
|
+ iframe = document.getElementById('de-popup-page');
|
|
|
|
+ }
|
|
|
|
+ if(iframe) {
|
|
|
|
+ if(path) {
|
|
|
|
+ iframe.src = chrome.runtime.getURL('/iframe/popup-page.html') + `#${path}`;
|
|
|
|
+ }
|
|
|
|
+ iframe.style.transform = 'translateX(-' + 395 + 'px)';
|
|
|
|
+
|
|
|
|
+ chrome.runtime.sendMessage({
|
|
|
|
+ actionType: "CONTENT_POPUP_PAGE_SHOW",
|
|
|
|
+ data: { }
|
|
|
|
+ }, () => { });
|
|
|
|
+
|
|
|
|
+ chrome.runtime.sendMessage({
|
|
|
|
+ actionType: "CONTENT_SET_POPUP_CONFIG",
|
|
|
|
+ data: {
|
|
|
|
+ popup: ''
|
|
|
|
+ }
|
|
|
|
+ }, () => { });
|
|
|
|
+
|
|
|
|
+ let overlay = document.getElementById('de-popup-overlay');
|
|
|
|
+ overlay.style.display = 'block';
|
|
|
|
+
|
|
|
|
+ let htmlDom = document.querySelector('html');
|
|
|
|
+ if(htmlDom) {
|
|
|
|
+ htmlDom.style.overflowY = 'hidden';
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+export const hidePopupPage = () => {
|
|
|
|
+ let iframe = document.getElementById('de-popup-page');
|
|
|
|
+ if (iframe) {
|
|
|
|
+ iframe.style.transform = 'translateX(' + 385 + 'px)';
|
|
|
|
+
|
|
|
|
+ let overlay = document.getElementById('de-popup-overlay');
|
|
|
|
+ overlay.style.display = 'none';
|
|
|
|
+
|
|
|
|
+ let htmlDom = document.querySelector('html');
|
|
|
|
+ if(htmlDom) {
|
|
|
|
+ htmlDom.style.overflowY = 'auto';
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ chrome.runtime.sendMessage({
|
|
|
|
+ actionType: "CONTENT_SET_POPUP_CONFIG",
|
|
|
|
+ data: {
|
|
|
|
+ popup: 'popup.html'
|
|
|
|
+ }
|
|
|
|
+ }, () => { });
|
|
|
|
+
|
|
|
|
+ if(showPopupPageFrom == 'BUY_NFT_FINISH') {
|
|
|
|
+ chrome.runtime.sendMessage({
|
|
|
|
+ actionType: "CONTENT_GET_PINED",
|
|
|
|
+ data: {}
|
|
|
|
+ }, () => { });
|
|
|
|
+ showPopupPageFrom = '';
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+export const tiggerInjectPopupPage = () => {
|
|
|
|
+ let iframeContent = document.getElementById('de-popup-page');
|
|
|
|
+ if (iframeContent) {
|
|
|
|
+ hidePinTips();
|
|
|
|
+ hideNoticeBindTweet();
|
|
|
|
+ let {transform = ''} = iframeContent.style;
|
|
|
|
+ if(transform == 'translateX(385px)' || !transform) {
|
|
|
|
+ showPopupPage();
|
|
|
|
+ } else {
|
|
|
|
+ hidePopupPage();
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ appendPopupPage();
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ let iframe = document.getElementById('de-popup-page');
|
|
|
|
+ let {transform = ''} = iframe.style;
|
|
|
|
+ if(transform == 'translateX(385px)' || !transform) {
|
|
|
|
+ showPopupPage();
|
|
|
|
+ } else {
|
|
|
|
+ hidePopupPage();
|
|
|
|
+ }
|
|
|
|
+ }, 300)
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+const onBodyClick = () => {
|
|
|
|
+ if(window.location.href.indexOf('api.twitter.com') < 0) {
|
|
|
|
+ document.querySelector('body').addEventListener('click', function () {
|
|
|
|
+ console.log('click')
|
|
|
|
+ // hidePopupPage();
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+export const setPopupConfByPopupPage = () => {
|
|
|
|
+ let iframe = document.getElementById('de-popup-page');
|
|
|
|
+ if (iframe) {
|
|
|
|
+ let {transform = ''} = iframe.style;
|
|
|
|
+
|
|
|
|
+ if(transform && transform == 'translateX(-395px)') {
|
|
|
|
+ chrome.runtime.sendMessage({
|
|
|
|
+ actionType: "CONTENT_SET_POPUP_CONFIG",
|
|
|
|
+ data: {
|
|
|
|
+ popup: ''
|
|
|
|
+ }
|
|
|
|
+ }, () => { });
|
|
|
|
+ } else {
|
|
|
|
+ chrome.runtime.sendMessage({
|
|
|
|
+ actionType: "CONTENT_SET_POPUP_CONFIG",
|
|
|
|
+ data: {
|
|
|
|
+ popup: 'popup.html'
|
|
|
|
+ }
|
|
|
|
+ }, () => { });
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ chrome.runtime.sendMessage({
|
|
|
|
+ actionType: "CONTENT_SET_POPUP_CONFIG",
|
|
|
|
+ data: {
|
|
|
|
+ popup: 'popup.html'
|
|
|
|
+ }
|
|
|
|
+ }, () => { });
|
|
|
|
+ }
|
|
}
|
|
}
|