|
3 | 3 | // @description Add AI chat & product/category summaries to Amazon shopping, powered by the latest LLMs like GPT-4o! |
4 | 4 | // @author KudoAI |
5 | 5 | // @namespace https://kudoai.com |
6 | | -// @version 2026.7.26.1 |
| 6 | +// @version 2026.7.26.2 |
7 | 7 | // @license MIT |
8 | 8 | // @icon https://cdn.jsdelivr.net/gh/KudoAI/amazongpt@8e8ed1c/assets/images/icons/app/black-gold-teal/icon48.png |
9 | 9 | // @icon64 https://cdn.jsdelivr.net/gh/KudoAI/amazongpt@8e8ed1c/assets/images/icons/app/black-gold-teal/icon64.png |
|
154 | 154 | })), |
155 | 155 | msgs: await new Promise(resolve => { |
156 | 156 | 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 })} |
160 | 160 | function handleMsgs(resp) { |
161 | 161 | try { // to return localized messages.json |
162 | 162 | const msgs = JSON.parse(resp.responseText), flatMsgs = {} |
|
166 | 166 | resolve(flatMsgs) |
167 | 167 | } catch (err) { // if bad response |
168 | 168 | 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 |
171 | 171 | : `${msgBaseURL}/en/messages.json` // else use default English messages |
172 | 172 | fetchMsgs() |
173 | 173 | } |
|
0 commit comments