|
@@ -5,9 +5,16 @@ import { reportSrcPublishEvent } from '@/http/publishApi'
|
|
|
import Report from "@/log-center/log"
|
|
|
import { fetchAddFinishEvent } from '@/logic/background/fetch/facebook';
|
|
|
import { showNFTGroupIcon, hideNFTGroupList, checkUserJoinGroup, elemAddEventListener, addJoinedGroupList } from '@/logic/content/nft';
|
|
|
+import { getTwitterNftGroupInfo } from '@/http/nft'
|
|
|
|
|
|
let dom = {};
|
|
|
|
|
|
+let tweetAccountBindGroupInfo = {
|
|
|
+ isBind: false,
|
|
|
+ groupInfo: null,
|
|
|
+ isInit: false
|
|
|
+}
|
|
|
+
|
|
|
function twitterPinLogin() {
|
|
|
if (window.location.href == 'https://api.twitter.com/oauth/authorize') {
|
|
|
let code = document.querySelector('code')
|
|
@@ -825,9 +832,12 @@ export function init() {
|
|
|
renderDom();
|
|
|
checkTwitterTaskState();
|
|
|
initBuyNFT();
|
|
|
- addGroupTab();
|
|
|
addJoinedGroupList();
|
|
|
|
|
|
+ // getTweetAccountGroupInfo( () => {
|
|
|
+ addGroupTab()
|
|
|
+ // })
|
|
|
+
|
|
|
getChromeStorage("popupShowPublishDialog", (res) => {
|
|
|
console.log("popupShowPublishDialog", res);
|
|
|
if (res && res.show) {
|
|
@@ -1645,70 +1655,82 @@ export const setPopupConfByPopupPage = () => {
|
|
|
* Group Tab List Start
|
|
|
*/
|
|
|
|
|
|
-const addGroupTab = () => {
|
|
|
- let tabListDom = document.querySelector('div[role="tablist"]');
|
|
|
- let groupItemTab = document.querySelector('#de-nav-tab-group');
|
|
|
-
|
|
|
- let groupIcon = document.createElement('img');
|
|
|
- groupIcon.id = 'de-group-tab-icon'
|
|
|
- groupIcon.src = require("@/assets/img/icon-group-tab-item.png");
|
|
|
- groupIcon.style.cssText = 'width:20px;height: 20px;margin-right:4px;';
|
|
|
-
|
|
|
- let divNode = document.createElement('div');
|
|
|
- divNode.style.cssText = 'display: flex; align-items: center';
|
|
|
- divNode.appendChild(groupIcon);
|
|
|
- divNode.appendChild(document.createTextNode('Group'));
|
|
|
-
|
|
|
- if(tabListDom && !groupItemTab) {
|
|
|
- let lineDom = document.createElement('div');
|
|
|
- lineDom.id = 'de-tab-line';
|
|
|
- lineDom.style.cssText = `border-radius: 9999px;
|
|
|
- position: absolute;
|
|
|
- bottom: 0px;
|
|
|
- min-width: 56px;
|
|
|
- align-self: center;
|
|
|
- height: 4px;
|
|
|
- background-color: rgb(29, 155, 240);
|
|
|
- display: none`;
|
|
|
-
|
|
|
- let groupTab = document.createElement('div');
|
|
|
- groupTab.id = 'de-nav-tab-group';
|
|
|
- groupTab.style.cssText = `z-index: 1;
|
|
|
- position: relative;
|
|
|
- display: flex;
|
|
|
- min-width: 56px;
|
|
|
- -webkit-box-pack: center;
|
|
|
- justify-content: center;
|
|
|
- -webkit-box-align: center;
|
|
|
- align-items: center;
|
|
|
- text-align: center;
|
|
|
- padding: 0px 16px;
|
|
|
- color: rgb(83, 100, 113);
|
|
|
- font-weight: 700;
|
|
|
- height: 53px;
|
|
|
- cursor: pointer;
|
|
|
- font: 500 15px / 20px TwitterChirp, -apple-system, "system-ui", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;`;
|
|
|
-
|
|
|
- groupTab.appendChild(divNode);
|
|
|
- groupTab.appendChild(lineDom);
|
|
|
- tabListDom.appendChild(groupTab);
|
|
|
-
|
|
|
- groupTab.addEventListener('mouseenter', function() {
|
|
|
- groupTab.style.background = 'rgba(15, 20, 25, 0.1)'
|
|
|
- });
|
|
|
- groupTab.addEventListener('mouseleave', function() {
|
|
|
- groupTab.style.background = 'none'
|
|
|
+const addGroupTab = () => {
|
|
|
+ // if(!tweetAccountBindGroupInfo.isInit) {
|
|
|
+ // getTweetAccountGroupInfo(() => {
|
|
|
+ // main();
|
|
|
+ // })
|
|
|
+ // } else {
|
|
|
+ main();
|
|
|
+ // }
|
|
|
+ function main() {
|
|
|
+ // if(!tweetAccountBindGroupInfo.isBind) {
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ let tabListDom = document.querySelector('div[role="tablist"]');
|
|
|
+ let groupItemTab = document.querySelector('#de-nav-tab-group');
|
|
|
+
|
|
|
+ let groupIcon = document.createElement('img');
|
|
|
+ groupIcon.id = 'de-group-tab-icon'
|
|
|
+ groupIcon.src = require("@/assets/img/icon-group-tab-item.png");
|
|
|
+ groupIcon.style.cssText = 'width:20px;height: 20px;margin-right:4px;';
|
|
|
+
|
|
|
+ let divNode = document.createElement('div');
|
|
|
+ divNode.style.cssText = 'display: flex; align-items: center';
|
|
|
+ divNode.appendChild(groupIcon);
|
|
|
+ divNode.appendChild(document.createTextNode('Group'));
|
|
|
+
|
|
|
+ if(tabListDom && !groupItemTab) {
|
|
|
+ let lineDom = document.createElement('div');
|
|
|
+ lineDom.id = 'de-tab-line';
|
|
|
+ lineDom.style.cssText = `border-radius: 9999px;
|
|
|
+ position: absolute;
|
|
|
+ bottom: 0px;
|
|
|
+ min-width: 56px;
|
|
|
+ align-self: center;
|
|
|
+ height: 4px;
|
|
|
+ background-color: rgb(29, 155, 240);
|
|
|
+ display: none`;
|
|
|
+
|
|
|
+ let groupTab = document.createElement('div');
|
|
|
+ groupTab.id = 'de-nav-tab-group';
|
|
|
+ groupTab.style.cssText = `z-index: 1;
|
|
|
+ position: relative;
|
|
|
+ display: flex;
|
|
|
+ min-width: 56px;
|
|
|
+ -webkit-box-pack: center;
|
|
|
+ justify-content: center;
|
|
|
+ -webkit-box-align: center;
|
|
|
+ align-items: center;
|
|
|
+ text-align: center;
|
|
|
+ padding: 0px 16px;
|
|
|
+ color: rgb(83, 100, 113);
|
|
|
+ font-weight: 700;
|
|
|
+ height: 53px;
|
|
|
+ cursor: pointer;
|
|
|
+ font: 500 15px / 20px TwitterChirp, -apple-system, "system-ui", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;`;
|
|
|
+
|
|
|
+ groupTab.appendChild(divNode);
|
|
|
+ groupTab.appendChild(lineDom);
|
|
|
+ tabListDom.appendChild(groupTab);
|
|
|
+
|
|
|
+ groupTab.addEventListener('mouseenter', function() {
|
|
|
+ groupTab.style.background = 'rgba(15, 20, 25, 0.1)'
|
|
|
+ });
|
|
|
+ groupTab.addEventListener('mouseleave', function() {
|
|
|
+ groupTab.style.background = 'none'
|
|
|
+ });
|
|
|
+
|
|
|
+ addGroupTabEventListener({groupTab});
|
|
|
+ }
|
|
|
+
|
|
|
+ addTweetTabEventListener({
|
|
|
+ tabListDom
|
|
|
});
|
|
|
|
|
|
- addGroupTabEventListener({groupTab});
|
|
|
+ addTabGroupContent();
|
|
|
+ checkNeedSelectGroupTab();
|
|
|
}
|
|
|
-
|
|
|
- addTweetTabEventListener({
|
|
|
- tabListDom
|
|
|
- });
|
|
|
-
|
|
|
- addTabGroupContent();
|
|
|
- checkNeedSelectGroupTab();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1727,7 +1749,7 @@ const checkNeedSelectGroupTab = () => {
|
|
|
}
|
|
|
|
|
|
/** 选中 Group tab */
|
|
|
-const selectGroupTab = () => {
|
|
|
+export const selectGroupTab = () => {
|
|
|
let groupTab = document.querySelector('#de-nav-tab-group');
|
|
|
if(groupTab) {
|
|
|
groupTab.click();
|
|
@@ -1755,6 +1777,9 @@ const addGroupTabEventListener = (params) => {
|
|
|
|
|
|
refreshTabGroup();
|
|
|
|
|
|
+ chrome.runtime.sendMessage({ actionType: "SWITCH_GROUP_BANNER_STATUS",
|
|
|
+ data: {type: 'btn'}}, () => {});
|
|
|
+
|
|
|
window.addEventListener('scroll', addPageScrollEvent)
|
|
|
})
|
|
|
}
|
|
@@ -1800,6 +1825,9 @@ const addTweetTabEventListener = (params) => {
|
|
|
setTweetActiveTabStyle({
|
|
|
color: 'rgb(15, 20, 25)',
|
|
|
display: 'block'});
|
|
|
+
|
|
|
+ chrome.runtime.sendMessage({ actionType: "SWITCH_GROUP_BANNER_STATUS",
|
|
|
+ data: {type: 'arrow'}}, () => {});
|
|
|
})
|
|
|
}
|
|
|
}
|
|
@@ -1943,4 +1971,54 @@ export const loginSuccessHandle = () => {
|
|
|
addEventAction()
|
|
|
addJoinedGroupList();
|
|
|
})
|
|
|
-}
|
|
|
+}
|
|
|
+
|
|
|
+export const setGroupInfo = (params) => {
|
|
|
+ tweetAccountBindGroupInfo.groupInfo = params.data;
|
|
|
+ if(!params.data.nftGroupId) {
|
|
|
+ let groupTab = document.querySelector('#de-nav-tab-group');
|
|
|
+ if(groupTab) {
|
|
|
+ groupTab.style.display = 'none';
|
|
|
+ } else {
|
|
|
+ setTimeout(() => {
|
|
|
+ groupTab = document.querySelector('#de-nav-tab-group');
|
|
|
+ if(groupTab) {
|
|
|
+ groupTab.style.display = 'none';
|
|
|
+ }
|
|
|
+ }, 500)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const getTweetAccountGroupInfo = (cb) => {
|
|
|
+ let arr = window.location.pathname.split('/') || [];
|
|
|
+ let tabListDom = document.querySelector('div[role="tablist"]');
|
|
|
+ if (arr.length == 2 && tabListDom && !tweetAccountBindGroupInfo.isInit) {
|
|
|
+ let twitterAccount = arr[1];
|
|
|
+ tweetAccountBindGroupInfo.isInit = true;
|
|
|
+ getTwitterNftGroupInfo({
|
|
|
+ params: {
|
|
|
+ twitterAccount
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ if(res.code == 0) {
|
|
|
+ if(res.data) {
|
|
|
+ tweetAccountBindGroupInfo.groupInfo = res.data;
|
|
|
+ tweetAccountBindGroupInfo.isBind = true;
|
|
|
+ } else {
|
|
|
+ tweetAccountBindGroupInfo = {
|
|
|
+ isBind: false,
|
|
|
+ groupInfo: null
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ tweetAccountBindGroupInfo = {
|
|
|
+ isBind: false,
|
|
|
+ groupInfo: null
|
|
|
+ }
|
|
|
+ }
|
|
|
+ cb && cb()
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|
|
|
+
|