Skip to content

Commit a01faa5

Browse files
committed
Replaced chatgpt.isDarkMode() w/ env.scheme ↞ [auto-sync from https://github.com/KudoAI/chatgpt.js-chrome-starter]
1 parent 00e80fc commit a01faa5

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

starters/chrome/extension/content.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515
// Import APP data
1616
const { app } = await chrome.storage.sync.get('app')
17+
18+
// Export DEPENDENCIES to imported resources
19+
dom.dependencies.import({ env }) // for env.scheme
1720
modals.dependencies.import({ app, env }) // for app data + env.scheme
1821

1922
// Add CHROME MSG listener

starters/chrome/extension/lib/dom.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
window.dom = {
2+
3+
dependencies: {
4+
import(dependencies) { // { env) }
5+
for (const name in dependencies) this[name] = dependencies[name] }
6+
},
7+
28
create: {
39
elem(elemType, attrs = {}) {
410
const elem = document.createElement(elemType)
@@ -13,14 +19,15 @@ window.dom = {
1319
}
1420
},
1521

16-
fillStarryBG(targetNode) { // requires https://assets.aiwebextensions.com/styles/css/<black|white>-rising-stars.min.css
22+
fillStarryBG(targetNode) { // requires https://assets.aiwebextensions.com/styles/rising-stars/css/<black|white>.min.css
23+
if (targetNode.querySelector('[id*=stars]')) return
1724
const starsDivsContainer = document.createElement('div')
1825
starsDivsContainer.style.cssText = 'position: absolute ; top: 0 ; left: 0 ;' // hug targetNode's top-left corner
1926
+ 'height: 100% ; width: 100% ; border-radius: 15px ; overflow: clip ;' // bound innards exactly by targetNode
2027
+ 'z-index: -1'; // allow interactive elems to be clicked
2128
['sm', 'med', 'lg'].forEach(starSize => {
2229
const starsDiv = document.createElement('div')
23-
starsDiv.id = `${ chatgpt.isDarkMode() ? 'white' : 'black' }-stars-${starSize}`
30+
starsDiv.id = `${ this.dependencies.env.scheme == 'dark' ? 'white' : 'black' }-stars-${starSize}`
2431
starsDivsContainer.append(starsDiv)
2532
})
2633
targetNode.prepend(starsDivsContainer)

0 commit comments

Comments
 (0)