Skip to content

Commit

Permalink
Replaced interval w/ timer func in chatgpt.isLoaded() for improved …
Browse files Browse the repository at this point in the history
…efficiency
  • Loading branch information
adamlui authored May 16, 2024
1 parent c3554c5 commit 71a5034
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions chatgpt.js
Original file line number Diff line number Diff line change
Expand Up @@ -1052,10 +1052,10 @@ const chatgpt = { // eslint-disable-line no-redeclare

isLoaded: function() {
return new Promise(resolve => {
const isLoadedCheckerID = setInterval(() => {
if (chatgpt.getNewChatButton()) {
clearInterval(isLoadedCheckerID); resolve(true);
}}, 100);
(function checkIsLoaded() {
if (chatgpt.getNewChatButton()) resolve(true);
else setTimeout(checkIsLoaded, 100);
})();
});},

isLightMode: function() { return document.documentElement.classList.toString().includes('light'); },
Expand Down

0 comments on commit 71a5034

Please sign in to comment.