|
@@ -4,7 +4,7 @@ import { discordAuthRedirectUri } from '@/http/configAPI'
|
|
|
import { reportSrcPublishEvent } from '@/http/publishApi'
|
|
|
import Report from "@/log-center/log"
|
|
|
import { fetchAddFinishEvent } from '@/logic/background/fetch/facebook';
|
|
|
-import { showNFTGroupIcon, hideNFTGroupList, checkUserJoinGroup } from '@/logic/content/nft';
|
|
|
+import { showNFTGroupIcon, hideNFTGroupList, checkUserJoinGroup, addJoinedGroupList } from '@/logic/content/nft';
|
|
|
|
|
|
let dom = {};
|
|
|
|
|
@@ -768,6 +768,7 @@ function initParseCard() {
|
|
|
changeQueueNum(-1)
|
|
|
showNFTCard()
|
|
|
addGroupTab();
|
|
|
+ addJoinedGroupList();
|
|
|
}, 1000)
|
|
|
} else if (inFacebook && inFacebookNode) {
|
|
|
clearInterval(timer)
|
|
@@ -819,6 +820,7 @@ export function init() {
|
|
|
checkTwitterTaskState();
|
|
|
initBuyNFT();
|
|
|
addGroupTab();
|
|
|
+ addJoinedGroupList();
|
|
|
|
|
|
getChromeStorage("popupShowPublishDialog", (res) => {
|
|
|
console.log("popupShowPublishDialog", res);
|
|
@@ -1495,13 +1497,23 @@ export const setPopupConfByPopupPage = () => {
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
- * Group Tab List start
|
|
|
+ * 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';
|
|
@@ -1515,7 +1527,6 @@ const addGroupTab = () => {
|
|
|
display: none`;
|
|
|
|
|
|
let groupTab = document.createElement('div');
|
|
|
- groupTab.innerHTML = `Group`;
|
|
|
groupTab.id = 'de-nav-tab-group';
|
|
|
groupTab.style.cssText = `z-index: 1;
|
|
|
position: relative;
|
|
@@ -1532,6 +1543,8 @@ const addGroupTab = () => {
|
|
|
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);
|
|
|
|
|
@@ -1550,8 +1563,32 @@ const addGroupTab = () => {
|
|
|
});
|
|
|
|
|
|
addTabGroupContent();
|
|
|
+ checkNeedSelectGroupTab();
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * 跳转到个人主页 检查是否需要选中 Group tab
|
|
|
+ */
|
|
|
+const checkNeedSelectGroupTab = () => {
|
|
|
+ if(window.location.pathname != '/home') {
|
|
|
+ setTimeout(() => {
|
|
|
+ const urlParams = new URLSearchParams(window.location.search);
|
|
|
+ const deTabVal = urlParams.get('deTabVal');
|
|
|
+ if (deTabVal == 'deGroupTab') {
|
|
|
+ selectGroupTab();
|
|
|
+ }
|
|
|
+ }, 500)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/** 选中 Group tab */
|
|
|
+const selectGroupTab = () => {
|
|
|
+ let groupTab = document.querySelector('#de-nav-tab-group');
|
|
|
+ if(groupTab) {
|
|
|
+ groupTab.click();
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
/**
|
|
|
*
|
|
|
* Group tab点击事件监听
|
|
@@ -1678,11 +1715,6 @@ const setTabContentStyle = (params) => {
|
|
|
} else {
|
|
|
tweetTabContent.style.display = tweetTabContentDisply;
|
|
|
}
|
|
|
- } else {
|
|
|
- tweetTabContent = document.querySelector('div[data-testid="emptyState"]');
|
|
|
- if(tweetTabContent) {
|
|
|
- tweetTabContent.style.display = tweetTabContentDisply;
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
let iframeContent = document.getElementById('de-tab-group-content');
|
|
@@ -1703,7 +1735,7 @@ const setTabContentStyle = (params) => {
|
|
|
* 获取 twitter tab 下的内容
|
|
|
*/
|
|
|
const getTweetTabContent = () => {
|
|
|
- let tweetTabContent = document.querySelector('[data-testid="primaryColumn"] [role="navigation"] + * > div[aria-label]:not([role="progressbar"])');
|
|
|
+ let tweetTabContent = document.querySelector('[data-testid="primaryColumn"] [role="navigation"] + * > div[aria-label]:not([role="progressbar"])') || document.querySelector('div[data-testid="emptyState"]');
|
|
|
return tweetTabContent;
|
|
|
}
|
|
|
|
|
@@ -1711,9 +1743,12 @@ const getTweetTabContent = () => {
|
|
|
* 注入 Group List 内容
|
|
|
*/
|
|
|
const addTabGroupContent = () => {
|
|
|
+ let params = {
|
|
|
+ windowLocation: window.location
|
|
|
+ }
|
|
|
let iframe = document.createElement('iframe');
|
|
|
iframe.id = 'de-tab-group-content';
|
|
|
- iframe.src = chrome.runtime.getURL('/iframe/tab-group.html');
|
|
|
+ iframe.src = chrome.runtime.getURL('/iframe/tab-group.html') + `?params=${JSON.stringify(params)}`;
|
|
|
iframe.style.cssText = `border: medium none; height: 500px;display: none`
|
|
|
|
|
|
let iframeContent = document.getElementById('de-tab-group-content');
|
|
@@ -1722,11 +1757,6 @@ const addTabGroupContent = () => {
|
|
|
if (!iframeContent) {
|
|
|
if(tweetTabContent && tweetTabContent.parentElement) {
|
|
|
tweetTabContent.parentElement.appendChild(iframe);
|
|
|
- } else {
|
|
|
- tweetTabContent = document.querySelector('div[data-testid="emptyState"]');
|
|
|
- if(tweetTabContent && tweetTabContent.parentElement) {
|
|
|
- tweetTabContent.parentElement.appendChild(iframe);
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
};
|
|
@@ -1736,24 +1766,36 @@ const addTabGroupContent = () => {
|
|
|
* 设置Tab Group Iframe 样式
|
|
|
*/
|
|
|
export const setTabGroupIframeStyle = (params) => {
|
|
|
- let {height = 0} = params;
|
|
|
- // if(height > 0) {
|
|
|
- let iframeContent = document.getElementById('de-tab-group-content');
|
|
|
- // iframeContent.style.height = height + 'px';
|
|
|
- iframeContent.style.height = document.querySelector('html').offsetHeight + 'px';
|
|
|
- // }
|
|
|
+ let iframeContent = document.getElementById('de-tab-group-content');
|
|
|
+ iframeContent.style.height = document.querySelector('html').offsetHeight + 'px';
|
|
|
+}
|
|
|
+
|
|
|
+export const pageJumpHandler = (params) => {
|
|
|
+ let {url, name = '_self'} = params
|
|
|
+ window.open(url, name)
|
|
|
}
|
|
|
|
|
|
+export const getTweetProfileNavTop = (params) => {
|
|
|
+ let top = document.querySelector('div[role="tablist"]').closest('nav').getBoundingClientRect().top;
|
|
|
+
|
|
|
+ chrome.runtime.sendMessage({ actionType: "CONTENT_SEND_GROUP_NAV_TOP", data: {
|
|
|
+ top,
|
|
|
+ scrollTop: params.scrollTop
|
|
|
+ } }, () => { })
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
*
|
|
|
- * Group Tab List end
|
|
|
+ * Group Tab List End
|
|
|
*
|
|
|
*/
|
|
|
|
|
|
+
|
|
|
export const loginSuccessHandle = () => {
|
|
|
// 检查是否漏出group图标
|
|
|
checkUserJoinGroup(() => {
|
|
|
showNFTGroupIcon()
|
|
|
addEventAction()
|
|
|
+ addJoinedGroupList();
|
|
|
})
|
|
|
}
|