Skip to content

Commit

Permalink
Added preload navicon ↞ [auto-sync from https://github.com/adamlui/ai…
Browse files Browse the repository at this point in the history
  • Loading branch information
kudo-sync-bot committed Jan 30, 2025
1 parent c00b401 commit f3341cc
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions greasemonkey/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 2025.1.29.8
// @version 2025.1.30
// @license MIT
// @icon https://assets.chatgptautorefresh.com/images/icons/openai/black/icon48.png?v=f11a0a8
// @icon64 https://assets.chatgptautorefresh.com/images/icons/openai/black/icon64.png?v=f11a0a8
Expand Down Expand Up @@ -910,9 +910,19 @@
},

update: {
navicon() {
toggles.sidebar.navicon.src = `${app.urls.assetHost}/images/icons/auto-refresh/${
env.ui.scheme == 'dark' ? 'white' : 'black' }/icon32.png?v=${app.latestResourceCommitHash}`

navicon({ preload = false } = {}) {
const baseURL = `${app.urls.assetHost}/images/icons/auto-refresh`,
schemeMap = { light: 'black', dark: 'white' },
fileName = 'icon32.png'

if (preload)
Object.keys(schemeMap).forEach(scheme =>
new Image().src = `${baseURL}/${schemeMap[scheme]}/${fileName}?v=`
+ app.latestResourceCommitHash
)
else toggles.sidebar.navicon.src = baseURL
+ `/${schemeMap[env.ui.scheme]}/${fileName}?v=${app.latestResourceCommitHash}`
},

scheme() { // to match UI scheme
Expand Down Expand Up @@ -950,6 +960,7 @@
// Run MAIN routine

menu.register() // create browser toolbar menu
toggles.sidebar.update.navicon({ preload: true }) // preload sidebar NAVICON variants

// Init UI props
await Promise.race([chatgpt.isLoaded(), new Promise(resolve => setTimeout(resolve, 5000))]) // initial UI loaded
Expand Down

0 comments on commit f3341cc

Please sign in to comment.