Skip to content

Commit

Permalink
Alphabetized dom.js methods for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
adamlui committed Jan 30, 2025
1 parent 05f8e0f commit 7391125
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 103 deletions.
2 changes: 1 addition & 1 deletion assets/lib/dom.js/dist/dom.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 18 additions & 18 deletions assets/lib/dom.js/src/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,20 @@ window.dom = {
for (const depName in deps) this[depName] = deps[depName] }
},

cssSelectorize(classList) {
return classList.toString()
.replace(/([:[\]\\])/g, '\\$1') // escape special chars :[]\
.replace(/^| /g, '.') // prefix w/ dot, convert spaces to dots
addRisingParticles(targetNode) { // requires https://assets.aiwebextensions.com/styles/rising-particles/dist/<gray|white>.min.css
if (targetNode.querySelector('[id*=particles]')) return
const particlesDivsContainer = document.createElement('div')
particlesDivsContainer.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(particleSize => {
const particlesDiv = document.createElement('div')
particlesDiv.id = this.imports.config?.bgAnimationsDisabled ? `particles-${particleSize}-off`
: `${( this.imports.env?.ui?.scheme || this.imports.env?.ui?.app?.scheme ) == 'dark' ? 'white'
: 'gray' }-particles-${particleSize}`
particlesDivsContainer.append(particlesDiv)
})
targetNode.prepend(particlesDivsContainer)
},

create: {
Expand Down Expand Up @@ -40,20 +50,10 @@ window.dom = {
}
},

addRisingParticles(targetNode) { // requires https://assets.aiwebextensions.com/styles/rising-particles/dist/<gray|white>.min.css
if (targetNode.querySelector('[id*=particles]')) return
const particlesDivsContainer = document.createElement('div')
particlesDivsContainer.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(particleSize => {
const particlesDiv = document.createElement('div')
particlesDiv.id = this.imports.config?.bgAnimationsDisabled ? `particles-${particleSize}-off`
: `${( this.imports.env?.ui?.scheme || this.imports.env?.ui?.app?.scheme ) == 'dark' ? 'white'
: 'gray' }-particles-${particleSize}`
particlesDivsContainer.append(particlesDiv)
})
targetNode.prepend(particlesDivsContainer)
cssSelectorize(classList) {
return classList.toString()
.replace(/([:[\]\\])/g, '\\$1') // escape special chars :[]\
.replace(/^| /g, '.') // prefix w/ dot, convert spaces to dots
},

get: {
Expand Down
28 changes: 14 additions & 14 deletions chatgpt-auto-continue/chromium/extension/lib/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ window.dom = {
for (const depName in deps) this[depName] = deps[depName] }
},

addRisingParticles(targetNode) { // requires https://assets.aiwebextensions.com/styles/rising-particles/dist/<gray|white>.min.css
if (targetNode.querySelector('[id*=particles]')) return
const particlesDivsContainer = document.createElement('div')
particlesDivsContainer.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(particleSize => {
const particlesDiv = document.createElement('div')
particlesDiv.id = `${ this.imports.env.ui.scheme == 'dark' ? 'white' : 'gray' }-particles-${particleSize}`
particlesDivsContainer.append(particlesDiv)
})
targetNode.prepend(particlesDivsContainer)
},

create: {
elem(elemType, attrs = {}) {
const elem = document.createElement(elemType)
Expand All @@ -23,19 +37,5 @@ window.dom = {
for (const attr in attrs) elem.setAttributeNS(null, attr, attrs[attr])
return elem
}
},

addRisingParticles(targetNode) { // requires https://assets.aiwebextensions.com/styles/rising-particles/dist/<gray|white>.min.css
if (targetNode.querySelector('[id*=particles]')) return
const particlesDivsContainer = document.createElement('div')
particlesDivsContainer.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(particleSize => {
const particlesDiv = document.createElement('div')
particlesDiv.id = `${ this.imports.env.ui.scheme == 'dark' ? 'white' : 'gray' }-particles-${particleSize}`
particlesDivsContainer.append(particlesDiv)
})
targetNode.prepend(particlesDivsContainer)
}
};
28 changes: 14 additions & 14 deletions chatgpt-auto-continue/firefox/extension/lib/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ window.dom = {
for (const depName in deps) this[depName] = deps[depName] }
},

addRisingParticles(targetNode) { // requires https://assets.aiwebextensions.com/styles/rising-particles/dist/<gray|white>.min.css
if (targetNode.querySelector('[id*=particles]')) return
const particlesDivsContainer = document.createElement('div')
particlesDivsContainer.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(particleSize => {
const particlesDiv = document.createElement('div')
particlesDiv.id = `${ this.imports.env.ui.scheme == 'dark' ? 'white' : 'gray' }-particles-${particleSize}`
particlesDivsContainer.append(particlesDiv)
})
targetNode.prepend(particlesDivsContainer)
},

create: {
elem(elemType, attrs = {}) {
const elem = document.createElement(elemType)
Expand All @@ -23,19 +37,5 @@ window.dom = {
for (const attr in attrs) elem.setAttributeNS(null, attr, attrs[attr])
return elem
}
},

addRisingParticles(targetNode) { // requires https://assets.aiwebextensions.com/styles/rising-particles/dist/<gray|white>.min.css
if (targetNode.querySelector('[id*=particles]')) return
const particlesDivsContainer = document.createElement('div')
particlesDivsContainer.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(particleSize => {
const particlesDiv = document.createElement('div')
particlesDiv.id = `${ this.imports.env.ui.scheme == 'dark' ? 'white' : 'gray' }-particles-${particleSize}`
particlesDivsContainer.append(particlesDiv)
})
targetNode.prepend(particlesDivsContainer)
}
};
28 changes: 14 additions & 14 deletions chatgpt-infinity/chromium/extension/lib/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ window.dom = {
for (const depName in deps) this[depName] = deps[depName] }
},

addRisingParticles(targetNode) { // requires https://assets.aiwebextensions.com/styles/rising-particles/dist/<gray|white>.min.css
if (targetNode.querySelector('[id*=particles]')) return
const particlesDivsContainer = document.createElement('div')
particlesDivsContainer.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(particleSize => {
const particlesDiv = document.createElement('div')
particlesDiv.id = `${ this.imports.env.ui.scheme == 'dark' ? 'white' : 'gray' }-particles-${particleSize}`
particlesDivsContainer.append(particlesDiv)
})
targetNode.prepend(particlesDivsContainer)
},

create: {
elem(elemType, attrs = {}) {
const elem = document.createElement(elemType)
Expand All @@ -23,19 +37,5 @@ window.dom = {
for (const attr in attrs) elem.setAttributeNS(null, attr, attrs[attr])
return elem
}
},

addRisingParticles(targetNode) { // requires https://assets.aiwebextensions.com/styles/rising-particles/dist/<gray|white>.min.css
if (targetNode.querySelector('[id*=particles]')) return
const particlesDivsContainer = document.createElement('div')
particlesDivsContainer.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(particleSize => {
const particlesDiv = document.createElement('div')
particlesDiv.id = `${ this.imports.env.ui.scheme == 'dark' ? 'white' : 'gray' }-particles-${particleSize}`
particlesDivsContainer.append(particlesDiv)
})
targetNode.prepend(particlesDivsContainer)
}
};
28 changes: 14 additions & 14 deletions chatgpt-infinity/firefox/extension/lib/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ window.dom = {
for (const depName in deps) this[depName] = deps[depName] }
},

addRisingParticles(targetNode) { // requires https://assets.aiwebextensions.com/styles/rising-particles/dist/<gray|white>.min.css
if (targetNode.querySelector('[id*=particles]')) return
const particlesDivsContainer = document.createElement('div')
particlesDivsContainer.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(particleSize => {
const particlesDiv = document.createElement('div')
particlesDiv.id = `${ this.imports.env.ui.scheme == 'dark' ? 'white' : 'gray' }-particles-${particleSize}`
particlesDivsContainer.append(particlesDiv)
})
targetNode.prepend(particlesDivsContainer)
},

create: {
elem(elemType, attrs = {}) {
const elem = document.createElement(elemType)
Expand All @@ -23,19 +37,5 @@ window.dom = {
for (const attr in attrs) elem.setAttributeNS(null, attr, attrs[attr])
return elem
}
},

addRisingParticles(targetNode) { // requires https://assets.aiwebextensions.com/styles/rising-particles/dist/<gray|white>.min.css
if (targetNode.querySelector('[id*=particles]')) return
const particlesDivsContainer = document.createElement('div')
particlesDivsContainer.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(particleSize => {
const particlesDiv = document.createElement('div')
particlesDiv.id = `${ this.imports.env.ui.scheme == 'dark' ? 'white' : 'gray' }-particles-${particleSize}`
particlesDivsContainer.append(particlesDiv)
})
targetNode.prepend(particlesDivsContainer)
}
};
28 changes: 14 additions & 14 deletions chatgpt-widescreen/chromium/extension/lib/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ window.dom = {
for (const depName in deps) this[depName] = deps[depName] }
},

addRisingParticles(targetNode) { // requires https://assets.aiwebextensions.com/styles/rising-particles/dist/<gray|white>.min.css
if (targetNode.querySelector('[id*=particles]')) return
const particlesDivsContainer = document.createElement('div')
particlesDivsContainer.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(particleSize => {
const particlesDiv = document.createElement('div')
particlesDiv.id = `${ this.imports.env.ui.scheme == 'dark' ? 'white' : 'gray' }-particles-${particleSize}`
particlesDivsContainer.append(particlesDiv)
})
targetNode.prepend(particlesDivsContainer)
},

create: {
elem(elemType, attrs = {}) {
const elem = document.createElement(elemType)
Expand All @@ -31,20 +45,6 @@ window.dom = {
.replace(/^| /g, '.') // prefix w/ dot, convert spaces to dots
},

addRisingParticles(targetNode) { // requires https://assets.aiwebextensions.com/styles/rising-particles/dist/<gray|white>.min.css
if (targetNode.querySelector('[id*=particles]')) return
const particlesDivsContainer = document.createElement('div')
particlesDivsContainer.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(particleSize => {
const particlesDiv = document.createElement('div')
particlesDiv.id = `${ this.imports.env.ui.scheme == 'dark' ? 'white' : 'gray' }-particles-${particleSize}`
particlesDivsContainer.append(particlesDiv)
})
targetNode.prepend(particlesDivsContainer)
},

getLoadedElem(selector, timeout = null) {
const timeoutPromise = timeout ? new Promise(resolve => setTimeout(() => resolve(null), timeout)) : null
const isLoadedPromise = new Promise(resolve => {
Expand Down
Loading

0 comments on commit 7391125

Please sign in to comment.