Skip to content

Commit

Permalink
Added timeouts to awaits of isLoaded promises for unhindered prog…
Browse files Browse the repository at this point in the history
…ram flow ↞ [auto-sync from `adamlui/chatgpt-apps/chatgpt-infinity/greasemonkey`]
  • Loading branch information
adamlui authored and kudo-sync-bot committed May 23, 2024
1 parent 8c59673 commit 49d887d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions chrome/extension/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
})

// Init UI flag
await chatgpt.isLoaded()
await Promise.race([chatgpt.isLoaded(), new Promise(resolve => setTimeout(resolve, 1000))])
const isGPT4oUI = document.documentElement.className.includes(' ')

// Add listener to auto-disable Infinity Mode
Expand Down Expand Up @@ -82,7 +82,7 @@
updateToggleHTML() // create children

// Insert sidebar toggle
await chatgpt.sidebar.isLoaded()
await Promise.race([chatgpt.sidebar.isLoaded(), new Promise(resolve => setTimeout(resolve, 1000))])
settings.load(['extensionDisabled']).then(() => {
if (!config.extensionDisabled) insertToggle() })

Expand Down Expand Up @@ -136,7 +136,7 @@
// Define UI functions

async function insertToggle() {
await chatgpt.history.isLoaded()
await Promise.race([chatgpt.history.isLoaded(), new Promise(resolve => setTimeout(resolve, 1000))])

// Insert toggle
const parentToInsertInto = document.querySelector('nav '
Expand Down
7 changes: 4 additions & 3 deletions greasemonkey/chatgpt-infinity.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
// @description:zh-TW 從無所不知的 ChatGPT 生成無窮無盡的答案 (用任何語言!)
// @author Adam Lui
// @namespace https://github.com/adamlui
// @version 2024.5.20
// @version 2024.5.23
// @license MIT
// @match *://chatgpt.com/*
// @match *://chat.openai.com/*
Expand Down Expand Up @@ -278,7 +278,8 @@
}) ; if (!/^en/.test(config.userLanguage)) try { msgs = await msgsLoaded; } catch (err) {}

// Create browser toolbar menu or disable script if extension installed
await chatgpt.sidebar.isLoaded() // to let Chromium extension flag inject first
await Promise.race([ // to let Chromium extension flag inject first
chatgpt.sidebar.isLoaded(), new Promise(resolve => setTimeout(resolve, 1000))])
const state = {
symbol: ['✔️', '❌'], word: ['ON', 'OFF'],
separator: getUserscriptManager() == 'Tampermonkey' ? ' — ' : ': ' }
Expand Down Expand Up @@ -589,7 +590,7 @@
// Define UI functions

async function insertToggle() {
await chatgpt.history.isLoaded()
await Promise.race([chatgpt.history.isLoaded(), new Promise(resolve => setTimeout(resolve, 1000))])

// Insert toggle
const parentToInsertInto = document.querySelector('nav '
Expand Down

0 comments on commit 49d887d

Please sign in to comment.