|
@@ -1,5 +1,5 @@
|
|
import { getChromeStorage, setChromeStorage, chromeExtensionUrl } from '@/uilts/chromeExtension.js'
|
|
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 { discordAuthRedirectUri, iframeHost } from '@/http/configAPI'
|
|
import { reportSrcPublishEvent } from '@/http/publishApi'
|
|
import { reportSrcPublishEvent } from '@/http/publishApi'
|
|
|
|
|
|
@@ -680,11 +680,22 @@ function createTweetToolbarToolBox() {
|
|
function addSliderNavDeBtn() {
|
|
function addSliderNavDeBtn() {
|
|
try {
|
|
try {
|
|
let isSmall = false;
|
|
let isSmall = false;
|
|
|
|
+ let isFloating = false;
|
|
|
|
+ let floatingTweetBtn;
|
|
let tweetBtn = document.querySelector('a[data-testid="SideNav_NewTweet_Button"]');
|
|
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 bigDom = document.querySelector('a[href="/compose/tweet"]').parentNode.parentNode;
|
|
let deBtn = document.getElementById('de-btn');
|
|
let deBtn = document.getElementById('de-btn');
|
|
if (bigDom && !deBtn) {
|
|
if (bigDom && !deBtn) {
|
|
@@ -696,15 +707,19 @@ function addSliderNavDeBtn() {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- let smallDom = document.querySelector('a[href="/compose/tweet"]').parentNode.parentNode;
|
|
|
|
let deBtn3 = document.getElementById('de-btn3');
|
|
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) {
|
|
} catch (e) {
|
|
@@ -1072,7 +1087,7 @@ export function init() {
|
|
}
|
|
}
|
|
|
|
|
|
export const getTweetUserFollowStatus = (params) => {
|
|
export const getTweetUserFollowStatus = (params) => {
|
|
- let { tweetId, userList } = params.data;
|
|
|
|
|
|
+ let { tweetId, userList, iframeGUId, type } = JSON.parse(params.data);
|
|
let promiseList = [];
|
|
let promiseList = [];
|
|
for (let i = 0; i < userList.length; i++) {
|
|
for (let i = 0; i < userList.length; i++) {
|
|
promiseList[i] = TwitterApiUserByScreenNameReq({ screen_name: userList[i]['name'] });
|
|
promiseList[i] = TwitterApiUserByScreenNameReq({ screen_name: userList[i]['name'] });
|
|
@@ -1089,10 +1104,28 @@ export const getTweetUserFollowStatus = (params) => {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ 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 }, () => { })
|
|
|
|
|
|
+ // chrome.runtime.sendMessage({ actionType: 'CONTENT_GET_TWEET_USER_FOLLOW_STATUS_RES', data: list, tweetId, type: params.type, iframeId: params.iframeId }, () => { })
|
|
}).catch(err => {
|
|
}).catch(err => {
|
|
- 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 }, () => { })
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1141,8 +1174,8 @@ export function facebookReplyTweet({ info, data }) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-export function replyHandle({ info, data}) {
|
|
|
|
- let iframe = window.parent.document.getElementById(data.postId);
|
|
|
|
|
|
+export function replyHandle(params) {
|
|
|
|
+ let iframe = window.parent.document.getElementById(params.iframeId);
|
|
let replyBtn = iframe.parentNode.parentNode.querySelector('div[data-testid="reply"]') ||
|
|
let replyBtn = iframe.parentNode.parentNode.querySelector('div[data-testid="reply"]') ||
|
|
iframe.parentNode.parentNode.parentNode.querySelector('div[data-testid="reply"]');
|
|
iframe.parentNode.parentNode.parentNode.querySelector('div[data-testid="reply"]');
|
|
if (replyBtn) {
|
|
if (replyBtn) {
|
|
@@ -1164,16 +1197,9 @@ export function replyHandle({ info, data}) {
|
|
});
|
|
});
|
|
|
|
|
|
let eleList = tweetReply.parentNode.parentNode.parentNode.parentNode.parentNode.querySelectorAll('span[data-text="true"]');
|
|
let eleList = tweetReply.parentNode.parentNode.parentNode.parentNode.parentNode.querySelectorAll('span[data-text="true"]');
|
|
- reportReplyResult(eleList, data, () => {
|
|
|
|
- contentMessageCenter.send({
|
|
|
|
- info: {
|
|
|
|
- actionType: 'CONTENT_RED_PACKET_REPLY_RASK_FINSH',
|
|
|
|
- iframeId: info.iframeId
|
|
|
|
- },
|
|
|
|
- data: { postId: data.postId }
|
|
|
|
- })
|
|
|
|
- // iframe.contentWindow.postMessage({ actionType: 'CONTENT_RED_PACKET_REPLY_RASK_FINSH', data: {} }, '*');
|
|
|
|
- // chrome.runtime.sendMessage({ actionType: "CONTENT_RED_PACKET_REPLY_RASK_FINSH", data: { postId: data.postId } }, () => { })
|
|
|
|
|
|
+ reportReplyResult(eleList, params, () => {
|
|
|
|
+ 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 } }, () => { })
|
|
});
|
|
});
|
|
})
|
|
})
|
|
}
|
|
}
|
|
@@ -1181,7 +1207,7 @@ export function replyHandle({ info, data}) {
|
|
}
|
|
}
|
|
|
|
|
|
export function onTweetReplyClick(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"]') ||
|
|
let replyBtn = iframe.parentNode.parentNode.querySelector('div[data-testid="reply"]') ||
|
|
iframe.parentNode.parentNode.parentNode.querySelector('div[data-testid="reply"]');
|
|
iframe.parentNode.parentNode.parentNode.querySelector('div[data-testid="reply"]');
|
|
if (replyBtn) {
|
|
if (replyBtn) {
|
|
@@ -1229,8 +1255,8 @@ function onReplyDialogOpen(params, iframe) {
|
|
let eleList = dialog.querySelector('div[contenteditable="true"]').querySelectorAll('span[data-text="true"]');
|
|
let eleList = dialog.querySelector('div[contenteditable="true"]').querySelectorAll('span[data-text="true"]');
|
|
reportReplyResult(eleList, params, () => {
|
|
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 } }, () => { })
|
|
})
|
|
})
|
|
});
|
|
});
|
|
}
|
|
}
|
|
@@ -1473,6 +1499,35 @@ export function doTaskTwitterAPI({ info, data }) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+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) {
|
|
export function showJoinDialog(data) {
|
|
let iframe = document.querySelector('#nftProjectId')
|
|
let iframe = document.querySelector('#nftProjectId')
|
|
iframe.style.display = 'block'
|
|
iframe.style.display = 'block'
|
|
@@ -1500,7 +1555,8 @@ const TwitterFriendshipsUpdate = (params) => {
|
|
if (!id) {
|
|
if (!id) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- return fetch("https://twitter.com/i/api/1.1/friendships/update.json", {
|
|
|
|
|
|
+ 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": {
|
|
"headers": {
|
|
"authorization": "Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA",
|
|
"authorization": "Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA",
|
|
"content-type": "application/x-www-form-urlencoded",
|
|
"content-type": "application/x-www-form-urlencoded",
|
|
@@ -1522,9 +1578,9 @@ const TwitterFriendshipsUpdate = (params) => {
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
-const TwitterFollowAPI = (item, tweet_Id, info) => {
|
|
|
|
- console.log('TwitterFollowAPI', item, tweet_Id, info)
|
|
|
|
- fetch("https://twitter.com/i/api/1.1/friendships/create.json", {
|
|
|
|
|
|
+const TwitterFollowAPI = (item, tweet_Id) => {
|
|
|
|
+ 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": {
|
|
"headers": {
|
|
"authorization": "Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA",
|
|
"authorization": "Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA",
|
|
"content-type": "application/x-www-form-urlencoded",
|
|
"content-type": "application/x-www-form-urlencoded",
|
|
@@ -1567,8 +1623,9 @@ const TwitterFollowAPI = (item, tweet_Id, info) => {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-const TwitterRetweetAPI = (tweet_Id, info) => {
|
|
|
|
- fetch("https://twitter.com/i/api/graphql/ojPdsZsimiJrUGLR1sjUtA/CreateRetweet", {
|
|
|
|
|
|
+const TwitterRetweetAPI = (tweet_Id) => {
|
|
|
|
+ let url = isMobileTwitter() ? "https://mobile.twitter.com/i/api/graphql/ojPdsZsimiJrUGLR1sjUtA/CreateRetweet" : "https://twitter.com/i/api/graphql/ojPdsZsimiJrUGLR1sjUtA/CreateRetweet"
|
|
|
|
+ fetch(url, {
|
|
"headers": {
|
|
"headers": {
|
|
"accept": "*/*",
|
|
"accept": "*/*",
|
|
"accept-language": "zh,en;q=0.9,zh-CN;q=0.8",
|
|
"accept-language": "zh,en;q=0.9,zh-CN;q=0.8",
|
|
@@ -1611,8 +1668,9 @@ const TwitterRetweetAPI = (tweet_Id, info) => {
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
-const TwitterLikeAPI = (tweet_Id, info) => {
|
|
|
|
- fetch("https://twitter.com/i/api/graphql/lI07N6Otwv1PhnEgXILM7A/FavoriteTweet", {
|
|
|
|
|
|
+const TwitterLikeAPI = (tweet_Id) => {
|
|
|
|
+ let url = isMobileTwitter() ? "https://mobile.twitter.com/i/api/graphql/lI07N6Otwv1PhnEgXILM7A/FavoriteTweet" : "https://twitter.com/i/api/graphql/lI07N6Otwv1PhnEgXILM7A/FavoriteTweet"
|
|
|
|
+ fetch(url, {
|
|
"headers": {
|
|
"headers": {
|
|
"accept": "*/*",
|
|
"accept": "*/*",
|
|
"accept-language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",
|
|
"accept-language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",
|
|
@@ -1655,7 +1713,8 @@ const TwitterLikeAPI = (tweet_Id, info) => {
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
-const TwitterApiCreateTweet = ({ text, tweet_Id, iframeId }) => {
|
|
|
|
|
|
+const TwitterApiCreateTweet = ({ text, tweet_Id, iframeId,
|
|
|
|
+ iframeGUId, iframeMsg }) => {
|
|
let data = {
|
|
let data = {
|
|
queryId: "hC1nuE-2d1NX5LYBuuAvtQ",
|
|
queryId: "hC1nuE-2d1NX5LYBuuAvtQ",
|
|
features: {
|
|
features: {
|
|
@@ -1665,7 +1724,9 @@ const TwitterApiCreateTweet = ({ text, tweet_Id, iframeId }) => {
|
|
"vibe_api_enabled": true,
|
|
"vibe_api_enabled": true,
|
|
"responsive_web_edit_tweet_api_enabled": false,
|
|
"responsive_web_edit_tweet_api_enabled": false,
|
|
"standardized_nudges_misinfo": true,
|
|
"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: {
|
|
variables: {
|
|
"tweet_text": text,
|
|
"tweet_text": text,
|
|
@@ -1682,7 +1743,8 @@ const TwitterApiCreateTweet = ({ text, tweet_Id, iframeId }) => {
|
|
"dark_request": false
|
|
"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, {
|
|
data, {
|
|
headers: {
|
|
headers: {
|
|
"accept": "*/*",
|
|
"accept": "*/*",
|
|
@@ -1701,15 +1763,43 @@ const TwitterApiCreateTweet = ({ text, tweet_Id, iframeId }) => {
|
|
"x-twitter-client-language": "en"
|
|
"x-twitter-client-language": "en"
|
|
},
|
|
},
|
|
}).then(function (response) {
|
|
}).then(function (response) {
|
|
- 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) {
|
|
}).catch(function (err) {
|
|
- 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) => {
|
|
const TwitterApiUserByScreenNameReq = (params) => {
|
|
let { screen_name } = 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: {
|
|
headers: {
|
|
"accept": "*/*",
|
|
"accept": "*/*",
|
|
"accept-language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",
|
|
"accept-language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",
|
|
@@ -1730,33 +1820,39 @@ const TwitterApiUserByScreenNameReq = (params) => {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-export const TwitterApiUserByScreenName = ({info, data}) => {
|
|
|
|
- let { screen_name, tweetId = '', objectType = '', iframeId = '' } = params;
|
|
|
|
|
|
+export const TwitterApiUserByScreenName = (params, cb) => {
|
|
|
|
+ let { screen_name, tweetId = '', objectType = '', iframeId = '', iframeMsg = false, iframeGUId } = params;
|
|
|
|
|
|
TwitterApiUserByScreenNameReq({ screen_name }).then(function (response) {
|
|
TwitterApiUserByScreenNameReq({ screen_name }).then(function (response) {
|
|
- contentMessageCenter.send({
|
|
|
|
- info,
|
|
|
|
- data: {
|
|
|
|
- data: response.data.data || {},
|
|
|
|
- tweetId,
|
|
|
|
- objectType,
|
|
|
|
- iframeId
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- // treasure 使用 runtime
|
|
|
|
- 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) {
|
|
}).catch(function (err) {
|
|
- contentMessageCenter.send({
|
|
|
|
- info,
|
|
|
|
- data: {
|
|
|
|
- data: {},
|
|
|
|
- tweetId,
|
|
|
|
- objectType,
|
|
|
|
- iframeId
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- // treasure 使用 runtime
|
|
|
|
- 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 }, () => { })
|
|
|
|
+ }
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2815,16 +2911,26 @@ 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({
|
|
|
|
+ info: {
|
|
|
|
+ iframeId: params.iframeId,
|
|
|
|
+ actionType: 'CONTENT_GET_TWEET_TXT'
|
|
|
|
+ },
|
|
|
|
+ data: {
|
|
|
|
+ tweet_Id, txt, iframeGUId
|
|
|
|
+ }
|
|
})
|
|
})
|
|
|
|
+ // 发送
|
|
|
|
+ // chrome.runtime.sendMessage({
|
|
|
|
+ // actionType: "CONTENT_GET_TWEET_TXT", data: {
|
|
|
|
+ // tweet_Id,
|
|
|
|
+ // txt
|
|
|
|
+ // }
|
|
|
|
+ // })
|
|
}
|
|
}
|
|
|
|
|
|
export const sendLoginSuccessToAllIframe = () => {
|
|
export const sendLoginSuccessToAllIframe = () => {
|