From 672c1b27c9187e02c3eed869188072f7861ad0a0 Mon Sep 17 00:00:00 2001 From: "adamlui@protonmail.com" Date: Wed, 28 Aug 2024 01:55:48 -0700 Subject: [PATCH] Updated selectors in `chatgpt.sidebar` methods, optimized `isToggleBtn` in `.toggle()` --- chatgpt.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/chatgpt.js b/chatgpt.js index a7e461085..0104d8aed 100644 --- a/chatgpt.js +++ b/chatgpt.js @@ -1740,7 +1740,7 @@ const chatgpt = { // eslint-disable-line no-redeclare show() { this.isOff() ? this.toggle() : console.info('Sidebar already shown!'); }, isOff() { return !this.isOn(); }, isOn() { - const sidebar = document.querySelector('#__next > div > div'); + const sidebar = document.querySelector('body script + div > div'); return chatgpt.browser.isMobile() ? document.documentElement.style.overflow == 'hidden' : sidebar.style.visibility != 'hidden' && sidebar.style.width != '0px'; @@ -1748,9 +1748,9 @@ const chatgpt = { // eslint-disable-line no-redeclare toggle() { const isMobileDevice = chatgpt.browser.isMobile(), - navBtnSelector = isMobileDevice ? '#__next button' : 'nav button', + navBtnSelector = isMobileDevice ? 'button' : 'nav button', isToggleBtn = isMobileDevice ? () => true // since 1st one is toggle - : btn => btn.querySelectorAll('svg path[d*="M8.857 3h6.286c1.084"]').length > 0; + : btn => btn.querySelector('svg path[d*="M8.857 3h6.286c1.084"]'); for (const btn of document.querySelectorAll(navBtnSelector)) if (isToggleBtn(btn)) { btn.click(); return; } },