|
@@ -14,6 +14,7 @@ import messageCenter from '@/uilts/messageCenter/content';
|
|
|
import { PlayType } from '@/types';
|
|
|
import { reSetBindPostContent } from '@/http/help.js';
|
|
|
import { setDeviceInfo } from '@/logic/content/help/twitter';
|
|
|
+import { isMobileTwitter } from '@/uilts/help';
|
|
|
|
|
|
let dom = {};
|
|
|
|
|
@@ -679,11 +680,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 +707,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) {
|
|
@@ -1510,49 +1526,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",
|
|
@@ -1585,7 +1603,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",
|
|
@@ -1617,7 +1636,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",
|
|
@@ -1659,7 +1679,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,
|
|
@@ -1676,7 +1698,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": "*/*",
|
|
@@ -1730,7 +1753,8 @@ const TwitterApiCreateTweet = ({ text, tweet_Id, 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",
|