Scroll up when switching tabs

This commit is contained in:
oobabooga 2023-08-13 18:48:15 -07:00
parent c269214219
commit b8df4a436e

View File

@ -1,19 +1,29 @@
let chat_tab = document.getElementById('chat-tab'); let chat_tab = document.getElementById('chat-tab');
let main_parent = chat_tab.parentNode; let main_parent = chat_tab.parentNode;
function scrollToTop() {
window.scrollTo({
top: 0,
// behavior: 'smooth'
});
}
function switch_to_chat() { function switch_to_chat() {
let chat_tab_button = main_parent.childNodes[0].childNodes[1]; let chat_tab_button = main_parent.childNodes[0].childNodes[1];
chat_tab_button.click(); chat_tab_button.click();
scrollToTop();
} }
function switch_to_default() { function switch_to_default() {
let default_tab_button = main_parent.childNodes[0].childNodes[4]; let default_tab_button = main_parent.childNodes[0].childNodes[4];
default_tab_button.click(); default_tab_button.click();
scrollToTop();
} }
function switch_to_notebook() { function switch_to_notebook() {
let notebook_tab_button = main_parent.childNodes[0].childNodes[7]; let notebook_tab_button = main_parent.childNodes[0].childNodes[7];
notebook_tab_button.click(); notebook_tab_button.click();
scrollToTop();
} }
function switch_to_generation_parameters() { function switch_to_generation_parameters() {
@ -21,6 +31,7 @@ function switch_to_generation_parameters() {
let generation_tab_button = document.getElementById('character-menu').parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.childNodes[0].childNodes[1]; let generation_tab_button = document.getElementById('character-menu').parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.childNodes[0].childNodes[1];
parameters_tab_button.click(); parameters_tab_button.click();
generation_tab_button.click(); generation_tab_button.click();
scrollToTop();
} }
function switch_to_character() { function switch_to_character() {
@ -28,4 +39,5 @@ function switch_to_character() {
let character_tab_button = document.getElementById('character-menu').parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.childNodes[0].childNodes[4]; let character_tab_button = document.getElementById('character-menu').parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.childNodes[0].childNodes[4];
parameters_tab_button.click(); parameters_tab_button.click();
character_tab_button.click(); character_tab_button.click();
scrollToTop();
} }