Skip to content

Commit

Permalink
Updated selectors in chatgpt.sidebar methods, optimized `isToggleBt…
Browse files Browse the repository at this point in the history
…n` in `.toggle()`
  • Loading branch information
adamlui committed Aug 28, 2024
1 parent 6ba6764 commit 672c1b2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions chatgpt.js
Original file line number Diff line number Diff line change
Expand Up @@ -1740,17 +1740,17 @@ 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';
},

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; }
},
Expand Down

0 comments on commit 672c1b2

Please sign in to comment.