Skip to content

Commit 179a912

Browse files
committed
Condensed locale init, renamed msgURL to msgsURL ↞ [auto-sync from https://github.com/adamlui/ai-web-extensions/tree/main/amazongpt]
1 parent 8e38f40 commit 179a912

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

chatgpt/amazongpt/amazongpt.user.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// @description Add AI chat & product/category summaries to Amazon shopping, powered by the latest LLMs like GPT-4o!
44
// @author KudoAI
55
// @namespace https://kudoai.com
6-
// @version 2026.7.26.1
6+
// @version 2026.7.26.2
77
// @license MIT
88
// @icon https://cdn.jsdelivr.net/gh/KudoAI/amazongpt@8e8ed1c/assets/images/icons/app/black-gold-teal/icon48.png
99
// @icon64 https://cdn.jsdelivr.net/gh/KudoAI/amazongpt@8e8ed1c/assets/images/icons/app/black-gold-teal/icon64.png
@@ -154,9 +154,9 @@
154154
})),
155155
msgs: await new Promise(resolve => {
156156
const msgBaseURL = `${app.urls.resourceHost}/greasemonkey/_locales`,
157-
locale = `${ env.browser.language ? env.browser.language.replace('-', '_') : 'en' }`
158-
let msgURL = `${msgBaseURL}/${locale}/messages.json`, msgFetchesTried = 0
159-
function fetchMsgs() { env.xhr({ method: 'GET', url: msgURL, onload: handleMsgs })}
157+
locale = env.browser.language ? env.browser.language.replace('-', '_') : 'en'
158+
let msgsURL = `${msgBaseURL}/${locale}/messages.json`, msgFetchesTried = 0
159+
function fetchMsgs() { env.xhr({ method: 'GET', url: msgsURL, onload: handleMsgs })}
160160
function handleMsgs(resp) {
161161
try { // to return localized messages.json
162162
const msgs = JSON.parse(resp.responseText), flatMsgs = {}
@@ -166,8 +166,8 @@
166166
resolve(flatMsgs)
167167
} catch (err) { // if bad response
168168
msgFetchesTried++ ; if (msgFetchesTried == 3) return resolve({}) // try original/region-stripped/EN
169-
msgURL = env.browser.language.includes('-') && msgFetchesTried == 1 ? // if regional lang on 1st try
170-
msgURL.replace(/(_locales\/[^_]+)_[^_]+(\/)/, '$1$2') // ...strip region before retrying
169+
msgsURL = env.browser.language.includes('-') && msgFetchesTried == 1 ? // if regional lang on 1st try
170+
msgsURL.replace(/(_locales\/[^_]+)_[^_]+(\/)/, '$1$2') // ...strip region before retrying
171171
: `${msgBaseURL}/en/messages.json` // else use default English messages
172172
fetchMsgs()
173173
}

0 commit comments

Comments
 (0)