From f4a90285fedfa9a16227072a790e3f1c50137765 Mon Sep 17 00:00:00 2001 From: dimden Date: Wed, 13 Sep 2023 02:34:34 +0300 Subject: [PATCH] save scroll on Load more button click --- layouts/header/script.js | 4 ++++ scripts/apis.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/layouts/header/script.js b/layouts/header/script.js index 3b1e48b3..4e8d8d26 100644 --- a/layouts/header/script.js +++ b/layouts/header/script.js @@ -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')); diff --git a/scripts/apis.js b/scripts/apis.js index 75d84f33..1111aa8a 100644 --- a/scripts/apis.js +++ b/scripts/apis.js @@ -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,