Skip to content

Commit 387d357

Browse files
committed
Redesigned About modal to be more epic ↞ [auto-sync from https://github.com/KudoAI/chatgpt.js-chrome-starter]
1 parent 7a9504e commit 387d357

File tree

2 files changed

+26
-27
lines changed

2 files changed

+26
-27
lines changed

starters/chrome/extension/components/modals.js

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -121,42 +121,39 @@ window.modals = {
121121

122122
about() {
123123

124-
// Init styles
125-
const headingStyle = 'font-size: 1.15rem',
126-
pStyle = 'position: relative ; left: 3px',
127-
pBrStyle = 'position: relative ; left: 4px ',
128-
aStyle = 'color: ' + ( chatgpt.isDarkMode() ? '#c67afb' : '#8325c4' ) // purple
129-
130-
// Init buttons
131-
const modalBtns = [
132-
function getSupport(){ modals.safeWinOpen(`${modals.dependencies.app.urls.gitHub}/issues`) },
133-
function rateUs() { modals.safeWinOpen(`${modals.dependencies.app.urls.gitHub}/discussions`) },
134-
function moreAiExtensions(){ modals.safeWinOpen(modals.dependencies.app.urls.relatedExtensions) }
135-
]
136-
137124
// Show modal
138125
const aboutModal = this.alert(
139126
`${this.dependencies.app.symbol} ${chrome.runtime.getManifest().name}`, // title
140-
`<span style="${headingStyle}"><b>🏷️ <i>Version</i></b>: </span>`
141-
+ `<span style="${pStyle}">${this.dependencies.app.version}</span>\n`
142-
+ `<span style="${headingStyle}"><b>⚡ <i>Powered by</i></b>: </span>`
143-
+ `<span style="${pStyle}">`
144-
+ `<a style="${aStyle}" href="${this.dependencies.app.urls.chatgptJS}" target="_blank"`
145-
+ ' rel="noopener">chatgpt.js</a></span>\n'
146-
+ `<span style="${headingStyle}"><b>📜 <i>Open source code</i></b>:</span>\n`
147-
+ `<span style="${pBrStyle}"><a href="${this.dependencies.app.urls.gitHub}" target="_blank"`
148-
+ ` rel="nopener">${this.dependencies.app.urls.gitHub}</a></span>`,
149-
modalBtns, '', 451
127+
`🏷️ Version: <span class="about-em">${this.dependencies.app.version}</span>\n` // msg
128+
+ '⚡ Powered by: '
129+
+ `<a href="${this.dependencies.app.urls.chatgptJS}" target="_blank" rel="noopener">chatgpt.js</a>\n`
130+
+ '📜 Open source code: '
131+
+ `<a href="${this.dependencies.app.urls.gitHub}" target="_blank" rel="nopener">`
132+
+ this.dependencies.app.urls.gitHub + '</a>',
133+
[ function getSupport(){}, function rateUs(){}, function moreAiExtensions(){} ], // button labels
134+
'', 656 // modal width
150135
)
151136

152137
// Format text
153-
aboutModal.querySelector('h2').style.cssText = 'text-align: center ; font-size: 37px ; padding: 9px'
154-
aboutModal.querySelector('p').style.cssText = 'text-align: center'
138+
aboutModal.querySelector('h2').style.cssText = (
139+
'text-align: center ; font-size: 51px ; line-height: 46px ; padding: 15px 0' )
140+
aboutModal.querySelector('p').style.cssText = (
141+
'text-align: center ; overflow-wrap: anywhere ;'
142+
+ `margin: ${ this.dependencies.env.browser.isPortrait ? '6px 0 -16px' : '3px 0 0' }` )
155143

156144
// Hack buttons
157145
aboutModal.querySelector('.modal-buttons').style.justifyContent = 'center'
158146
aboutModal.querySelectorAll('button').forEach(btn => {
159-
btn.style.cssText = 'cursor: pointer !important ; height: 43px'
147+
btn.style.cssText = 'height: 55px ; min-width: 136px ; text-align: center'
148+
149+
// Replace buttons w/ clones that don't dismiss modal
150+
const btnClone = btn.cloneNode(true)
151+
btn.parentNode.replaceChild(btnClone, btn) ; btn = btnClone
152+
btn.onclick = () => this.safeWinOpen(
153+
btn.textContent == 'Get Support' ? `${modals.dependencies.app.urls.gitHub}/issues`
154+
: btn.textContent == 'Rate Us' ? `${modals.dependencies.app.urls.gitHub}/discussions`
155+
: modals.dependencies.app.urls.relatedExtensions
156+
)
160157

161158
// Prepend emoji
162159
if (/support/i.test(btn.textContent))

starters/chrome/extension/content.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
await import(chrome.runtime.getURL(resource))
99

1010
// Init ENV context
11-
const env = { scheme: getScheme() }
11+
const env = { browser: { isMobile: chatgpt.browser.isMobile() }}
12+
env.browser.isPortrait = env.browser.isMobile && (window.innerWidth < window.innerHeight)
13+
env.scheme = getScheme()
1214

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

0 commit comments

Comments
 (0)