Skip to content

Commit 310b092

Browse files
committed
Renamed newly specialized lib/browser.js to i18n.js
1 parent 16f352b commit 310b092

File tree

42 files changed

+300
-300
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+300
-300
lines changed

chatgpt-auto-continue/chromium/extension/components/modals.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ window.modals = {
1111
: 'chromium'
1212
},
1313

14-
about() { // requires lib/browser.js + <app|env>
14+
about() { // requires lib/i18n.js + <app|env>
1515
const { browser: { isPortrait }, ui: { scheme }} = env
1616

1717
// Init buttons
@@ -27,19 +27,19 @@ window.modals = {
2727
const labelStyles = 'text-transform: uppercase ; font-size: 17px ; font-weight: bold ;'
2828
+ `color: ${ scheme == 'dark' ? 'white' : '#494141' }`
2929
const aboutModal = modals.alert(
30-
`${app.symbol} ${browserAPI.getMsg('appName')}`, // title
31-
`<span style="${labelStyles}">🧠 ${browserAPI.getMsg('about_author')}:</span> `
32-
+ `<a href="${app.author.url}">${browserAPI.getMsg('appAuthor')}</a> ${browserAPI.getMsg('about_and')}`
33-
+ ` <a href="${app.urls.contributors}">${browserAPI.getMsg('about_contributors')}</a>\n`
34-
+ `<span style="${labelStyles}">🏷️ ${browserAPI.getMsg('about_version')}:</span> `
30+
`${app.symbol} ${i18n.getMsg('appName')}`, // title
31+
`<span style="${labelStyles}">🧠 ${i18n.getMsg('about_author')}:</span> `
32+
+ `<a href="${app.author.url}">${i18n.getMsg('appAuthor')}</a> ${i18n.getMsg('about_and')}`
33+
+ ` <a href="${app.urls.contributors}">${i18n.getMsg('about_contributors')}</a>\n`
34+
+ `<span style="${labelStyles}">🏷️ ${i18n.getMsg('about_version')}:</span> `
3535
+ `<span class="about-em">${app.version}</span>\n`
36-
+ `<span style="${labelStyles}">📜 ${browserAPI.getMsg('about_openSourceCode')}:</span> `
36+
+ `<span style="${labelStyles}">📜 ${i18n.getMsg('about_openSourceCode')}:</span> `
3737
+ `<a href="${app.urls.github}" target="_blank" rel="nopener">`
3838
+ app.urls.github + '</a>\n'
39-
+ `<span style="${labelStyles}">🚀 ${browserAPI.getMsg('about_latestChanges')}:</span> `
39+
+ `<span style="${labelStyles}">🚀 ${i18n.getMsg('about_latestChanges')}:</span> `
4040
+ `<a href="${app.urls.github}/commits/main/${this.runtime}" target="_blank" rel="nopener">`
4141
+ `${app.urls.github}/commits/main/${this.runtime}</a>\n`
42-
+ `<span style="${labelStyles}">⚡ ${browserAPI.getMsg('about_poweredBy')}:</span> `
42+
+ `<span style="${labelStyles}">⚡ ${i18n.getMsg('about_poweredBy')}:</span> `
4343
+ `<a href="${app.urls.chatgptjs}" target="_blank" rel="noopener">chatgpt.js</a>`,
4444
modalBtns, '', 747
4545
)
@@ -60,20 +60,20 @@ window.modals = {
6060
if (/support|extensions/i.test(btn.textContent)) {
6161
btn.replaceWith(btn = btn.cloneNode(true))
6262
btn.onclick = () => this.safeWinOpen(app.urls[
63-
btn.textContent.includes(browserAPI.getMsg('btnLabel_getSupport')) ? 'support' : 'relatedExtensions' ])
63+
btn.textContent.includes(i18n.getMsg('btnLabel_getSupport')) ? 'support' : 'relatedExtensions' ])
6464
}
6565

6666
// Prepend emoji + localize labels
6767
if (/updates/i.test(btn.textContent))
68-
btn.textContent = `🚀 ${browserAPI.getMsg('btnLabel_checkForUpdates')}`
68+
btn.textContent = `🚀 ${i18n.getMsg('btnLabel_checkForUpdates')}`
6969
else if (/support/i.test(btn.textContent))
70-
btn.textContent = `🧠 ${browserAPI.getMsg('btnLabel_getSupport')}`
70+
btn.textContent = `🧠 ${i18n.getMsg('btnLabel_getSupport')}`
7171
else if (/rate/i.test(btn.textContent))
72-
btn.textContent = `⭐ ${browserAPI.getMsg('btnLabel_rateUs')}`
72+
btn.textContent = `⭐ ${i18n.getMsg('btnLabel_rateUs')}`
7373
else if (/discuss/i.test(btn.textContent))
74-
btn.textContent = `🗨️ ${browserAPI.getMsg('btnLabel_discuss')}`
74+
btn.textContent = `🗨️ ${i18n.getMsg('btnLabel_discuss')}`
7575
else if (/extensions/i.test(btn.textContent))
76-
btn.textContent = `🤖 ${browserAPI.getMsg('btnLabel_moreAIextensions')}`
76+
btn.textContent = `🤖 ${i18n.getMsg('btnLabel_moreAIextensions')}`
7777

7878
// Hide Dismiss button
7979
else btn.style.display = 'none'
@@ -89,7 +89,7 @@ window.modals = {
8989
return alert
9090
},
9191

92-
feedback() { // requires lib/browser.js + app.sourceWebStore
92+
feedback() { // requires lib/i18n.js + app.sourceWebStore
9393

9494
// Init buttons
9595
const modalBtns = [function softonic(){}]
@@ -101,7 +101,7 @@ window.modals = {
101101
)
102102

103103
// Show modal
104-
const feedbackModal = modals.alert(`${browserAPI.getMsg('alert_choosePlatform')}:`, '', modalBtns)
104+
const feedbackModal = modals.alert(`${i18n.getMsg('alert_choosePlatform')}:`, '', modalBtns)
105105
feedbackModal.style.display = 'inline-table' // allow many buttons to fit
106106

107107
// Hack buttons

chatgpt-auto-continue/chromium/extension/content.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
// Import JS resources
2222
for (const resource of [
23-
'components/modals.js', 'lib/browser.js', 'lib/chatgpt.min.js', 'lib/dom.min.js',
23+
'components/modals.js', 'lib/i18n.js', 'lib/chatgpt.min.js', 'lib/dom.min.js',
2424
'lib/feedback.js', 'lib/settings.js', 'lib/styles.js', 'lib/sync.js', 'lib/ui.js'
2525
]) await import(chrome.runtime.getURL(resource))
2626

@@ -46,7 +46,7 @@
4646
btn.click()
4747
if (btnType == 'Continue') {
4848
continueBtnClicked = true
49-
feedback.notify(browserAPI.getMsg('notif_chatAutoContinued'), 'bottom-right')
49+
feedback.notify(i18n.getMsg('notif_chatAutoContinued'), 'bottom-right')
5050
if (config.autoScroll) try { chatgpt.scrollToBottom() } catch(err) {}
5151
}})
5252
setTimeout(checkBtnsToClick, continueBtnClicked ? 5000 : 500)
@@ -66,7 +66,7 @@
6666
checkBtnsToClick()
6767

6868
// NOTIFY of status on load
69-
feedback.notify(`${browserAPI.getMsg('mode_autoContinue')}: ${ browserAPI.getMsg('state_on').toUpperCase()}`)
69+
feedback.notify(`${i18n.getMsg('mode_autoContinue')}: ${ i18n.getMsg('state_on').toUpperCase()}`)
7070
}
7171

7272
// Monitor SCHEME PREF changes to update sidebar toggle + modal colors

chatgpt-auto-continue/chromium/extension/lib/feedback.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ window.feedback = {
44
notify(msg, pos = '', notifDuration = '', shadow = '') {
55
if (!styles.toast.node) styles.update({ key: 'toast' })
66
if (config.notifDisabled
7-
&& !new RegExp(`${browserAPI.getMsg('menuLabel_show')} ${browserAPI.getMsg('menuLabel_notifs')}`, 'i')
7+
&& !new RegExp(`${i18n.getMsg('menuLabel_show')} ${i18n.getMsg('menuLabel_notifs')}`, 'i')
88
.test(msg)
99
) return
1010

1111
// Strip state word to append colored one later
1212
const foundState = [
13-
browserAPI.getMsg('state_on').toUpperCase(), browserAPI.getMsg('state_off').toUpperCase()
13+
i18n.getMsg('state_on').toUpperCase(), i18n.getMsg('state_off').toUpperCase()
1414
].find(word => msg.includes(word))
1515
if (foundState) msg = msg.replace(foundState, '')
1616

@@ -34,7 +34,7 @@ window.feedback = {
3434
}
3535
const styledStateSpan = dom.create.elem('span')
3636
styledStateSpan.style.cssText = stateStyles[
37-
foundState == browserAPI.getMsg('state_off').toUpperCase() ? 'off' : 'on'][env.ui.scheme]
37+
foundState == i18n.getMsg('state_off').toUpperCase() ? 'off' : 'on'][env.ui.scheme]
3838
styledStateSpan.append(foundState) ; notif.append(styledStateSpan)
3939
}
4040
}

chatgpt-auto-continue/chromium/extension/lib/browser.js renamed to chatgpt-auto-continue/chromium/extension/lib/i18n.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
window.browserAPI = {
2+
window.i18n = {
33
getMsg(key) {
44
return typeof GM_info == 'undefined' ?
55
chrome.i18n.getMessage(key) // from ./_locales/*/messages.json

chatgpt-auto-continue/chromium/extension/popup/controller.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
document.documentElement.classList.add('dark')
66

77
// Import JS resources
8-
for (const resource of ['components/icons.js', 'lib/browser.js', 'lib/dom.min.js', 'lib/settings.js'])
8+
for (const resource of ['components/icons.js', 'lib/i18n.js', 'lib/dom.min.js', 'lib/settings.js'])
99
await import(chrome.runtime.getURL(resource))
1010

1111
// Init DATA
@@ -63,19 +63,19 @@
6363
entry.label.textContent += `: ${entry.slider.value}${ entryData.labelSuffix || '' }`
6464
entry.label.append(entry.editLink = dom.create.elem('span', {
6565
class: 'edit-link', role: 'button', tabindex: '0', 'aria-label': entryData.helptip,
66-
textContent: browserAPI.getMsg('promptLabel_edit')
66+
textContent: i18n.getMsg('promptLabel_edit')
6767
}))
6868
entry.slider.style.setProperty('--track-fill-percent', `${ entry.slider.value / entry.slider.max *100 }%`)
6969

7070
// Add listeners
7171
entry.editLink.onclick = () => {
72-
const promptMsg = `${browserAPI.getMsg('prompt_enterNewVal')} ${entryData.label} (${
73-
browserAPI.getMsg('error_between')} ${minVal}${maxVal}):`
72+
const promptMsg = `${i18n.getMsg('prompt_enterNewVal')} ${entryData.label} (${
73+
i18n.getMsg('error_between')} ${minVal}${maxVal}):`
7474
const userVal = prompt(promptMsg, entry.slider.value)
7575
if (userVal == null) return // user cancelled so do nothing
7676
if (!/\d/.test(userVal)) return alert(`${
77-
browserAPI.getMsg('error_enterValidNum')} ${browserAPI.getMsg('error_between')} ${
78-
minVal} ${browserAPI.getMsg('error_and')} ${maxVal}!`)
77+
i18n.getMsg('error_enterValidNum')} ${i18n.getMsg('error_between')} ${
78+
minVal} ${i18n.getMsg('error_and')} ${maxVal}!`)
7979
let validVal = parseInt(userVal.replace(/\D/g, '')) ; if (isNaN(validVal)) return
8080
validVal = Math.max(minVal, Math.min(maxVal, validVal))
8181
entry.slider.value = validVal ; settings.save(entryData.key, validVal)
@@ -117,7 +117,7 @@
117117
entry.leftElem.classList.toggle('on')
118118
settings.save(entryData.key, !config[entryData.key])
119119
sync.configToUI({ updatedKey: entryData.key })
120-
requestAnimationFrame(() => notify(`${entryData.label} ${browserAPI.getMsg(`state_${
120+
requestAnimationFrame(() => notify(`${entryData.label} ${i18n.getMsg(`state_${
121121
settings.typeIsEnabled(entryData.key) ? 'on' : 'off' }`).toUpperCase()}`))
122122
},
123123
link: () => { open(entryData.url) ; close() }
@@ -157,7 +157,7 @@
157157

158158
function notify(msg, pos = !config.toastMode ? 'bottom-right' : undefined) {
159159
if (config.notifDisabled
160-
&& !new RegExp(`${browserAPI.getMsg('menuLabel_show')} ${browserAPI.getMsg('menuLabel_notifs')}`, 'i')
160+
&& !new RegExp(`${i18n.getMsg('menuLabel_show')} ${i18n.getMsg('menuLabel_notifs')}`, 'i')
161161
.test(msg)
162162
) return
163163
sendMsgToActiveTab('notify', { msg, pos })
@@ -240,7 +240,7 @@
240240
Object.entries(elemToLocalize.dataset).forEach(([dataAttr, dataVal]) => {
241241
if (!dataAttr.startsWith('locale')) return
242242
const propToLocalize = dataAttr[6].toLowerCase() + dataAttr.slice(7), // convert to valid DOM prop
243-
localizedTxt = dataVal.split(' ').map(key => browserAPI.getMsg(key) || key).join(' ')
243+
localizedTxt = dataVal.split(' ').map(key => i18n.getMsg(key) || key).join(' ')
244244
elemToLocalize[propToLocalize] = localizedTxt
245245
})
246246
)
@@ -265,8 +265,8 @@
265265
masterToggle.div.onclick = () => {
266266
masterToggle.switch.classList.toggle('on') ; settings.save('extensionDisabled', !config.extensionDisabled)
267267
Object.keys(sync).forEach(key => sync[key]()) // sync fade + storage to UI
268-
notify(`${browserAPI.getMsg('appName')} 🧩 ${
269-
browserAPI.getMsg(`state_${ config.extensionDisabled ? 'off' : 'on' }`).toUpperCase()}`)
268+
notify(`${i18n.getMsg('appName')} 🧩 ${
269+
i18n.getMsg(`state_${ config.extensionDisabled ? 'off' : 'on' }`).toUpperCase()}`)
270270
}
271271

272272
// Create CHILD menu entries on chatgpt.com
@@ -355,7 +355,7 @@
355355
moreExt: { span: footer.querySelector('span[data-locale-title=btnLabel_moreAIextensions]') }
356356
}
357357
footerElems.chatgptjs.logo.parentNode.title = env.browser.displaysEnglish ? ''
358-
: `${browserAPI.getMsg('about_poweredBy')} chatgpt.js` // add localized tooltip to English logo for non-English users
358+
: `${i18n.getMsg('about_poweredBy')} chatgpt.js` // add localized tooltip to English logo for non-English users
359359
footerElems.chatgptjs.logo.src = 'https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@858b952'
360360
+ `/assets/images/badges/powered-by-chatgpt.js/${ env.menu.isDark ? 'white' : 'black' }/with-robot/95x19.png`
361361
footerElems.chatgptjs.logo.onclick = () => { open(app.urls.chatgptjs) ; close() }

chatgpt-auto-continue/eslint.config.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ export default [
1717
languageOptions: {
1818
ecmaVersion: 'latest', sourceType: 'script',
1919
globals: {
20-
...globals.browser, ...globals.greasemonkey, ...globals.node, app: 'writable', browserAPI: 'readonly',
21-
chatgpt: 'readonly', checkBtnsToClick: 'readonly', chrome: 'readonly', config: 'writable',
22-
dom: 'readonly', env: 'writable', feedback: 'readonly', icons: 'writable', modals: 'writable',
23-
settings: 'writable', styles: 'writable', sync: 'readonly', toolbarMenu: 'writable', ui: 'readonly',
24-
updateCheck: 'readonly', xhr: 'writable'
20+
...globals.browser, ...globals.greasemonkey, ...globals.node, app: 'writable', chatgpt: 'readonly',
21+
checkBtnsToClick: 'readonly', chrome: 'readonly', config: 'writable', dom: 'readonly', env: 'writable',
22+
feedback: 'readonly', i18n: 'readonly', icons: 'writable', modals: 'writable', settings: 'writable',
23+
styles: 'writable', sync: 'readonly', toolbarMenu: 'writable', ui: 'readonly', updateCheck: 'readonly',
24+
xhr: 'writable'
2525
}
2626
},
2727
plugins: { 'import': importPlugin, 'js-styles': stylisticJS, regexp },

chatgpt-auto-continue/firefox/extension/components/modals.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ window.modals = {
1111
: 'chromium'
1212
},
1313

14-
about() { // requires lib/browser.js + <app|env>
14+
about() { // requires lib/i18n.js + <app|env>
1515
const { browser: { isPortrait }, ui: { scheme }} = env
1616

1717
// Init buttons
@@ -27,19 +27,19 @@ window.modals = {
2727
const labelStyles = 'text-transform: uppercase ; font-size: 17px ; font-weight: bold ;'
2828
+ `color: ${ scheme == 'dark' ? 'white' : '#494141' }`
2929
const aboutModal = modals.alert(
30-
`${app.symbol} ${browserAPI.getMsg('appName')}`, // title
31-
`<span style="${labelStyles}">🧠 ${browserAPI.getMsg('about_author')}:</span> `
32-
+ `<a href="${app.author.url}">${browserAPI.getMsg('appAuthor')}</a> ${browserAPI.getMsg('about_and')}`
33-
+ ` <a href="${app.urls.contributors}">${browserAPI.getMsg('about_contributors')}</a>\n`
34-
+ `<span style="${labelStyles}">🏷️ ${browserAPI.getMsg('about_version')}:</span> `
30+
`${app.symbol} ${i18n.getMsg('appName')}`, // title
31+
`<span style="${labelStyles}">🧠 ${i18n.getMsg('about_author')}:</span> `
32+
+ `<a href="${app.author.url}">${i18n.getMsg('appAuthor')}</a> ${i18n.getMsg('about_and')}`
33+
+ ` <a href="${app.urls.contributors}">${i18n.getMsg('about_contributors')}</a>\n`
34+
+ `<span style="${labelStyles}">🏷️ ${i18n.getMsg('about_version')}:</span> `
3535
+ `<span class="about-em">${app.version}</span>\n`
36-
+ `<span style="${labelStyles}">📜 ${browserAPI.getMsg('about_openSourceCode')}:</span> `
36+
+ `<span style="${labelStyles}">📜 ${i18n.getMsg('about_openSourceCode')}:</span> `
3737
+ `<a href="${app.urls.github}" target="_blank" rel="nopener">`
3838
+ app.urls.github + '</a>\n'
39-
+ `<span style="${labelStyles}">🚀 ${browserAPI.getMsg('about_latestChanges')}:</span> `
39+
+ `<span style="${labelStyles}">🚀 ${i18n.getMsg('about_latestChanges')}:</span> `
4040
+ `<a href="${app.urls.github}/commits/main/${this.runtime}" target="_blank" rel="nopener">`
4141
+ `${app.urls.github}/commits/main/${this.runtime}</a>\n`
42-
+ `<span style="${labelStyles}">⚡ ${browserAPI.getMsg('about_poweredBy')}:</span> `
42+
+ `<span style="${labelStyles}">⚡ ${i18n.getMsg('about_poweredBy')}:</span> `
4343
+ `<a href="${app.urls.chatgptjs}" target="_blank" rel="noopener">chatgpt.js</a>`,
4444
modalBtns, '', 747
4545
)
@@ -60,20 +60,20 @@ window.modals = {
6060
if (/support|extensions/i.test(btn.textContent)) {
6161
btn.replaceWith(btn = btn.cloneNode(true))
6262
btn.onclick = () => this.safeWinOpen(app.urls[
63-
btn.textContent.includes(browserAPI.getMsg('btnLabel_getSupport')) ? 'support' : 'relatedExtensions' ])
63+
btn.textContent.includes(i18n.getMsg('btnLabel_getSupport')) ? 'support' : 'relatedExtensions' ])
6464
}
6565

6666
// Prepend emoji + localize labels
6767
if (/updates/i.test(btn.textContent))
68-
btn.textContent = `🚀 ${browserAPI.getMsg('btnLabel_checkForUpdates')}`
68+
btn.textContent = `🚀 ${i18n.getMsg('btnLabel_checkForUpdates')}`
6969
else if (/support/i.test(btn.textContent))
70-
btn.textContent = `🧠 ${browserAPI.getMsg('btnLabel_getSupport')}`
70+
btn.textContent = `🧠 ${i18n.getMsg('btnLabel_getSupport')}`
7171
else if (/rate/i.test(btn.textContent))
72-
btn.textContent = `⭐ ${browserAPI.getMsg('btnLabel_rateUs')}`
72+
btn.textContent = `⭐ ${i18n.getMsg('btnLabel_rateUs')}`
7373
else if (/discuss/i.test(btn.textContent))
74-
btn.textContent = `🗨️ ${browserAPI.getMsg('btnLabel_discuss')}`
74+
btn.textContent = `🗨️ ${i18n.getMsg('btnLabel_discuss')}`
7575
else if (/extensions/i.test(btn.textContent))
76-
btn.textContent = `🤖 ${browserAPI.getMsg('btnLabel_moreAIextensions')}`
76+
btn.textContent = `🤖 ${i18n.getMsg('btnLabel_moreAIextensions')}`
7777

7878
// Hide Dismiss button
7979
else btn.style.display = 'none'
@@ -89,7 +89,7 @@ window.modals = {
8989
return alert
9090
},
9191

92-
feedback() { // requires lib/browser.js + app.sourceWebStore
92+
feedback() { // requires lib/i18n.js + app.sourceWebStore
9393

9494
// Init buttons
9595
const modalBtns = [function softonic(){}]
@@ -101,7 +101,7 @@ window.modals = {
101101
)
102102

103103
// Show modal
104-
const feedbackModal = modals.alert(`${browserAPI.getMsg('alert_choosePlatform')}:`, '', modalBtns)
104+
const feedbackModal = modals.alert(`${i18n.getMsg('alert_choosePlatform')}:`, '', modalBtns)
105105
feedbackModal.style.display = 'inline-table' // allow many buttons to fit
106106

107107
// Hack buttons

0 commit comments

Comments
 (0)