Skip to content

Commit

Permalink
save scroll on Load more button click
Browse files Browse the repository at this point in the history
  • Loading branch information
dimdenGD committed Sep 12, 2023
1 parent f28d9a4 commit f4a9028
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions layouts/header/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -974,10 +974,14 @@ let userDataFunction = async user => {
messageElements.push(messageElement);
}
if(!newMessages) {
let savedScroll = messageBox.parentElement.scrollTop;
let oldHeight = messageBox.parentElement.scrollHeight;
messageElements = messageElements.reverse();
for(let i in messageElements) {
messageBox.prepend(messageElements[i], document.createElement('br'));
}
let newScroll = messageBox.scrollHeight - oldHeight + savedScroll;
messageBox.parentElement.scrollTop = newScroll;
} else {
for(let i in messageElements) {
messageBox.append(messageElements[i], document.createElement('br'));
Expand Down
2 changes: 1 addition & 1 deletion scripts/apis.js
Original file line number Diff line number Diff line change
Expand Up @@ -4083,7 +4083,7 @@ const API = {
},
getConversation: (id, max_id) => {
return new Promise((resolve, reject) => {
fetch(`https://twitter.com/i/api/1.1/dm/conversation/${id}.json?${max_id ? `max_id=${max_id}&` : ''}count=100&context=FETCH_DM_CONVERSATION_HISTORY&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&include_ext_is_blue_verified=1&include_ext_verified_type=1&include_ext_profile_image_shape=1&skip_status=1&dm_secret_conversations_enabled=false&krs_registration_enabled=true&cards_platform=Web-12&include_cards=1&include_ext_alt_text=true&include_ext_limited_action_results=true&include_quote_count=true&include_reply_count=1&tweet_mode=extended&include_ext_views=true&dm_users=false&include_groups=true&include_inbox_timelines=true&include_ext_media_color=true&supports_reactions=true&include_conversation_info=true&ext=mediaColor%2CaltText%2CmediaStats%2ChighlightedLabel%2ChasNftAvatar%2CvoiceInfo%2CbirdwatchPivot%2CsuperFollowMetadata%2CunmentionInfo%2CeditControl`, {
fetch(`https://twitter.com/i/api/1.1/dm/conversation/${id}.json?${max_id ? `max_id=${max_id}&` : ''}count=30&context=FETCH_DM_CONVERSATION_HISTORY&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&include_ext_is_blue_verified=1&include_ext_verified_type=1&include_ext_profile_image_shape=1&skip_status=1&dm_secret_conversations_enabled=false&krs_registration_enabled=true&cards_platform=Web-12&include_cards=1&include_ext_alt_text=true&include_ext_limited_action_results=true&include_quote_count=true&include_reply_count=1&tweet_mode=extended&include_ext_views=true&dm_users=false&include_groups=true&include_inbox_timelines=true&include_ext_media_color=true&supports_reactions=true&include_conversation_info=true&ext=mediaColor%2CaltText%2CmediaStats%2ChighlightedLabel%2ChasNftAvatar%2CvoiceInfo%2CbirdwatchPivot%2CsuperFollowMetadata%2CunmentionInfo%2CeditControl`, {
headers: {
"authorization": OLDTWITTER_CONFIG.oauth_key,
"x-csrf-token": OLDTWITTER_CONFIG.csrf,
Expand Down

0 comments on commit f4a9028

Please sign in to comment.