|
@@ -639,6 +639,7 @@ function bindTwitterArtMethod() {
|
|
|
|
|
|
|
|
|
import parseCard from './ParseCard'
|
|
|
+import { renderThumbStyle } from 'element-plus'
|
|
|
|
|
|
// 检测dom改变
|
|
|
// 获取短链接
|
|
@@ -709,13 +710,15 @@ function setIframeRedPacket(type = 'twitter') {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// 监听点击发推 按钮绑定事件
|
|
|
+// 监听点击发推 上报文案
|
|
|
// document.addEventListener('click', (e) => {
|
|
|
// try {
|
|
|
+// let inputEle = document.querySelector('div[contenteditable="true"]');
|
|
|
// if (e.target.dataset && e.target.dataset.testid && e.target.dataset.testid == 'tweetButton') {
|
|
|
-// bindTwitterArtMethod()
|
|
|
+// // 获取文案上报
|
|
|
+// console.log(inputEle.innerText)
|
|
|
// } else if (e.target.closest('div[data-testid=tweetButton]')) {
|
|
|
-// bindTwitterArtMethod()
|
|
|
+// console.log(inputEle.innerText)
|
|
|
// }
|
|
|
// } catch (error) {
|
|
|
// console.error('error', error)
|
|
@@ -765,6 +768,7 @@ function initParseCard() {
|
|
|
checkHasSliderDeBtn();
|
|
|
changeQueueNum(-1)
|
|
|
showNFTCard()
|
|
|
+ initGroupTip()
|
|
|
}, 1000)
|
|
|
} else if (inFacebook && inFacebookNode) {
|
|
|
clearInterval(timer)
|
|
@@ -794,11 +798,11 @@ export function init() {
|
|
|
getDiscordAuthCode();
|
|
|
appendPopupPage();
|
|
|
|
|
|
- chrome.runtime.sendMessage({
|
|
|
- actionType: "CONTENT_SET_POPUP_CONFIG",
|
|
|
+ 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;
|
|
@@ -1156,6 +1160,12 @@ export function doTaskTwitterAPI({ task_data, task_type }) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+export function showJoinDialog(data) {
|
|
|
+ let iframe = document.querySelector('#nftProjectId')
|
|
|
+ iframe.style.display = 'block'
|
|
|
+ iframe.src = chrome.runtime.getURL(`/iframe/buy-nft.html#/group?type=${data.type}&buy_nft_status=${data.buy_nft_status}&nft_group_Id=${data.nft_group_Id}`)
|
|
|
+}
|
|
|
+
|
|
|
const TwitterFollowAPI = (item, tweet_Id) => {
|
|
|
fetch("https://twitter.com/i/api/1.1/friendships/create.json", {
|
|
|
"headers": {
|
|
@@ -1248,6 +1258,128 @@ const TwitterLikeAPI = (tweet_Id) => {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+export const showTwitterPost = (data) => {
|
|
|
+ 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();
|
|
|
+ }
|
|
|
+ content_get_nft_post_pre({
|
|
|
+ groupId: data.groupId
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+function publishNFTTweetEvent({ groupId, postId, srcContent }) {
|
|
|
+ setTimeout(() => {
|
|
|
+ let publishTweetBtn;
|
|
|
+ let dialog = document.querySelector('div[role="dialog"]');
|
|
|
+ if (dialog) {
|
|
|
+ publishTweetBtn = dialog.querySelector('div[data-testid="tweetButton"]');
|
|
|
+ } else {
|
|
|
+ let domMain = document.querySelector('main[role="main"]');
|
|
|
+ publishTweetBtn = domMain && domMain.querySelector('div[data-testid="tweetButton"]');
|
|
|
+ }
|
|
|
+ publishTweetBtn.dataset.denet = 'nft'
|
|
|
+ publishTweetBtn && publishTweetBtn.addEventListener('click', function () {
|
|
|
+ // 获取文案上报
|
|
|
+ let inputEle = document.querySelector('div[contenteditable="true"]');
|
|
|
+ let textContent = inputEle.innerText
|
|
|
+ let arr = srcContent.split(' ') || []
|
|
|
+
|
|
|
+ arr.forEach((item) => {
|
|
|
+ if (textContent.includes(item)) {
|
|
|
+ textContent = textContent.replaceAll(item, '')
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ let formData = {
|
|
|
+ groupId,
|
|
|
+ textContent
|
|
|
+ }
|
|
|
+ let params = {
|
|
|
+ postBizData: JSON.stringify(formData),
|
|
|
+ postSrc: 1, //1 twitter
|
|
|
+ postType: 2, //2 nft
|
|
|
+ postId
|
|
|
+ }
|
|
|
+ chrome.runtime.sendMessage({
|
|
|
+ actionType: "CONTENT_NFT_TXT_PUBLISH",
|
|
|
+ data: params
|
|
|
+ }, () => { });
|
|
|
+ });
|
|
|
+ }, 800)
|
|
|
+}
|
|
|
+
|
|
|
+const content_get_nft_post_pre = (data) => {
|
|
|
+ chrome.runtime.sendMessage({
|
|
|
+ actionType: "CONTENT_GET_TWITTER_NFT_POST_PRE",
|
|
|
+ data
|
|
|
+ }, () => { });
|
|
|
+}
|
|
|
+
|
|
|
+let tweet_nft_content = {}
|
|
|
+export const setTwitterTextarea = (params) => {
|
|
|
+ tweet_nft_content = params
|
|
|
+ let inputEle = document.querySelector('div[contenteditable="true"]');
|
|
|
+ if (inputEle) {
|
|
|
+ inputEle.focus();
|
|
|
+ document.execCommand("insertText", false, '');
|
|
|
+ }
|
|
|
+ setTimeout(() => {
|
|
|
+ document.execCommand("insertText", false, params.srcContent);
|
|
|
+ }, 1000);
|
|
|
+
|
|
|
+ publishNFTTweetEvent(params)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+const initGroupTip = () => {
|
|
|
+ let arr = window.location.pathname.split('/') || []
|
|
|
+ if (arr.length == 2) {
|
|
|
+ let twitterAccount = arr[1]
|
|
|
+ addGroupTip(twitterAccount)
|
|
|
+ }
|
|
|
+}
|
|
|
+export const showGroupTip = () => {
|
|
|
+ let dom_denet_group_tip = document.querySelector('#denet_group_tip')
|
|
|
+ dom_denet_group_tip.style.display = 'block'
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+const addGroupTip = (twitterAccount) => {
|
|
|
+ let dom_denet_group_tip = document.querySelector('#denet_group_tip')
|
|
|
+ if (dom_denet_group_tip) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ let nav_list = document.querySelectorAll('nav[role=navigation]') || []
|
|
|
+ let dom
|
|
|
+ for (let i in nav_list) {
|
|
|
+ if (nav_list[i] && nav_list[i].querySelector('div[data-testid="ScrollSnap-SwipeableList"]')) {
|
|
|
+ dom = nav_list[i]
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ let iframe = document.createElement('iframe')
|
|
|
+ iframe.id = 'denet_group_tip'
|
|
|
+ iframe.style.cssText = 'border: medium none; display:none; width:100%; height:100px;'
|
|
|
+
|
|
|
+ iframe.src = chrome.runtime.getURL(`/iframe/group-card.html?twitterAccount=${twitterAccount}`)
|
|
|
+
|
|
|
+ if (dom) {
|
|
|
+ dom.parentNode.insertBefore(iframe, dom)
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (error) {
|
|
|
+
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
export const hideBuyNFT = () => {
|
|
|
let iframe = document.querySelector('#nftProjectId')
|
|
|
iframe.style.display = 'none'
|
|
@@ -1304,9 +1436,9 @@ 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;
|
|
|
+ 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;
|
|
@@ -1315,8 +1447,8 @@ export const appendPopupPage = (params = {}) => {
|
|
|
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;
|
|
|
+ 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');
|
|
@@ -1324,14 +1456,14 @@ export const appendPopupPage = (params = {}) => {
|
|
|
|
|
|
if (!iframeContent && body) {
|
|
|
document.querySelector('body').appendChild(iframe);
|
|
|
- if(!overlay) {
|
|
|
+ if (!overlay) {
|
|
|
document.querySelector('body').appendChild(overlayDom);
|
|
|
|
|
|
- overlayDom.addEventListener('click', function() {
|
|
|
+ overlayDom.addEventListener('click', function () {
|
|
|
hidePopupPage();
|
|
|
})
|
|
|
} else {
|
|
|
- overlay.addEventListener('click', function() {
|
|
|
+ overlay.addEventListener('click', function () {
|
|
|
hidePopupPage();
|
|
|
})
|
|
|
}
|
|
@@ -1350,29 +1482,29 @@ export const showPopupPage = (params = {}) => {
|
|
|
appendPopupPage();
|
|
|
iframe = document.getElementById('de-popup-page');
|
|
|
}
|
|
|
- if(iframe) {
|
|
|
- if(path) {
|
|
|
+ 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_POPUP_PAGE_SHOW",
|
|
|
+ data: {}
|
|
|
}, () => { });
|
|
|
|
|
|
- chrome.runtime.sendMessage({
|
|
|
- actionType: "CONTENT_SET_POPUP_CONFIG",
|
|
|
+ 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) {
|
|
|
+ if (htmlDom) {
|
|
|
htmlDom.style.overflowY = 'hidden';
|
|
|
}
|
|
|
}
|
|
@@ -1387,21 +1519,21 @@ export const hidePopupPage = () => {
|
|
|
overlay.style.display = 'none';
|
|
|
|
|
|
let htmlDom = document.querySelector('html');
|
|
|
- if(htmlDom) {
|
|
|
+ if (htmlDom) {
|
|
|
htmlDom.style.overflowY = 'auto';
|
|
|
}
|
|
|
|
|
|
- chrome.runtime.sendMessage({
|
|
|
- actionType: "CONTENT_SET_POPUP_CONFIG",
|
|
|
+ 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: {}
|
|
|
+ if (showPopupPageFrom == 'BUY_NFT_FINISH') {
|
|
|
+ chrome.runtime.sendMessage({
|
|
|
+ actionType: "CONTENT_GET_PINED",
|
|
|
+ data: {}
|
|
|
}, () => { });
|
|
|
showPopupPageFrom = '';
|
|
|
}
|
|
@@ -1413,8 +1545,8 @@ export const tiggerInjectPopupPage = () => {
|
|
|
if (iframeContent) {
|
|
|
hidePinTips();
|
|
|
hideNoticeBindTweet();
|
|
|
- let {transform = ''} = iframeContent.style;
|
|
|
- if(transform == 'translateX(385px)' || !transform) {
|
|
|
+ let { transform = '' } = iframeContent.style;
|
|
|
+ if (transform == 'translateX(385px)' || !transform) {
|
|
|
showPopupPage();
|
|
|
} else {
|
|
|
hidePopupPage();
|
|
@@ -1423,8 +1555,8 @@ export const tiggerInjectPopupPage = () => {
|
|
|
appendPopupPage();
|
|
|
setTimeout(() => {
|
|
|
let iframe = document.getElementById('de-popup-page');
|
|
|
- let {transform = ''} = iframe.style;
|
|
|
- if(transform == 'translateX(385px)' || !transform) {
|
|
|
+ let { transform = '' } = iframe.style;
|
|
|
+ if (transform == 'translateX(385px)' || !transform) {
|
|
|
showPopupPage();
|
|
|
} else {
|
|
|
hidePopupPage();
|
|
@@ -1434,41 +1566,41 @@ export const tiggerInjectPopupPage = () => {
|
|
|
}
|
|
|
|
|
|
const onBodyClick = () => {
|
|
|
- if(window.location.href.indexOf('api.twitter.com') < 0) {
|
|
|
+ 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;
|
|
|
+ let { transform = '' } = iframe.style;
|
|
|
|
|
|
- if(transform && transform == 'translateX(-395px)') {
|
|
|
- chrome.runtime.sendMessage({
|
|
|
- actionType: "CONTENT_SET_POPUP_CONFIG",
|
|
|
+ if (transform && transform == 'translateX(-395px)') {
|
|
|
+ chrome.runtime.sendMessage({
|
|
|
+ actionType: "CONTENT_SET_POPUP_CONFIG",
|
|
|
data: {
|
|
|
popup: ''
|
|
|
- }
|
|
|
+ }
|
|
|
}, () => { });
|
|
|
} else {
|
|
|
- chrome.runtime.sendMessage({
|
|
|
- actionType: "CONTENT_SET_POPUP_CONFIG",
|
|
|
+ chrome.runtime.sendMessage({
|
|
|
+ actionType: "CONTENT_SET_POPUP_CONFIG",
|
|
|
data: {
|
|
|
popup: 'popup.html'
|
|
|
- }
|
|
|
+ }
|
|
|
}, () => { });
|
|
|
}
|
|
|
} else {
|
|
|
- chrome.runtime.sendMessage({
|
|
|
- actionType: "CONTENT_SET_POPUP_CONFIG",
|
|
|
+ chrome.runtime.sendMessage({
|
|
|
+ actionType: "CONTENT_SET_POPUP_CONFIG",
|
|
|
data: {
|
|
|
popup: 'popup.html'
|
|
|
- }
|
|
|
+ }
|
|
|
}, () => { });
|
|
|
}
|
|
|
}
|