Skip to content

Commit

Permalink
Alphabetized function defs for readability ↞ [auto-sync from https://…
Browse files Browse the repository at this point in the history
  • Loading branch information
kudo-sync-bot committed Feb 12, 2025
1 parent 90aca42 commit 8a7be20
Showing 1 changed file with 97 additions and 97 deletions.
194 changes: 97 additions & 97 deletions chatgpt/chatgpt-auto-talk/chatgpt-auto-talk.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@
// @description:zu Dlala izimpendulo ze-ChatGPT ngokuzenzakalela
// @author Adam Lui
// @namespace https://github.com/adamlui
// @version 2025.2.12
// @version 2025.2.12.1
// @license MIT
// @icon https://assets.chatgptautotalk.com/images/icons/openai/black/icon48.png?v=9f1ed3c
// @icon64 https://assets.chatgptautotalk.com/images/icons/openai/black/icon64.png?v=9f1ed3c
Expand Down Expand Up @@ -401,6 +401,11 @@
words: [app.msgs.state_off.toUpperCase(), app.msgs.state_on.toUpperCase()]
},

refresh() {
if (typeof GM_unregisterMenuCommand == 'undefined') return
for (const id of menu.ids) { GM_unregisterMenuCommand(id) } menu.register()
},

register() {

// Add toggles
Expand All @@ -422,11 +427,6 @@
+ ` ${app.msgs[`menuLabel_${entryType}`]} ${ entryType == 'about' ? app.msgs.appName : '' }`,
() => modals.open(entryType), env.scriptManager.supportsTooltips ? { title: ' ' } : undefined
)))
},

refresh() {
if (typeof GM_unregisterMenuCommand == 'undefined') return
for (const id of menu.ids) { GM_unregisterMenuCommand(id) } menu.register()
}
}

Expand Down Expand Up @@ -487,89 +487,6 @@
stack: [], // of types of undismissed modals
class: `${app.slug}-modal`,

alert(title = '', msg = '', btns = '', checkbox = '', width = '') { // generic one from chatgpt.alert()
const alertID = chatgpt.alert(title, msg, btns, checkbox, width),
alert = document.getElementById(alertID).firstChild
this.init(alert) // add classes + rising particles bg
return alert
},

open(modalType, modalSubType) {
const modal = modalSubType ? this[modalType][modalSubType]() : this[modalType]() // show modal
if (!modal) return // since no div returned
this.stack.unshift(modalSubType ? `${modalType}_${modalSubType}` : modalType) // add to stack
this.init(modal) // add classes + rising particles bg
this.observeRemoval(modal, modalType, modalSubType) // to maintain stack for proper nav
},

init(modal) {
if (!this.styles) this.stylize() // to init/append stylesheet
modal.classList.add('no-user-select', this.class) ; modal.parentNode.classList.add(`${this.class}-bg`)
dom.addRisingParticles(modal)
},

stylize() {
if (!this.styles) {
this.styles = dom.create.style(null, { id: `${this.class}-styles` })
document.head.append(this.styles)
}
this.styles.innerText = (
`.no-user-select {
user-select: none ; -webkit-user-select: none ; -moz-user-select: none ; -ms-user-select: none }`
+ `.${this.class} {` // modals
+ 'font-family: -apple-system, system-ui, BlinkMacSystemFont, Segoe UI, Roboto,'
+ 'Oxygen-Sans, Ubuntu, Cantarell, Helvetica Neue, sans-serif ;'
+ 'padding: 20px 25px 24px 25px !important ; font-size: 20px ;'
+ `color: ${ env.ui.scheme == 'dark' ? 'white' : 'black' } !important ;`
+ `background-image: linear-gradient(180deg, ${
env.ui.scheme == 'dark' ? '#99a8a6 -200px, black 200px' : '#b6ebff -296px, white 171px' }) }`
+ `.${this.class} [class*=modal-close-btn] {`
+ 'position: absolute !important ; float: right ; top: 14px !important ; right: 16px !important ;'
+ 'cursor: pointer ; width: 33px ; height: 33px ; border-radius: 20px }'
+ `.${this.class} [class*=modal-close-btn] svg { height: 10px }`
+ `.${this.class} [class*=modal-close-btn] path {`
+ `${ env.ui.scheme == 'dark' ? 'stroke: white ; fill: white' : 'stroke: #9f9f9f ; fill: #9f9f9f' }}`
+ ( env.ui.scheme == 'dark' ? // invert dark mode hover paths
`.${this.class} [class*=modal-close-btn]:hover path { stroke: black ; fill: black }` : '' )
+ `.${this.class} [class*=modal-close-btn]:hover { background-color: #f2f2f2 }` // hover underlay
+ `.${this.class} [class*=modal-close-btn] svg { margin: 11.5px }` // center SVG for hover underlay
+ `.${this.class} a { color: #${ env.ui.scheme == 'dark' ? '00cfff' : '1e9ebb' } !important }`
+ `.${this.class} h2 { font-weight: bold }`
+ `.${this.class} button {`
+ '--btn-transition: transform 0.1s ease-in-out, box-shadow 0.1s ease-in-out ;'
+ 'font-size: 14px ; text-transform: uppercase ;' // shrink/uppercase labels
+ 'border-radius: 0 !important ;' // square borders
+ 'transition: var(--btn-transition) ;' // smoothen hover fx
+ '-webkit-transition: var(--btn-transition) ; -moz-transition: var(--btn-transition) ;'
+ '-o-transition: var(--btn-transition) ; -ms-transition: var(--btn-transition) ;'
+ 'cursor: pointer !important ;' // add finger cursor
+ `border: 1px solid ${ env.ui.scheme == 'dark' ? 'white' : 'black' } !important ;`
+ 'padding: 8px !important ; min-width: 102px }' // resize
+ `.${this.class} button:hover {` // add zoom, re-scheme
+ 'transform: scale(1.055) ; color: black !important ;'
+ `background-color: #${ env.ui.scheme == 'dark' ? '00cfff' : '9cdaff' } !important }`
+ ( !env.browser.isMobile ? `.${this.class} .modal-buttons { margin-left: -13px !important }` : '' )
+ `.about-em { color: ${ env.ui.scheme == 'dark' ? 'white' : 'green' } !important }`
)
},

observeRemoval(modal, modalType, modalSubType) { // to maintain stack for proper nav
const modalBG = modal.parentNode
new MutationObserver(([mutation], obs) => {
mutation.removedNodes.forEach(removedNode => { if (removedNode == modalBG) {
if (modals.stack[0].includes(modalSubType || modalType)) { // new modal not launched so nav back
modals.stack.shift() // remove this modal type from stack 1st
const prevModalType = modals.stack[0]
if (prevModalType) { // open it
modals.stack.shift() // remove type from stack since re-added on open
modals.open(prevModalType)
}
}
obs.disconnect()
}})
}).observe(modalBG.parentNode, { childList: true, subtree: true })
},

about() {

// Show modal
Expand Down Expand Up @@ -631,6 +548,13 @@
return aboutModal
},

alert(title = '', msg = '', btns = '', checkbox = '', width = '') { // generic one from chatgpt.alert()
const alertID = chatgpt.alert(title, msg, btns, checkbox, width),
alert = document.getElementById(alertID).firstChild
this.init(alert) // add classes + rising particles bg
return alert
},

donate() {

// Show modal
Expand Down Expand Up @@ -687,6 +611,84 @@
return donateModal
},

init(modal) {
if (!this.styles) this.stylize() // to init/append stylesheet
modal.classList.add('no-user-select', this.class) ; modal.parentNode.classList.add(`${this.class}-bg`)
dom.addRisingParticles(modal)
},

observeRemoval(modal, modalType, modalSubType) { // to maintain stack for proper nav
const modalBG = modal.parentNode
new MutationObserver(([mutation], obs) => {
mutation.removedNodes.forEach(removedNode => { if (removedNode == modalBG) {
if (modals.stack[0].includes(modalSubType || modalType)) { // new modal not launched so nav back
modals.stack.shift() // remove this modal type from stack 1st
const prevModalType = modals.stack[0]
if (prevModalType) { // open it
modals.stack.shift() // remove type from stack since re-added on open
modals.open(prevModalType)
}
}
obs.disconnect()
}})
}).observe(modalBG.parentNode, { childList: true, subtree: true })
},

open(modalType, modalSubType) {
const modal = modalSubType ? this[modalType][modalSubType]() : this[modalType]() // show modal
if (!modal) return // since no div returned
this.stack.unshift(modalSubType ? `${modalType}_${modalSubType}` : modalType) // add to stack
this.init(modal) // add classes + rising particles bg
this.observeRemoval(modal, modalType, modalSubType) // to maintain stack for proper nav
},

safeWinOpen(url) { open(url, '_blank', 'noopener') }, // to prevent backdoor vulnerabilities

stylize() {
if (!this.styles) {
this.styles = dom.create.style(null, { id: `${this.class}-styles` })
document.head.append(this.styles)
}
this.styles.innerText = (
`.no-user-select {
user-select: none ; -webkit-user-select: none ; -moz-user-select: none ; -ms-user-select: none }`
+ `.${this.class} {` // modals
+ 'font-family: -apple-system, system-ui, BlinkMacSystemFont, Segoe UI, Roboto,'
+ 'Oxygen-Sans, Ubuntu, Cantarell, Helvetica Neue, sans-serif ;'
+ 'padding: 20px 25px 24px 25px !important ; font-size: 20px ;'
+ `color: ${ env.ui.scheme == 'dark' ? 'white' : 'black' } !important ;`
+ `background-image: linear-gradient(180deg, ${
env.ui.scheme == 'dark' ? '#99a8a6 -200px, black 200px' : '#b6ebff -296px, white 171px' }) }`
+ `.${this.class} [class*=modal-close-btn] {`
+ 'position: absolute !important ; float: right ; top: 14px !important ; right: 16px !important ;'
+ 'cursor: pointer ; width: 33px ; height: 33px ; border-radius: 20px }'
+ `.${this.class} [class*=modal-close-btn] svg { height: 10px }`
+ `.${this.class} [class*=modal-close-btn] path {`
+ `${ env.ui.scheme == 'dark' ? 'stroke: white ; fill: white' : 'stroke: #9f9f9f ; fill: #9f9f9f' }}`
+ ( env.ui.scheme == 'dark' ? // invert dark mode hover paths
`.${this.class} [class*=modal-close-btn]:hover path { stroke: black ; fill: black }` : '' )
+ `.${this.class} [class*=modal-close-btn]:hover { background-color: #f2f2f2 }` // hover underlay
+ `.${this.class} [class*=modal-close-btn] svg { margin: 11.5px }` // center SVG for hover underlay
+ `.${this.class} a { color: #${ env.ui.scheme == 'dark' ? '00cfff' : '1e9ebb' } !important }`
+ `.${this.class} h2 { font-weight: bold }`
+ `.${this.class} button {`
+ '--btn-transition: transform 0.1s ease-in-out, box-shadow 0.1s ease-in-out ;'
+ 'font-size: 14px ; text-transform: uppercase ;' // shrink/uppercase labels
+ 'border-radius: 0 !important ;' // square borders
+ 'transition: var(--btn-transition) ;' // smoothen hover fx
+ '-webkit-transition: var(--btn-transition) ; -moz-transition: var(--btn-transition) ;'
+ '-o-transition: var(--btn-transition) ; -ms-transition: var(--btn-transition) ;'
+ 'cursor: pointer !important ;' // add finger cursor
+ `border: 1px solid ${ env.ui.scheme == 'dark' ? 'white' : 'black' } !important ;`
+ 'padding: 8px !important ; min-width: 102px }' // resize
+ `.${this.class} button:hover {` // add zoom, re-scheme
+ 'transform: scale(1.055) ; color: black !important ;'
+ `background-color: #${ env.ui.scheme == 'dark' ? '00cfff' : '9cdaff' } !important }`
+ ( !env.browser.isMobile ? `.${this.class} .modal-buttons { margin-left: -13px !important }` : '' )
+ `.about-em { color: ${ env.ui.scheme == 'dark' ? 'white' : 'green' } !important }`
)
},

update: {
width: 377,

Expand Down Expand Up @@ -720,23 +722,21 @@
'', '', modals.update.width
)
}
},

safeWinOpen(url) { open(url, '_blank', 'noopener') } // to prevent backdoor vulnerabilities
}
}

// Define UI functions

function syncConfigToUI() {
toggles.sidebar.update.state() // based on config.autoTalkDisabled + config.toggleHidden
menu.refresh() // prefixes/suffixes
}

function getScheme() {
return document.documentElement.className
|| (window.matchMedia?.('(prefers-color-scheme: dark)')?.matches ? 'dark' : 'light')
}

function syncConfigToUI() {
toggles.sidebar.update.state() // based on config.autoTalkDisabled + config.toggleHidden
menu.refresh() // prefixes/suffixes
}

const toggles = {

sidebar: {
Expand Down

0 comments on commit 8a7be20

Please sign in to comment.