Skip to content

Commit

Permalink
Replaced chatgpt.isDarkMode() w/ env.scheme ↞ [auto-sync from htt…
Browse files Browse the repository at this point in the history
  • Loading branch information
kudo-sync-bot committed Dec 21, 2024
1 parent 00e80fc commit a01faa5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions starters/chrome/extension/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

// Import APP data
const { app } = await chrome.storage.sync.get('app')

// Export DEPENDENCIES to imported resources
dom.dependencies.import({ env }) // for env.scheme
modals.dependencies.import({ app, env }) // for app data + env.scheme

// Add CHROME MSG listener
Expand Down
11 changes: 9 additions & 2 deletions starters/chrome/extension/lib/dom.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
window.dom = {

dependencies: {
import(dependencies) { // { env) }
for (const name in dependencies) this[name] = dependencies[name] }
},

create: {
elem(elemType, attrs = {}) {
const elem = document.createElement(elemType)
Expand All @@ -13,14 +19,15 @@ window.dom = {
}
},

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

0 comments on commit a01faa5

Please sign in to comment.