|
@@ -10,7 +10,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';
|
|
|
+import messageCenter from '@/uilts/messageCenter/content';
|
|
|
import { PlayType } from '@/types';
|
|
|
import { reSetBindPostContent } from '@/http/help.js';
|
|
|
import { setDeviceInfo } from '@/logic/content/help/twitter';
|
|
@@ -882,10 +882,10 @@ function setIframeCard(type = 'twitter') {
|
|
|
index = Number(i) + 1
|
|
|
if (arr[i] == 'invite' && arr.length >= index) {
|
|
|
item.invite_code = arr[index];
|
|
|
- if(arr.length > index + 1) {
|
|
|
- item.invite_channel = arr[index+1];
|
|
|
+ if (arr.length > index + 1) {
|
|
|
+ item.invite_channel = arr[index + 1];
|
|
|
} else {
|
|
|
- item.invite_channel = '';
|
|
|
+ item.invite_channel = '';
|
|
|
}
|
|
|
break
|
|
|
}
|
|
@@ -1070,7 +1070,7 @@ export function init() {
|
|
|
}
|
|
|
|
|
|
export const getTweetUserFollowStatus = (params) => {
|
|
|
- let { tweetId, userList } = params.data;
|
|
|
+ let { tweetId, userList, iframeGUId, type } = JSON.parse(params.data);
|
|
|
let promiseList = [];
|
|
|
for (let i = 0; i < userList.length; i++) {
|
|
|
promiseList[i] = TwitterApiUserByScreenNameReq({ screen_name: userList[i]['name'] });
|
|
@@ -1079,18 +1079,24 @@ export const getTweetUserFollowStatus = (params) => {
|
|
|
Promise.allSettled(promiseList).then((res) => {
|
|
|
let list = [];
|
|
|
if (res && res.length) {
|
|
|
- let resList = res.filter(item => item.status == 'fulfilled');
|
|
|
- for (let i = 0; i < resList.length; i++) {
|
|
|
- let item = resList[i];
|
|
|
- if (item && item.value && item.value.data && item.value.data.data) {
|
|
|
- list.push(item.value.data.data)
|
|
|
- }
|
|
|
- }
|
|
|
+ let resList = res.filter(item => item.status == 'fulfilled');
|
|
|
+ for (let i = 0; i < resList.length; i++) {
|
|
|
+ let item = resList[i];
|
|
|
+ if (item && item.value && item.value.data && item.value.data.data) {
|
|
|
+ list.push(item.value.data.data)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+ messageCenter.send(params.iframeId, 'CONTENT_GET_TWEET_USER_FOLLOW_STATUS_RES', {
|
|
|
+ list, tweetId, type, iframeId: params.iframeId, iframeGUId
|
|
|
+ })
|
|
|
|
|
|
- chrome.runtime.sendMessage({ actionType: 'CONTENT_GET_TWEET_USER_FOLLOW_STATUS_RES', data: list, tweetId, type: params.type, iframeId: params.iframeId }, () => { })
|
|
|
+ // chrome.runtime.sendMessage({ actionType: 'CONTENT_GET_TWEET_USER_FOLLOW_STATUS_RES', data: list, tweetId, type: params.type, iframeId: params.iframeId }, () => { })
|
|
|
}).catch(err => {
|
|
|
- chrome.runtime.sendMessage({ actionType: 'CONTENT_GET_TWEET_USER_FOLLOW_STATUS_RES', data: [], tweetId, type: params.type, iframeId: params.iframeId }, () => { })
|
|
|
+ messageCenter.send(params.iframeId, 'CONTENT_GET_TWEET_USER_FOLLOW_STATUS_RES', {
|
|
|
+ list: [], tweetId, type, iframeId: params.iframeId, iframeGUId
|
|
|
+ })
|
|
|
+ // chrome.runtime.sendMessage({ actionType: 'CONTENT_GET_TWEET_USER_FOLLOW_STATUS_RES', data: [], tweetId, type: params.type, iframeId: params.iframeId }, () => { })
|
|
|
})
|
|
|
}
|
|
|
|
|
@@ -1455,6 +1461,35 @@ export function doTaskTwitterAPI({ task_data, task_type, tasks, iframeId }) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+export function doTaskIframeTwitterAPI(params) {
|
|
|
+ let {tweet_Id, tweet_text, task_type, tasks, iframeGUId} = JSON.parse(params.data);
|
|
|
+ if(task_type == 'tasks') {
|
|
|
+ tasks.forEach((item) => {
|
|
|
+ switch (String(item.type)) {
|
|
|
+ // 关注指定用户
|
|
|
+ case '1':
|
|
|
+ item.relatedUsers.forEach((item) => {
|
|
|
+ if (item.name && item.twitterUserId) {
|
|
|
+ TwitterFollowAPI(item, tweet_Id);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ break
|
|
|
+ // 点赞
|
|
|
+ case '2':
|
|
|
+ TwitterLikeAPI(tweet_Id)
|
|
|
+ break
|
|
|
+ // 推文发推
|
|
|
+ case '10':
|
|
|
+ // 发推
|
|
|
+ TwitterApiCreateTweet({ text: tweet_text, tweet_Id, iframeId: params.iframeId, iframeGUId, iframeMsg: true })
|
|
|
+ break
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else if(task_type == 'like') {
|
|
|
+ TwitterLikeAPI(tweet_Id)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
export function showJoinDialog(data) {
|
|
|
let iframe = document.querySelector('#nftProjectId')
|
|
|
iframe.style.display = 'block'
|
|
@@ -1463,45 +1498,45 @@ export function showJoinDialog(data) {
|
|
|
}
|
|
|
|
|
|
const TwitterFriendshipsUpdate = (params) => {
|
|
|
- let {id = '', device = true, name} = params || {};
|
|
|
- let data = {
|
|
|
- include_profile_interstitial_type: 1,
|
|
|
- include_blocking: 1,
|
|
|
- include_blocked_by: 1,
|
|
|
- include_followed_by: 1,
|
|
|
- include_want_retweets: 1,
|
|
|
- include_mute_edge: 1,
|
|
|
- include_can_dm: 1,
|
|
|
- include_can_media_tag: 1,
|
|
|
- include_ext_has_nft_avatar: 1,
|
|
|
- skip_status: 1,
|
|
|
- cursor: -1,
|
|
|
- id,
|
|
|
- device
|
|
|
- }
|
|
|
- if(!id) {
|
|
|
- return;
|
|
|
- }
|
|
|
- return fetch("https://twitter.com/i/api/1.1/friendships/update.json", {
|
|
|
- "headers": {
|
|
|
- "authorization": "Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA",
|
|
|
- "content-type": "application/x-www-form-urlencoded",
|
|
|
- "sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"102\", \"Google Chrome\";v=\"102\"",
|
|
|
- "sec-ch-ua-mobile": "?0",
|
|
|
- "sec-ch-ua-platform": "\"macOS\"",
|
|
|
- "x-csrf-token": getCookie('ct0'),
|
|
|
- "x-twitter-active-user": "yes",
|
|
|
- "x-twitter-auth-type": "OAuth2Session",
|
|
|
- "x-twitter-client-language": "en",
|
|
|
- "referer": `https://twitter.com/${name}`
|
|
|
- },
|
|
|
- "referrer": `https://twitter.com/${name}`,
|
|
|
- "referrerPolicy": "strict-origin-when-cross-origin",
|
|
|
- "body": `include_profile_interstitial_type=1&include_blocking=1&include_blocked_by=1&include_followed_by=1&include_want_retweets=1&include_mute_edge=1&include_can_dm=1&include_can_media_tag=1&include_ext_has_nft_avatar=1&skip_status=1&cursor=-1&id=${id}&device=true`,
|
|
|
- "method": "POST",
|
|
|
- "mode": "cors",
|
|
|
- "credentials": "include"
|
|
|
- })
|
|
|
+ let { id = '', device = true, name } = params || {};
|
|
|
+ let data = {
|
|
|
+ include_profile_interstitial_type: 1,
|
|
|
+ include_blocking: 1,
|
|
|
+ include_blocked_by: 1,
|
|
|
+ include_followed_by: 1,
|
|
|
+ include_want_retweets: 1,
|
|
|
+ include_mute_edge: 1,
|
|
|
+ include_can_dm: 1,
|
|
|
+ include_can_media_tag: 1,
|
|
|
+ include_ext_has_nft_avatar: 1,
|
|
|
+ skip_status: 1,
|
|
|
+ cursor: -1,
|
|
|
+ id,
|
|
|
+ device
|
|
|
+ }
|
|
|
+ if (!id) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ return fetch("https://twitter.com/i/api/1.1/friendships/update.json", {
|
|
|
+ "headers": {
|
|
|
+ "authorization": "Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA",
|
|
|
+ "content-type": "application/x-www-form-urlencoded",
|
|
|
+ "sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"102\", \"Google Chrome\";v=\"102\"",
|
|
|
+ "sec-ch-ua-mobile": "?0",
|
|
|
+ "sec-ch-ua-platform": "\"macOS\"",
|
|
|
+ "x-csrf-token": getCookie('ct0'),
|
|
|
+ "x-twitter-active-user": "yes",
|
|
|
+ "x-twitter-auth-type": "OAuth2Session",
|
|
|
+ "x-twitter-client-language": "en",
|
|
|
+ "referer": `https://twitter.com/${name}`
|
|
|
+ },
|
|
|
+ "referrer": `https://twitter.com/${name}`,
|
|
|
+ "referrerPolicy": "strict-origin-when-cross-origin",
|
|
|
+ "body": `include_profile_interstitial_type=1&include_blocking=1&include_blocked_by=1&include_followed_by=1&include_want_retweets=1&include_mute_edge=1&include_can_dm=1&include_can_media_tag=1&include_ext_has_nft_avatar=1&skip_status=1&cursor=-1&id=${id}&device=true`,
|
|
|
+ "method": "POST",
|
|
|
+ "mode": "cors",
|
|
|
+ "credentials": "include"
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
const TwitterFollowAPI = (item, tweet_Id) => {
|
|
@@ -1527,7 +1562,7 @@ const TwitterFollowAPI = (item, tweet_Id) => {
|
|
|
let task_data = {
|
|
|
follow_name: item.name
|
|
|
}
|
|
|
- TwitterFriendshipsUpdate({id: item.twitterUserId, name: item.name})
|
|
|
+ TwitterFriendshipsUpdate({ id: item.twitterUserId, name: item.name })
|
|
|
|
|
|
chrome.runtime.sendMessage({ actionType: "DO_TASK", do_type: 'api', tweet_Id, task_type: 'follow', task_data, task_done: true }, () => { })
|
|
|
}).catch(() => {
|
|
@@ -1601,7 +1636,8 @@ const TwitterLikeAPI = (tweet_Id) => {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-const TwitterApiCreateTweet = ({ text, tweet_Id, iframeId }) => {
|
|
|
+const TwitterApiCreateTweet = ({ text, tweet_Id, iframeId,
|
|
|
+ iframeGUId, iframeMsg }) => {
|
|
|
let data = {
|
|
|
queryId: "hC1nuE-2d1NX5LYBuuAvtQ",
|
|
|
features: {
|
|
@@ -1647,9 +1683,25 @@ const TwitterApiCreateTweet = ({ text, tweet_Id, iframeId }) => {
|
|
|
"x-twitter-client-language": "en"
|
|
|
},
|
|
|
}).then(function (response) {
|
|
|
+ console.log(response)
|
|
|
+ let data = response.data;
|
|
|
+ if(iframeMsg) {
|
|
|
+ messageCenter.send(iframeId, 'CONTENT_CREATE_TWEET_FINISH', {
|
|
|
+ tweet_Id, iframeId, iframeGUId, response: data, done: true
|
|
|
+ })
|
|
|
+ } else {
|
|
|
chrome.runtime.sendMessage({ actionType: "DO_TASK", do_type: 'api', tweet_Id, task_type: 'createTweet1', task_data: '', task_done: '是', response, iframeId })
|
|
|
+ }
|
|
|
}).catch(function (err) {
|
|
|
+ console.log('err --1', err)
|
|
|
+ if(iframeMsg) {
|
|
|
+ messageCenter.send(iframeId, 'CONTENT_CREATE_TWEET_FINISH', {
|
|
|
+ tweet_Id, iframeId, iframeGUId, done: false
|
|
|
+ })
|
|
|
+
|
|
|
+ } else {
|
|
|
chrome.runtime.sendMessage({ actionType: "DO_TASK", do_type: 'api', tweet_Id, task_type: 'createTweet1', task_data: '', task_done: '否', iframeId })
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -1677,12 +1729,25 @@ const TwitterApiUserByScreenNameReq = (params) => {
|
|
|
|
|
|
|
|
|
export const TwitterApiUserByScreenName = (params, cb) => {
|
|
|
- let { screen_name, tweetId = '', objectType = '', iframeId = '' } = params;
|
|
|
+ let { screen_name, tweetId = '', objectType = '', iframeId = '', iframeMsg = false, iframeGUId } = params;
|
|
|
|
|
|
TwitterApiUserByScreenNameReq({ screen_name }).then(function (response) {
|
|
|
+ if(iframeMsg) {
|
|
|
+ messageCenter.send(iframeId, 'CONTENT_API_GET_TWEET_USER_INFO_END', {
|
|
|
+ iframeGUId, response: response.data.data || {}, objectType
|
|
|
+ })
|
|
|
+ } else {
|
|
|
chrome.runtime.sendMessage({ actionType: "CONTENT_API_GET_TWEET_USER_INFO_RES", data: response.data.data || {}, tweetId, objectType, iframeId }, () => { })
|
|
|
+ }
|
|
|
+
|
|
|
}).catch(function (err) {
|
|
|
+ if(iframeMsg) {
|
|
|
+ messageCenter.send(iframeId, 'CONTENT_API_GET_TWEET_USER_INFO_END', {
|
|
|
+ iframeGUId, response: {}, objectType
|
|
|
+ })
|
|
|
+ } else {
|
|
|
chrome.runtime.sendMessage({ actionType: "CONTENT_API_GET_TWEET_USER_INFO_RES", data: {}, tweetId, objectType, iframeId }, () => { })
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -2338,7 +2403,12 @@ const addPageScrollEvent = () => {
|
|
|
contentHeight: contentDom.offsetHeight
|
|
|
}
|
|
|
|
|
|
- messageCenter.send('de-tab-group-content', 'CONTENT_GROUP_LIST_SCROLL', data)
|
|
|
+ messageCenter.send({
|
|
|
+ info: {
|
|
|
+ iframeId: 'de-tab-group-content', actionType: 'CONTENT_GROUP_LIST_SCROLL'
|
|
|
+ },
|
|
|
+ data
|
|
|
+ })
|
|
|
|
|
|
// chrome.runtime.sendMessage({
|
|
|
// actionType: "CONTENT_GROUP_LIST_SCROLL",
|
|
@@ -2424,7 +2494,11 @@ const setGroupTabSelfStyle = (params = {}) => {
|
|
|
* 切换到 Group tab时 刷新列表
|
|
|
*/
|
|
|
export const refreshTabGroup = () => {
|
|
|
- messageCenter.send('de-tab-group-content', 'CONTENT_REFRESH_TAB_GROUP_LIST', {})
|
|
|
+ messageCenter.send({
|
|
|
+ info: {
|
|
|
+ iframeId: 'de-tab-group-content', actionType: 'CONTENT_REFRESH_TAB_GROUP_LIST'
|
|
|
+ }
|
|
|
+ })
|
|
|
// chrome.runtime.sendMessage({
|
|
|
// actionType: "CONTENT_REFRESH_TAB_GROUP_LIST",
|
|
|
// data: {}
|
|
@@ -2505,7 +2579,7 @@ const addTabGroupContent = (cb) => {
|
|
|
}
|
|
|
let iframe = document.createElement('iframe');
|
|
|
iframe.id = 'de-tab-group-content';
|
|
|
- iframe.src = getInnerIframeURL(`${iframeHost}/tab-group` + `?params=${JSON.stringify(params)}&iframeID=${iframe.id}`);
|
|
|
+ iframe.src = getInnerIframeURL(`${iframeHost}/tab-group` + `?params=${JSON.stringify(params)}&iframeId=${iframe.id}`);
|
|
|
iframe.style.cssText = `border: medium none; height: 500px;display: none`
|
|
|
|
|
|
let iframeContent = getGroupTabContentNode();
|
|
@@ -2607,7 +2681,9 @@ export const getTweetProfileNavTop = (params) => {
|
|
|
let top = document.querySelector('div[role="tablist"]').closest('nav').getBoundingClientRect().top;
|
|
|
|
|
|
messageCenter.send({
|
|
|
- actionType: "CONTENT_SEND_GROUP_NAV_TOP",
|
|
|
+ info: {
|
|
|
+ actionType: "CONTENT_SEND_GROUP_NAV_TOP"
|
|
|
+ },
|
|
|
data: {
|
|
|
top,
|
|
|
scrollTop: params.scrollTop
|
|
@@ -2651,9 +2727,13 @@ export const setGroupInfo = (params = {}) => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-export const getExtensionStorgeDataForIframe = (data) => {
|
|
|
+export const getExtensionStorgeDataForIframe = (req) => {
|
|
|
+ const { info, data } = req
|
|
|
getChromeStorage(data.key).then((res) => {
|
|
|
- messageCenter.send(data.iframeID, `IFRAME_GET_EXTENSION_STORGE_DATA-${data.messageID}`, res)
|
|
|
+ messageCenter.send({
|
|
|
+ info,
|
|
|
+ data: res
|
|
|
+ })
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -2680,7 +2760,9 @@ const sysThemeChange = () => {
|
|
|
setTimeout(() => {
|
|
|
let bgColor = document.querySelector('body').style.backgroundColor;
|
|
|
messageCenter.send({
|
|
|
- actionType: "CONTENT_SYS_THEME_CHANGE",
|
|
|
+ info: {
|
|
|
+ actionType: "CONTENT_SYS_THEME_CHANGE"
|
|
|
+ },
|
|
|
data: {
|
|
|
theme: systemInfo.theme,
|
|
|
twitterTheme: bgColor == 'rgb(0, 0, 0)' ? 'dark' : 'light'
|
|
@@ -2719,14 +2801,18 @@ export const showPublishDialog = () => {
|
|
|
}
|
|
|
|
|
|
// 获取推文发送回去
|
|
|
-export const sendContentByTwitterID = (tweet_Id) => {
|
|
|
+export const sendContentByTwitterID = (params) => {
|
|
|
+ let {tweet_Id, iframeGUId} = JSON.parse(params.data);
|
|
|
// 获取内容
|
|
|
- let txt = parseCard.getContentByTwitterId(tweet_Id)
|
|
|
- // 发送
|
|
|
- chrome.runtime.sendMessage({
|
|
|
- actionType: "CONTENT_GET_TWEET_TXT", data: {
|
|
|
- tweet_Id,
|
|
|
- txt
|
|
|
- }
|
|
|
+ let txt = parseCard.getContentByTwitterId(tweet_Id);
|
|
|
+ messageCenter.send(params.iframeId, 'CONTENT_GET_TWEET_TXT', {
|
|
|
+ iframeGUId, tweet_Id, txt
|
|
|
})
|
|
|
+ // 发送
|
|
|
+ // chrome.runtime.sendMessage({
|
|
|
+ // actionType: "CONTENT_GET_TWEET_TXT", data: {
|
|
|
+ // tweet_Id,
|
|
|
+ // txt
|
|
|
+ // }
|
|
|
+ // })
|
|
|
}
|