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-auto-refresh`]
  • Loading branch information
adamlui authored and kudo-sync-bot committed May 23, 2024
1 parent c4c2bd2 commit 02c73c3
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions chatgpt/chatgpt-auto-refresh/chatgpt-auto-refresh.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
// @description:zu *NGOKUPHEPHA* susa ukusetha kabusha ingxoxo yemizuzu eyi-10 + amaphutha enethiwekhi ahlala njalo + Ukuhlolwa kwe-Cloudflare ku-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 @@ -318,9 +318,9 @@
let menuIDs = [] ; registerMenu() // create browser toolbar menu

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

// Add/update tweaks style
const tweaksStyleUpdated = 202405171 // datestamp of last edit for this file's `tweaksStyle`
Expand Down Expand Up @@ -351,7 +351,8 @@
updateToggleHTML() // create children

// Insert sidebar toggle
await chatgpt.sidebar.isLoaded() ; insertToggle()
await Promise.race([chatgpt.sidebar.isLoaded(), new Promise(resolve => setTimeout(resolve, 1000))])
insertToggle()

// Borrow/assign classes from sidebar div
const firstLink = document.querySelector('nav a[href="/"]')
Expand Down Expand Up @@ -571,7 +572,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 02c73c3

Please sign in to comment.