|
@@ -1,5 +1,5 @@
|
|
|
import { getChromeStorage, setChromeStorage, chromeExtensionUrl } from '@/uilts/chromeExtension.js'
|
|
|
-import { throttle, getQueryString, getCookie, nextTick, getQueryStringByUrl, getStorage, setStorage, getInnerIframeURL } from '@/uilts/help'
|
|
|
+import { throttle, getQueryString, getCookie, nextTick, getQueryStringByUrl, getStorage, setStorage, getInnerIframeURL, isMobileTwitter } from '@/uilts/help'
|
|
|
import { discordAuthRedirectUri, iframeHost } from '@/http/configAPI'
|
|
|
import { reportSrcPublishEvent } from '@/http/publishApi'
|
|
|
|
|
@@ -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';
|
|
@@ -64,7 +64,7 @@ function getDiscordAuthCode() {
|
|
|
* @param port
|
|
|
*/
|
|
|
function renderDom() {
|
|
|
- if (window.location.href.indexOf('https://twitter.com') > -1) {
|
|
|
+ if (window.location.href.indexOf('https://twitter.com') > -1 || window.location.href.indexOf('https://mobile.twitter.com') > -1 ) {
|
|
|
_createBtnDom();
|
|
|
onWindowResize();
|
|
|
checkHasDeBtn();
|
|
@@ -679,11 +679,22 @@ function createTweetToolbarToolBox() {
|
|
|
function addSliderNavDeBtn() {
|
|
|
try {
|
|
|
let isSmall = false;
|
|
|
+ let isFloating = false;
|
|
|
+ let floatingTweetBtn;
|
|
|
let tweetBtn = document.querySelector('a[data-testid="SideNav_NewTweet_Button"]');
|
|
|
- if (tweetBtn && tweetBtn.querySelector('svg')) {
|
|
|
- isSmall = true;
|
|
|
+ if (tweetBtn) {
|
|
|
+ if (tweetBtn.querySelector('svg')) {
|
|
|
+ isSmall = true;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 手机打开twitter 发推按钮
|
|
|
+ floatingTweetBtn = document.querySelector('div[data-testid="FloatingActionButtonBase"]');
|
|
|
+ if (floatingTweetBtn) {
|
|
|
+ isFloating = true;
|
|
|
+ }
|
|
|
}
|
|
|
- if (!isSmall) {
|
|
|
+
|
|
|
+ if (!isSmall && !isFloating) {
|
|
|
let bigDom = document.querySelector('a[href="/compose/tweet"]').parentNode.parentNode;
|
|
|
let deBtn = document.getElementById('de-btn');
|
|
|
if (bigDom && !deBtn) {
|
|
@@ -695,15 +706,19 @@ function addSliderNavDeBtn() {
|
|
|
});
|
|
|
}
|
|
|
} else {
|
|
|
- let smallDom = document.querySelector('a[href="/compose/tweet"]').parentNode.parentNode;
|
|
|
let deBtn3 = document.getElementById('de-btn3');
|
|
|
- if (smallDom && !deBtn3) {
|
|
|
- dom && dom.deBtn3 && smallDom.appendChild(dom.deBtn3);
|
|
|
- Report.reportLog({
|
|
|
- pageSource: Report.pageSource.mainPage,
|
|
|
- businessType: Report.businessType.buttonView,
|
|
|
- objectType: Report.objectType.buttonMain
|
|
|
- });
|
|
|
+ if (isFloating && !deBtn3) {
|
|
|
+ floatingTweetBtn.appendChild(dom.deBtn3);
|
|
|
+ } else {
|
|
|
+ let smallDom = document.querySelector('a[href="/compose/tweet"]').parentNode.parentNode;
|
|
|
+ if (smallDom && !deBtn3) {
|
|
|
+ dom && dom.deBtn3 && smallDom.appendChild(dom.deBtn3);
|
|
|
+ Report.reportLog({
|
|
|
+ pageSource: Report.pageSource.mainPage,
|
|
|
+ businessType: Report.businessType.buttonView,
|
|
|
+ objectType: Report.objectType.buttonMain
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
} catch (e) {
|
|
@@ -882,10 +897,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
|
|
|
}
|
|
@@ -1079,24 +1094,36 @@ 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)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- messageCenter.send(params.iframeId, 'CONTENT_GET_TWEET_USER_FOLLOW_STATUS_RES', {
|
|
|
- list, tweetId, type, iframeId: params.iframeId, iframeGUId
|
|
|
+ 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({
|
|
|
+ info: {
|
|
|
+ iframeId: params.iframeId,
|
|
|
+ actionType: 'CONTENT_GET_TWEET_USER_FOLLOW_STATUS_RES'
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ 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 }, () => { })
|
|
|
}).catch(err => {
|
|
|
- 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 }, () => { })
|
|
|
+ messageCenter.send({
|
|
|
+ info: {
|
|
|
+ iframeId: params.iframeId,
|
|
|
+ actionType: 'CONTENT_GET_TWEET_USER_FOLLOW_STATUS_RES'
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ 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 }, () => { })
|
|
|
})
|
|
|
}
|
|
|
|
|
@@ -1142,7 +1169,7 @@ export function facebookReplyTweet(params) {
|
|
|
}
|
|
|
|
|
|
export function replyHandle(params) {
|
|
|
- let iframe = window.parent.document.getElementById(params.postId);
|
|
|
+ let iframe = window.parent.document.getElementById(params.iframeId);
|
|
|
let replyBtn = iframe.parentNode.parentNode.querySelector('div[data-testid="reply"]') ||
|
|
|
iframe.parentNode.parentNode.parentNode.querySelector('div[data-testid="reply"]');
|
|
|
if (replyBtn) {
|
|
@@ -1165,8 +1192,8 @@ export function replyHandle(params) {
|
|
|
|
|
|
let eleList = tweetReply.parentNode.parentNode.parentNode.parentNode.parentNode.querySelectorAll('span[data-text="true"]');
|
|
|
reportReplyResult(eleList, params, () => {
|
|
|
- // iframe.contentWindow.postMessage({ actionType: 'CONTENT_RED_PACKET_REPLY_RASK_FINSH', data: {} }, '*');
|
|
|
- chrome.runtime.sendMessage({ actionType: "CONTENT_RED_PACKET_REPLY_RASK_FINSH", data: { postId: params.postId } }, () => { })
|
|
|
+ iframe.contentWindow.postMessage({ actionType: 'CONTENT_RED_PACKET_REPLY_RASK_FINSH', data: { postId: params.postId } }, '*');
|
|
|
+ // chrome.runtime.sendMessage({ actionType: "CONTENT_RED_PACKET_REPLY_RASK_FINSH", data: { postId: params.postId } }, () => { })
|
|
|
});
|
|
|
})
|
|
|
}
|
|
@@ -1174,7 +1201,7 @@ export function replyHandle(params) {
|
|
|
}
|
|
|
|
|
|
export function onTweetReplyClick(params) {
|
|
|
- let iframe = window.parent.document.getElementById(params.postId);
|
|
|
+ let iframe = window.parent.document.getElementById(params.iframeId);
|
|
|
let replyBtn = iframe.parentNode.parentNode.querySelector('div[data-testid="reply"]') ||
|
|
|
iframe.parentNode.parentNode.parentNode.querySelector('div[data-testid="reply"]');
|
|
|
if (replyBtn) {
|
|
@@ -1218,13 +1245,35 @@ function onReplyDialogOpen(params, iframe) {
|
|
|
businessType: Report.businessType.buttonClick,
|
|
|
objectType: Report.objectType.replyClickByTwitterList
|
|
|
});
|
|
|
+ let editDom = dialog.querySelector('div[contenteditable="true"]');
|
|
|
+ let eleList = []
|
|
|
+ if(editDom) {
|
|
|
+ eleList = editDom.querySelectorAll('span[data-text="true"]');
|
|
|
+ } else {
|
|
|
+ // mobile.twitter.com
|
|
|
+ editDom = dialog.querySelector('textarea');
|
|
|
+ if(editDom) {
|
|
|
+ let value = editDom.value;
|
|
|
+ if(value) {
|
|
|
+ let strArr = value.split(' ');
|
|
|
+ if(strArr && strArr.length) {
|
|
|
+ for(let i = 0; i < strArr.length; i++) {
|
|
|
+ eleList.push({
|
|
|
+ innerText: strArr[i]
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- let eleList = dialog.querySelector('div[contenteditable="true"]').querySelectorAll('span[data-text="true"]');
|
|
|
- reportReplyResult(eleList, params, () => {
|
|
|
+ if(eleList.length) {
|
|
|
+ reportReplyResult(eleList, params, () => {
|
|
|
// 上報完成
|
|
|
- // iframe.contentWindow.postMessage({ actionType: 'CONTENT_RED_PACKET_REPLY_RASK_FINSH', data: {} }, '*');
|
|
|
- chrome.runtime.sendMessage({ actionType: "CONTENT_RED_PACKET_REPLY_RASK_FINSH", data: { postId: params.postId } }, () => { })
|
|
|
- })
|
|
|
+ iframe.contentWindow.postMessage({ actionType: 'CONTENT_RED_PACKET_REPLY_RASK_FINSH', data: { postId: params.postId } }, '*');
|
|
|
+ // chrome.runtime.sendMessage({ actionType: "CONTENT_RED_PACKET_REPLY_RASK_FINSH", data: { postId: params.postId } }, () => { })
|
|
|
+ })
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
}, 1000);
|
|
@@ -1462,32 +1511,32 @@ 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)
|
|
|
- }
|
|
|
+ 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) {
|
|
@@ -1498,49 +1547,51 @@ 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;
|
|
|
+ }
|
|
|
+ let url = isMobileTwitter() ? 'https://mobile.twitter.com/i/api/1.1/friendships/update.json' : "https://twitter.com/i/api/1.1/friendships/update.json";
|
|
|
+ return fetch(url, {
|
|
|
+ "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) => {
|
|
|
- fetch("https://twitter.com/i/api/1.1/friendships/create.json", {
|
|
|
+ let url = isMobileTwitter() ? "https://mobile.twitter.com/i/api/1.1/friendships/create.json" : "https://twitter.com/i/api/1.1/friendships/create.json"
|
|
|
+ fetch(url, {
|
|
|
"headers": {
|
|
|
"authorization": "Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA",
|
|
|
"content-type": "application/x-www-form-urlencoded",
|
|
@@ -1562,7 +1613,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(() => {
|
|
@@ -1573,7 +1624,8 @@ const TwitterFollowAPI = (item, tweet_Id) => {
|
|
|
|
|
|
|
|
|
const TwitterRetweetAPI = (tweet_Id) => {
|
|
|
- fetch("https://twitter.com/i/api/graphql/ojPdsZsimiJrUGLR1sjUtA/CreateRetweet", {
|
|
|
+ let url = isMobileTwitter() ? "https://mobile.twitter.com/i/api/graphql/ojPdsZsimiJrUGLR1sjUtA/CreateRetweet" : "https://twitter.com/i/api/graphql/ojPdsZsimiJrUGLR1sjUtA/CreateRetweet"
|
|
|
+ fetch(url, {
|
|
|
"headers": {
|
|
|
"accept": "*/*",
|
|
|
"accept-language": "zh,en;q=0.9,zh-CN;q=0.8",
|
|
@@ -1605,7 +1657,8 @@ const TwitterRetweetAPI = (tweet_Id) => {
|
|
|
}
|
|
|
|
|
|
const TwitterLikeAPI = (tweet_Id) => {
|
|
|
- fetch("https://twitter.com/i/api/graphql/lI07N6Otwv1PhnEgXILM7A/FavoriteTweet", {
|
|
|
+ let url = isMobileTwitter() ? "https://mobile.twitter.com/i/api/graphql/lI07N6Otwv1PhnEgXILM7A/FavoriteTweet" : "https://twitter.com/i/api/graphql/lI07N6Otwv1PhnEgXILM7A/FavoriteTweet"
|
|
|
+ fetch(url, {
|
|
|
"headers": {
|
|
|
"accept": "*/*",
|
|
|
"accept-language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",
|
|
@@ -1637,7 +1690,7 @@ const TwitterLikeAPI = (tweet_Id) => {
|
|
|
}
|
|
|
|
|
|
const TwitterApiCreateTweet = ({ text, tweet_Id, iframeId,
|
|
|
- iframeGUId, iframeMsg }) => {
|
|
|
+ iframeGUId, iframeMsg }) => {
|
|
|
let data = {
|
|
|
queryId: "hC1nuE-2d1NX5LYBuuAvtQ",
|
|
|
features: {
|
|
@@ -1647,7 +1700,9 @@ const TwitterApiCreateTweet = ({ text, tweet_Id, iframeId,
|
|
|
"vibe_api_enabled": true,
|
|
|
"responsive_web_edit_tweet_api_enabled": false,
|
|
|
"standardized_nudges_misinfo": true,
|
|
|
- "responsive_web_enhance_cards_enabled": false
|
|
|
+ "responsive_web_enhance_cards_enabled": false,
|
|
|
+ "tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled": false,
|
|
|
+ "responsive_web_text_conversations_enabled": false
|
|
|
},
|
|
|
variables: {
|
|
|
"tweet_text": text,
|
|
@@ -1664,7 +1719,8 @@ const TwitterApiCreateTweet = ({ text, tweet_Id, iframeId,
|
|
|
"dark_request": false
|
|
|
}
|
|
|
};
|
|
|
- axios.post(`https://twitter.com/i/api/graphql/hC1nuE-2d1NX5LYBuuAvtQ/CreateTweet`,
|
|
|
+ let url = isMobileTwitter() ? "https://mobile.twitter.com/i/api/graphql/K9It0MijE2UOlX-8wLyPYA/CreateTweet" : "https://twitter.com/i/api/graphql/hC1nuE-2d1NX5LYBuuAvtQ/CreateTweet"
|
|
|
+ axios.post(url,
|
|
|
data, {
|
|
|
headers: {
|
|
|
"accept": "*/*",
|
|
@@ -1683,31 +1739,43 @@ 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 })
|
|
|
- }
|
|
|
+ console.log(response)
|
|
|
+ let data = response.data;
|
|
|
+ if (iframeMsg) {
|
|
|
+ messageCenter.send({
|
|
|
+ info: {
|
|
|
+ iframeId,
|
|
|
+ actionType: 'CONTENT_CREATE_TWEET_FINISH'
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ 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 })
|
|
|
- }
|
|
|
+ console.log('err --1', err)
|
|
|
+ if (iframeMsg) {
|
|
|
+ messageCenter.send({
|
|
|
+ info: {
|
|
|
+ iframeId,
|
|
|
+ actionType: 'CONTENT_CREATE_TWEET_FINISH'
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ 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 })
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
|
|
|
const TwitterApiUserByScreenNameReq = (params) => {
|
|
|
let { screen_name } = params || {};
|
|
|
- return 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`, {
|
|
|
+ let url = isMobileTwitter() ? `https://mobile.twitter.com/i/api/graphql/gr8Lk09afdgWo7NvzP89iQ/UserByScreenName?variables=%7B%22screen_name%22%3A%22${screen_name}%22%2C%22withSafetyModeUserFields%22%3Atrue%2C%22withSuperFollowsUserFields%22%3Atrue%7D` : `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`
|
|
|
+ return axios.get(url, {
|
|
|
headers: {
|
|
|
"accept": "*/*",
|
|
|
"accept-language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",
|
|
@@ -1732,22 +1800,35 @@ export const TwitterApiUserByScreenName = (params, cb) => {
|
|
|
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 }, () => { })
|
|
|
- }
|
|
|
+ if (iframeMsg) {
|
|
|
+ messageCenter.send({
|
|
|
+ info: {
|
|
|
+ iframeId,
|
|
|
+ actionType: 'CONTENT_API_GET_TWEET_USER_INFO_END'
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ 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 }, () => { })
|
|
|
- }
|
|
|
+ if (iframeMsg) {
|
|
|
+ messageCenter.send({
|
|
|
+ info: {
|
|
|
+ iframeId,
|
|
|
+ actionType: 'CONTENT_API_GET_TWEET_USER_INFO_END'
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ iframeGUId, response: {}, objectType
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ chrome.runtime.sendMessage({ actionType: "CONTENT_API_GET_TWEET_USER_INFO_RES", data: {}, tweetId, objectType, iframeId }, () => { })
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -2403,7 +2484,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",
|
|
@@ -2489,7 +2575,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: {}
|
|
@@ -2570,7 +2660,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();
|
|
@@ -2672,7 +2762,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
|
|
@@ -2718,7 +2810,13 @@ export const setGroupInfo = (params = {}) => {
|
|
|
|
|
|
export const getExtensionStorgeDataForIframe = (data) => {
|
|
|
getChromeStorage(data.key).then((res) => {
|
|
|
- messageCenter.send(data.iframeID, `IFRAME_GET_EXTENSION_STORGE_DATA-${data.messageID}`, res)
|
|
|
+ messageCenter.send({
|
|
|
+ info: {
|
|
|
+ iframeId: data.iframeId,
|
|
|
+ actionType: `IFRAME_GET_EXTENSION_STORGE_DATA-${data.messageId}`
|
|
|
+ },
|
|
|
+ data: res
|
|
|
+ })
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -2745,7 +2843,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'
|
|
@@ -2785,11 +2885,17 @@ export const showPublishDialog = () => {
|
|
|
|
|
|
// 获取推文发送回去
|
|
|
export const sendContentByTwitterID = (params) => {
|
|
|
- let {tweet_Id, iframeGUId} = JSON.parse(params.data);
|
|
|
+ let { tweet_Id, iframeGUId } = JSON.parse(params.data);
|
|
|
// 获取内容
|
|
|
let txt = parseCard.getContentByTwitterId(tweet_Id);
|
|
|
- messageCenter.send(params.iframeId, 'CONTENT_GET_TWEET_TXT', {
|
|
|
- iframeGUId, tweet_Id, txt
|
|
|
+ messageCenter.send({
|
|
|
+ info: {
|
|
|
+ iframeId: params.iframeId,
|
|
|
+ actionType: 'CONTENT_GET_TWEET_TXT'
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ tweet_Id, txt, iframeGUId
|
|
|
+ }
|
|
|
})
|
|
|
// 发送
|
|
|
// chrome.runtime.sendMessage({
|