Skip to content

Commit

Permalink
Merge pull request #641 from whakama/master
Browse files Browse the repository at this point in the history
fix photos/videos tab again + two dm things
  • Loading branch information
dimdenGD authored Dec 16, 2023
2 parents 6b63828 + b57b3be commit 1a286ee
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
4 changes: 3 additions & 1 deletion _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -627,5 +627,7 @@
}
},
"accepted_conversation": { "message": "Accepted conversation" },
"anniversary_tweet": { "message": "Do you remember when you joined Twitter? I do!\n#MyTwitterAnniversary" }
"anniversary_tweet": { "message": "Do you remember when you joined Twitter? I do!\n#MyTwitterAnniversary" },
"you_shared_tweet": { "message": "You shared a tweet" },
"user_shared_tweet": { "message": "$NAME$ shared a tweet", "placeholders": { "name": { "content": "Display Name" } } }
}
18 changes: 12 additions & 6 deletions layouts/header/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -1268,15 +1268,15 @@ let userDataFunction = async user => {

let lastSenderWasUser = lastMessage.message_data && lastMessage.message_data.sender_id === user.id_str

if(lastMessage.reason) {
if (lastMessage.reason) {
messageEntry.preview = LOC.accepted_conversation.message;
} else if(lastEvent.type == 'participants_leave') {
} else if (lastEvent.type == 'participants_leave') {
let leftUser = inbox.users[lastMessage.participants[0].user_id];
messageEntry.preview = LOC.user_left.message
.replace('$NAME$', escapeHTML(leftUser.name))
.replace('$A_START$', '')
.replace('$A_END$', '');
} else if(lastEvent.type == 'participants_join') {
} else if (lastEvent.type == 'participants_join') {
let joinedUser = inbox.users[lastMessage.participants[0].user_id];
let userWhoAdded = inbox.users[lastMessage.sender_id];
messageEntry.preview = LOC.user_added.message
Expand All @@ -1299,18 +1299,24 @@ let userDataFunction = async user => {
.replace('$NAME$', escapeHTML(userWhoUpdated.name))
.replace('$A_START$', '')
.replace('$A_END$', '');
} else if(lastMessage.message_data) {
} else if (lastMessage.message_data) {
let lastMessageUser = lastMessage.message_data ? messageUsers.find(user => user.id_str === lastMessage.message_data.sender_id) : messageUsers[0];
if (lastMessage.message_data.text.startsWith('dmservice_reaction_')) {
messageEntry.preview = lastSenderWasUser ? LOC.you_reacted_message.message : LOC.user_reacted_message.message.replace('$NAME$', escapeHTML(lastMessageUser.name));
} else if(lastMessage.message_data.attachment) {
} else if (lastMessage.message_data.attachment) {
if (lastMessage.message_data.attachment.video) {
messageEntry.preview = lastSenderWasUser ? LOC.you_sent_video.message : LOC.user_sent_video.message.replace('$NAME$', escapeHTML(lastMessageUser.name));
} else if (lastMessage.message_data.attachment.photo) {
messageEntry.preview = lastSenderWasUser ? LOC.you_sent_photo.message : LOC.user_sent_photo.message.replace('$NAME$', escapeHTML(lastMessageUser.name));
} else if (lastMessage.message_data.attachment.tweet) {
messageEntry.preview = lastSenderWasUser ? LOC.you_shared_tweet.message : LOC.user_shared_tweet.message.replace('$NAME$', escapeHTML(lastMessageUser.name));
} else if (c.type == 'GROUP_DM') { //other attachments like tweets, links, cards, etc (this should just end up being a t.co link) (same with the last else)
messageEntry.preview = escapeHTML(lastMessageUser.name) + ': ' + escapeHTML(lastMessage.message_data.text);
} else {
messageEntry.preview = escapeHTML(lastMessage.message_data.text); //other attachments like tweets, links, cards, etc (this should just end up being a t.co link)
messageEntry.preview = escapeHTML(lastMessage.message_data.text);
}
} else if (c.type == 'GROUP_DM') {
messageEntry.preview = escapeHTML(lastMessageUser.name) + ': ' + escapeHTML(lastMessage.message_data.text);
} else {
messageEntry.preview = escapeHTML(lastMessage.message_data.text);
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/apis.js
Original file line number Diff line number Diff line change
Expand Up @@ -1809,7 +1809,7 @@ const API = {
},
getMediaTweets: (id, cursor) => {
return new Promise((resolve, reject) => {
fetch(`https://twitter.com/i/api/graphql/qJPOeW9Q8icdlpfnPhsqJQ/UserMedia?variables=${encodeURIComponent(JSON.stringify({"userId":id,"count":20,"cursor":cursor,"includePromotedContent":false,"withDownvotePerspective":false,"withReactionsMetadata":false,"withReactionsPerspective":false,"withClientEventToken":false,"withBirdwatchNotes":false,"withVoice":true,"withV2Timeline":true}))}&features=${encodeURIComponent(JSON.stringify({"blue_business_profile_image_shape_enabled":false,"responsive_web_graphql_exclude_directive_enabled":true,"verified_phone_label_enabled":false,"responsive_web_graphql_timeline_navigation_enabled":true,"responsive_web_graphql_skip_user_profile_image_extensions_enabled":false,"tweetypie_unmention_optimization_enabled":true,"vibe_api_enabled":true,"responsive_web_edit_tweet_api_enabled":true,"graphql_is_translatable_rweb_tweet_is_translatable_enabled":true,"view_counts_everywhere_api_enabled":true,"longform_notetweets_consumption_enabled":true,"tweet_awards_web_tipping_enabled":false,"freedom_of_speech_not_reach_fetch_enabled":false,"standardized_nudges_misinfo":true,"tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled":false,"interactive_text_enabled":true,"responsive_web_text_conversations_enabled":false,"longform_notetweets_richtext_consumption_enabled":false,"responsive_web_enhance_cards_enabled":false}))}`, {
fetch(`https://twitter.com/i/api/graphql/oMVVrI5kt3kOpyHHTTKf5Q/UserMedia?variables=${encodeURIComponent(JSON.stringify({"userId":id,"count":20,"cursor":cursor,"includePromotedContent":false,"withDownvotePerspective":false,"withReactionsMetadata":false,"withReactionsPerspective":false,"withClientEventToken":false,"withBirdwatchNotes":false,"withVoice":true,"withV2Timeline":true}))}&features=${encodeURIComponent(JSON.stringify({"blue_business_profile_image_shape_enabled":false,"responsive_web_graphql_exclude_directive_enabled":true,"verified_phone_label_enabled":false,"responsive_web_graphql_timeline_navigation_enabled":true,"responsive_web_graphql_skip_user_profile_image_extensions_enabled":false,"tweetypie_unmention_optimization_enabled":true,"vibe_api_enabled":true,"responsive_web_edit_tweet_api_enabled":true,"graphql_is_translatable_rweb_tweet_is_translatable_enabled":true,"view_counts_everywhere_api_enabled":true,"longform_notetweets_consumption_enabled":true,"tweet_awards_web_tipping_enabled":false,"freedom_of_speech_not_reach_fetch_enabled":false,"standardized_nudges_misinfo":true,"tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled":false,"interactive_text_enabled":true,"responsive_web_text_conversations_enabled":false,"longform_notetweets_richtext_consumption_enabled":false,"responsive_web_enhance_cards_enabled":false,"rweb_video_timestamps_enabled":true,"longform_notetweets_inline_media_enabled":true,"c9s_tweet_anatomy_moderator_badge_enabled":true,"responsive_web_twitter_article_tweet_consumption_enabled":true,"longform_notetweets_rich_text_read_enabled":true,"creator_subscriptions_tweet_preview_api_enabled":true,"responsive_web_media_download_video_enabled":true}))}`, {
headers: {
"authorization": isFinite(+localStorage.hitRateLimit) && +localStorage.hitRateLimit > Date.now() ? OLDTWITTER_CONFIG.oauth_key : OLDTWITTER_CONFIG.public_token,
"x-csrf-token": OLDTWITTER_CONFIG.csrf,
Expand Down

0 comments on commit 1a286ee

Please sign in to comment.