Skip to content

Commit

Permalink
Updated DOM routine in chatgpt.clearChats() to work w/ new UI
Browse files Browse the repository at this point in the history
  • Loading branch information
adamlui committed May 1, 2024
1 parent 6fea322 commit 9126842
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions chatgpt.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,21 +428,16 @@ const chatgpt = { // eslint-disable-line no-redeclare
try { await chatgpt.getChatData(); } catch { return; } // check if chat history exists
chatgpt.menu.open();
setTimeout(() => {
const menuItems = document.querySelectorAll('a[role="menuitem"]') || [];
for (const menuItem of menuItems)
if (/settings/i.test(menuItem.text)) { menuItem.click(); break; }
const settingsBtn = document.querySelector(
'a[role="menuitem"] svg path[d*="M11.6439 3C10.9352"]').parentNode.parentNode

Check failure on line 432 in chatgpt.js

View workflow job for this annotation

GitHub Actions / eslint

Missing semicolon
if (settingsBtn) settingsBtn.click()

Check failure on line 433 in chatgpt.js

View workflow job for this annotation

GitHub Actions / eslint

Missing semicolon
setTimeout(() => { // clear chats
const settingsBtns = document.querySelectorAll('[id*=radix] button');
for (const settingsBtn of settingsBtns)
if (/^clear/i.test(settingsBtn.textContent)) { settingsBtn.click(); break; }
const settingsBtns = document.querySelectorAll('[id*=radix] button'),
deleteBtn = settingsBtns[settingsBtns.length - 1];
if (deleteBtn) deleteBtn.click()

Check failure on line 437 in chatgpt.js

View workflow job for this annotation

GitHub Actions / eslint

Missing semicolon
setTimeout(() => { // confirm clear
document.querySelector('[id*=radix] button').click();
setTimeout(() => {
exitMenu();
try { document.querySelector('#prompt-textarea').focus(); } catch (err) {}
}, 10);
document.querySelector('button[class*="danger"').click();
}, 10); }, 333); }, 10);
const exitMenu = () => { document.querySelector('div[id*=radix] button').click(); };

} else { // API method
// NOTE: DOM is not updated to reflect new empty chat list (until session refresh)
Expand Down

0 comments on commit 9126842

Please sign in to comment.