|
@@ -1,6 +1,6 @@
|
|
|
import { getChromeStorage, setChromeStorage } from '@/uilts/chromeExtension.js'
|
|
|
import { throttle, getQueryString, getCookie, nextTick, getQueryStringByUrl } from '@/uilts/help'
|
|
|
-import { discordAuthRedirectUri } from '@/http/configAPI'
|
|
|
+import { discordAuthRedirectUri, iframeHost } from '@/http/configAPI'
|
|
|
import { reportSrcPublishEvent } from '@/http/publishApi'
|
|
|
import Report from "@/log-center/log"
|
|
|
import { fetchAddFinishEvent } from '@/logic/background/fetch/facebook';
|
|
@@ -9,6 +9,7 @@ import { jumpTwitterDetailByAlert, showEditTweet } from '@/logic/content/help/tw
|
|
|
import { clearPostContent, setGroupIconStatus } from '@/logic/content/nft.js'
|
|
|
import { toolBox } from '@/logic/content/ToolBox'
|
|
|
import axios from 'axios';
|
|
|
+import messageCenter from '@/uilts/messageCenter';
|
|
|
|
|
|
let dom = {};
|
|
|
|
|
@@ -275,66 +276,64 @@ function checkIsShowReSend(dom, params) {
|
|
|
* @param isClick
|
|
|
* @private
|
|
|
*/
|
|
|
-function _addDeNetEditBtn(params = {}) {
|
|
|
- setTimeout(() => {
|
|
|
- let toolElem = document.querySelector('div[data-testid="toolBar"]');
|
|
|
- if (toolElem) {
|
|
|
- let innerDeIcon = document.getElementById('de-btn1');
|
|
|
- if (!innerDeIcon) {
|
|
|
- toolElem.firstChild.appendChild(createTweetToolbarDenet());
|
|
|
- popupShowGiveawayDialog();
|
|
|
- Report.reportLog({
|
|
|
- pageSource: Report.pageSource.mainPage,
|
|
|
- businessType: Report.businessType.buttonView,
|
|
|
- objectType: Report.objectType.buttonSecond
|
|
|
- }, {
|
|
|
- type: 0
|
|
|
- });
|
|
|
- }
|
|
|
+ function _addDeNetEditBtn(params = {}) {
|
|
|
+ let toolElem = document.querySelector('div[data-testid="toolBar"]');
|
|
|
+ if (toolElem) {
|
|
|
+ let innerDeIcon = toolElem.querySelector('#de-btn1');
|
|
|
+ if (!innerDeIcon) {
|
|
|
+ toolElem.firstChild.appendChild(createTweetToolbarDenet());
|
|
|
+ popupShowGiveawayDialog();
|
|
|
+ Report.reportLog({
|
|
|
+ pageSource: Report.pageSource.mainPage,
|
|
|
+ businessType: Report.businessType.buttonView,
|
|
|
+ objectType: Report.objectType.buttonSecond
|
|
|
+ }, {
|
|
|
+ type: 0
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- let innerToolBoxIcon = document.getElementById('de-tool-box-btn-01');
|
|
|
- if (!innerToolBoxIcon) {
|
|
|
- toolElem.firstChild.appendChild(createTweetToolbarToolBox())
|
|
|
- Report.reportLog({
|
|
|
- pageSource: Report.pageSource.mainPage,
|
|
|
- businessType: Report.businessType.buttonView,
|
|
|
- objectType: Report.objectType.buttonSecond
|
|
|
- }, {
|
|
|
- type: 1
|
|
|
- });
|
|
|
- }
|
|
|
- } else {
|
|
|
- setTimeout(() => {
|
|
|
- let toolElem = document.querySelector('div[data-testid="toolBar"]');
|
|
|
- if (toolElem) {
|
|
|
- let innerDeIcon = document.getElementById('de-btn1');
|
|
|
- if (!innerDeIcon) {
|
|
|
- toolElem.firstChild.appendChild(createTweetToolbarDenet());
|
|
|
- popupShowGiveawayDialog();
|
|
|
- Report.reportLog({
|
|
|
- pageSource: Report.pageSource.mainPage,
|
|
|
- businessType: Report.businessType.buttonView,
|
|
|
- objectType: Report.objectType.buttonSecond
|
|
|
- }, {
|
|
|
- type: 0
|
|
|
- });
|
|
|
- }
|
|
|
+ let innerToolBoxIcon = toolElem.querySelector('#de-tool-box-btn-01');
|
|
|
+ if (!innerToolBoxIcon) {
|
|
|
+ toolElem.firstChild.appendChild(createTweetToolbarToolBox())
|
|
|
+ Report.reportLog({
|
|
|
+ pageSource: Report.pageSource.mainPage,
|
|
|
+ businessType: Report.businessType.buttonView,
|
|
|
+ objectType: Report.objectType.buttonSecond
|
|
|
+ }, {
|
|
|
+ type: 1
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ setTimeout(() => {
|
|
|
+ let toolElem = document.querySelector('div[data-testid="toolBar"]');
|
|
|
+ if (toolElem) {
|
|
|
+ let innerDeIcon = toolElem.querySelector('#de-btn1');
|
|
|
+ if (!innerDeIcon) {
|
|
|
+ toolElem.firstChild.appendChild(createTweetToolbarDenet());
|
|
|
+ popupShowGiveawayDialog();
|
|
|
+ Report.reportLog({
|
|
|
+ pageSource: Report.pageSource.mainPage,
|
|
|
+ businessType: Report.businessType.buttonView,
|
|
|
+ objectType: Report.objectType.buttonSecond
|
|
|
+ }, {
|
|
|
+ type: 0
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- let innerToolBoxIcon = document.getElementById('de-tool-box-btn-01');
|
|
|
- if (!innerToolBoxIcon) {
|
|
|
- toolElem.firstChild.appendChild(createTweetToolbarToolBox())
|
|
|
- Report.reportLog({
|
|
|
- pageSource: Report.pageSource.mainPage,
|
|
|
- businessType: Report.businessType.buttonView,
|
|
|
- objectType: Report.objectType.buttonSecond
|
|
|
- }, {
|
|
|
- type: 1
|
|
|
- });
|
|
|
- }
|
|
|
+ let innerToolBoxIcon = toolElem.querySelector('#de-tool-box-btn-01');
|
|
|
+ if (!innerToolBoxIcon) {
|
|
|
+ toolElem.firstChild.appendChild(createTweetToolbarToolBox())
|
|
|
+ Report.reportLog({
|
|
|
+ pageSource: Report.pageSource.mainPage,
|
|
|
+ businessType: Report.businessType.buttonView,
|
|
|
+ objectType: Report.objectType.buttonSecond
|
|
|
+ }, {
|
|
|
+ type: 1
|
|
|
+ });
|
|
|
}
|
|
|
- }, 1000)
|
|
|
- }
|
|
|
- })
|
|
|
+ }
|
|
|
+ }, 1000)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
const popupShowGiveawayDialog = async () => {
|
|
@@ -717,8 +716,9 @@ function onWindowResize() {
|
|
|
function checkHasDeBtn() {
|
|
|
try {
|
|
|
let toolBar = document.querySelector('div[data-testid="toolBar"]');
|
|
|
- let innerDeIcon = document.getElementById('de-btn1');
|
|
|
- if (toolBar && !innerDeIcon) {
|
|
|
+ let append = toolBar && !toolBar.querySelector('#de-btn1');
|
|
|
+
|
|
|
+ if (append) {
|
|
|
_addDeNetEditBtn();
|
|
|
}
|
|
|
} catch (e) {
|
|
@@ -741,9 +741,9 @@ export function bindTwitterArtMethod() {
|
|
|
}
|
|
|
}).then((res) => {
|
|
|
if (res.code == 0) {
|
|
|
- Report.reportLog({
|
|
|
- objectType: Report.objectType.tweetPostBinded
|
|
|
- });
|
|
|
+ // Report.reportLog({
|
|
|
+ // objectType: Report.objectType.tweetPostBinded
|
|
|
+ // });
|
|
|
bindTwitterArt.needBind = false;
|
|
|
bindTwitterArt.postId = '';
|
|
|
bindTwitterArt.isBindIng = false;
|
|
@@ -830,6 +830,26 @@ function setIframeRedPacket(type = 'twitter') {
|
|
|
} else if (item && item.post_Id && !item.post_Id.includes('/')) {
|
|
|
item.page_type = '红包'
|
|
|
parseCard.replaceDOMRedPacket(item)
|
|
|
+ // 夺宝链接
|
|
|
+ } else if (item && item.post_Id && item.post_Id.includes('treasure/')) {
|
|
|
+ // https://testh5.denetme.net/treasure/{postid}
|
|
|
+ // https://testh5.denetme.net/treasure/invite/{inviteCode}
|
|
|
+ // 邀请链接
|
|
|
+ if (item.post_Id.includes('invite/')) {
|
|
|
+ item.invite_code = item.post_Id.split('invite/')[1] || ''
|
|
|
+ item.page_type = '邀请链接'
|
|
|
+ if (item.invite_code) {
|
|
|
+ item.post_Id = ''
|
|
|
+ parseCard.replaceDOMRreasureCard(item)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 原始链接
|
|
|
+ item.page_type = '原始链接'
|
|
|
+ item.post_Id = item.post_Id.split('treasure/')[1] || ''
|
|
|
+ if (item.post_Id) {
|
|
|
+ parseCard.replaceDOMRreasureCard(item)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
if (res.need_net_short_url.length > 0) {
|
|
@@ -902,6 +922,7 @@ function initParseCard() {
|
|
|
clearInterval(timer)
|
|
|
setInterval(() => {
|
|
|
onChangePageMain(inTwitterNode)
|
|
|
+ checkHasDeBtn()
|
|
|
twitterPinLogin()
|
|
|
showNFTGroupIcon()
|
|
|
if (queue_num <= 0) {
|
|
@@ -909,7 +930,6 @@ function initParseCard() {
|
|
|
}
|
|
|
initGroupTip()
|
|
|
setIframeRedPacket()
|
|
|
- checkHasDeBtn()
|
|
|
checkHasSliderDeBtn();
|
|
|
changeQueueNum(-1)
|
|
|
showNFTCard()
|
|
@@ -1314,7 +1334,7 @@ export function getTweetAuthorByDom(params) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-export function doTaskTwitterAPI({ task_data, task_type }) {
|
|
|
+export function doTaskTwitterAPI({ task_data, task_type, tasks }) {
|
|
|
switch (task_type) {
|
|
|
case 'like':
|
|
|
TwitterLikeAPI(task_data.tweet_Id)
|
|
@@ -1329,6 +1349,32 @@ export function doTaskTwitterAPI({ task_data, task_type }) {
|
|
|
}
|
|
|
})
|
|
|
break
|
|
|
+ case 'tasks':
|
|
|
+ tasks.forEach((item) => {
|
|
|
+ //
|
|
|
+ switch (String(item.type)) {
|
|
|
+ // 关注指定用户
|
|
|
+ case '1':
|
|
|
+ item.relatedUsers.forEach((item) => {
|
|
|
+ if (item.name && item.twitterUserId) {
|
|
|
+ TwitterFollowAPI(item, task_data.tweet_Id)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ break
|
|
|
+ // 点赞
|
|
|
+ case '2':
|
|
|
+ TwitterLikeAPI(task_data.tweet_Id)
|
|
|
+ break
|
|
|
+
|
|
|
+ // 推文发推
|
|
|
+ case '10':
|
|
|
+ // 发推
|
|
|
+ TwitterApiCreateTweet({ text: task_data.tweet_text, tweet_Id: task_data.tweet_Id })
|
|
|
+ break
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
+ break
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1431,6 +1477,60 @@ const TwitterLikeAPI = (tweet_Id) => {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+const TwitterApiCreateTweet = ({ text, tweet_Id }) => {
|
|
|
+ let data = {
|
|
|
+ queryId: "hC1nuE-2d1NX5LYBuuAvtQ",
|
|
|
+ features: {
|
|
|
+ "dont_mention_me_view_api_enabled": true,
|
|
|
+ "interactive_text_enabled": true,
|
|
|
+ "responsive_web_uc_gql_enabled": false,
|
|
|
+ "vibe_api_enabled": true,
|
|
|
+ "responsive_web_edit_tweet_api_enabled": false,
|
|
|
+ "standardized_nudges_misinfo": true,
|
|
|
+ "responsive_web_enhance_cards_enabled": false
|
|
|
+ },
|
|
|
+ variables: {
|
|
|
+ "tweet_text": text,
|
|
|
+ "media": {
|
|
|
+ "media_entities": [],
|
|
|
+ "possibly_sensitive": false
|
|
|
+ },
|
|
|
+ "withDownvotePerspective": true,
|
|
|
+ "withReactionsMetadata": false,
|
|
|
+ "withReactionsPerspective": false,
|
|
|
+ "withSuperFollowsTweetFields": true,
|
|
|
+ "withSuperFollowsUserFields": true,
|
|
|
+ "semantic_annotation_ids": [],
|
|
|
+ "dark_request": false
|
|
|
+ }
|
|
|
+ };
|
|
|
+ axios.post(`https://twitter.com/i/api/graphql/hC1nuE-2d1NX5LYBuuAvtQ/CreateTweet`,
|
|
|
+ data, {
|
|
|
+ headers: {
|
|
|
+ "accept": "*/*",
|
|
|
+ "accept-language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",
|
|
|
+ "authorization": "Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA",
|
|
|
+ "content-type": "application/json",
|
|
|
+ "sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"101\", \"Google Chrome\";v=\"101\"",
|
|
|
+ "sec-ch-ua-mobile": "?0",
|
|
|
+ "sec-ch-ua-platform": "\"Windows\"",
|
|
|
+ "sec-fetch-dest": "empty",
|
|
|
+ "sec-fetch-mode": "cors",
|
|
|
+ "sec-fetch-site": "same-origin",
|
|
|
+ "x-csrf-token": getCookie('ct0'),
|
|
|
+ "x-twitter-active-user": "yes",
|
|
|
+ "x-twitter-auth-type": "OAuth2Session",
|
|
|
+ "x-twitter-client-language": "en"
|
|
|
+ },
|
|
|
+ }).then(function (response) {
|
|
|
+ chrome.runtime.sendMessage({ actionType: "DO_TASK", do_type: 'api', tweet_Id, task_type: 'createTweet', task_data: '', task_done: true })
|
|
|
+ }).catch(function (err) {
|
|
|
+ chrome.runtime.sendMessage({ actionType: "DO_TASK", do_type: 'api', tweet_Id, task_type: 'createTweet', task_data: '', task_done: false })
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
export const TwitterApiUserByScreenName = (params) => {
|
|
|
let { screen_name } = params;
|
|
|
axios.get(`https://twitter.com/i/api/graphql/mCbpQvZAw6zu_4PvuAUVVQ/UserByScreenName?variables=%7B%22screen_name%22%3A%22${screen_name}%22%2C%22withSafetyModeUserFields%22%3Atrue%2C%22withSuperFollowsUserFields%22%3Atrue%7D`, {
|
|
@@ -2004,7 +2104,7 @@ const hiddenMaskWeb3Tab = (count) => {
|
|
|
* 跳转到个人主页 检查是否需要选中 Group tab
|
|
|
*/
|
|
|
const checkNeedSelectGroupTab = () => {
|
|
|
- if (window.location.pathname != '/home') {
|
|
|
+ if (window.location.pathname != '/home' && !document.hidden) {
|
|
|
setTimeout(() => {
|
|
|
getChromeStorage('groupTabData', (res) => {
|
|
|
console.log('groupTabData', res);
|
|
@@ -2107,10 +2207,12 @@ const addPageScrollEvent = () => {
|
|
|
contentHeight: contentDom.offsetHeight
|
|
|
}
|
|
|
|
|
|
- chrome.runtime.sendMessage({
|
|
|
- actionType: "CONTENT_GROUP_LIST_SCROLL",
|
|
|
- data: data
|
|
|
- }, () => { });
|
|
|
+ messageCenter.send('de-tab-group-content', 'CONTENT_GROUP_LIST_SCROLL', data)
|
|
|
+
|
|
|
+ // chrome.runtime.sendMessage({
|
|
|
+ // actionType: "CONTENT_GROUP_LIST_SCROLL",
|
|
|
+ // data: data
|
|
|
+ // }, () => { });
|
|
|
};
|
|
|
|
|
|
const removeTweetTabEvent = (params) => {
|
|
@@ -2191,10 +2293,11 @@ const setGroupTabSelfStyle = (params = {}) => {
|
|
|
* 切换到 Group tab时 刷新列表
|
|
|
*/
|
|
|
export const refreshTabGroup = () => {
|
|
|
- chrome.runtime.sendMessage({
|
|
|
- actionType: "CONTENT_REFRESH_TAB_GROUP_LIST",
|
|
|
- data: {}
|
|
|
- }, () => { });
|
|
|
+ messageCenter.send('de-tab-group-content', 'CONTENT_REFRESH_TAB_GROUP_LIST', {})
|
|
|
+ // chrome.runtime.sendMessage({
|
|
|
+ // actionType: "CONTENT_REFRESH_TAB_GROUP_LIST",
|
|
|
+ // data: {}
|
|
|
+ // }, () => { });
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -2271,7 +2374,7 @@ const addTabGroupContent = (cb) => {
|
|
|
}
|
|
|
let iframe = document.createElement('iframe');
|
|
|
iframe.id = 'de-tab-group-content';
|
|
|
- iframe.src = chrome.runtime.getURL('/iframe/tab-group.html') + `?params=${JSON.stringify(params)}`;
|
|
|
+ iframe.src = `${iframeHost}/tab-group` + `?params=${JSON.stringify(params)}`;
|
|
|
iframe.style.cssText = `border: medium none; height: 500px;display: none`
|
|
|
|
|
|
let iframeContent = getGroupTabContentNode();
|
|
@@ -2372,12 +2475,19 @@ export const pageJumpHandler = (params) => {
|
|
|
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: {
|
|
|
+ messageCenter.send({
|
|
|
+ actionType: "CONTENT_SEND_GROUP_NAV_TOP",
|
|
|
+ data: {
|
|
|
top,
|
|
|
scrollTop: params.scrollTop
|
|
|
}
|
|
|
- }, () => { })
|
|
|
+ })
|
|
|
+ // chrome.runtime.sendMessage({
|
|
|
+ // actionType: "CONTENT_SEND_GROUP_NAV_TOP", data: {
|
|
|
+ // top,
|
|
|
+ // scrollTop: params.scrollTop
|
|
|
+ // }
|
|
|
+ // }, () => { })
|
|
|
}
|
|
|
|
|
|
|
|
@@ -2432,13 +2542,19 @@ const getSysTheme = () => {
|
|
|
const sysThemeChange = () => {
|
|
|
setTimeout(() => {
|
|
|
let bgColor = document.querySelector('body').style.backgroundColor;
|
|
|
-
|
|
|
- chrome.runtime.sendMessage({
|
|
|
- actionType: "CONTENT_SYS_THEME_CHANGE", data: {
|
|
|
+ messageCenter.send({
|
|
|
+ actionType: "CONTENT_SYS_THEME_CHANGE",
|
|
|
+ data: {
|
|
|
theme: systemInfo.theme,
|
|
|
twitterTheme: bgColor == 'rgb(0, 0, 0)' ? 'dark' : 'light'
|
|
|
}
|
|
|
- }, () => { })
|
|
|
+ })
|
|
|
+ // chrome.runtime.sendMessage({
|
|
|
+ // actionType: "CONTENT_SYS_THEME_CHANGE", data: {
|
|
|
+ // theme: systemInfo.theme,
|
|
|
+ // twitterTheme: bgColor == 'rgb(0, 0, 0)' ? 'dark' : 'light'
|
|
|
+ // }
|
|
|
+ // }, () => { })
|
|
|
}, 800)
|
|
|
}
|
|
|
|