File tree Expand file tree Collapse file tree
chatgpt/autoclear-chatgpt-history Expand file tree Collapse file tree Original file line number Diff line number Diff line change 293293 } ) ) ,
294294 msgs : await new Promise ( resolve => {
295295 const msgBaseURL = `${ app . urls . resourceHost } /greasemonkey/_locales` ,
296- locale = ` ${ env . browser . language ? env . browser . language . replace ( '-' , '_' ) : 'en' } `
297- let msgURL = `${ msgBaseURL } /${ locale } /messages.json` , msgFetchesTried = 0
298- function fetchMsgs ( ) { env . xhr ( { method : 'GET' , url : msgURL , onload : handleMsgs } ) }
296+ locale = env . browser . language ? env . browser . language . replace ( '-' , '_' ) : 'en'
297+ let msgsURL = `${ msgBaseURL } /${ locale } /messages.json` , msgFetchesTried = 0
298+ function fetchMsgs ( ) { env . xhr ( { method : 'GET' , url : msgsURL , onload : handleMsgs } ) }
299299 function handleMsgs ( resp ) {
300300 try { // to return localized messages.json
301301 const msgs = JSON . parse ( resp . responseText ) , flatMsgs = { }
305305 resolve ( flatMsgs )
306306 } catch ( err ) { // if bad response
307307 msgFetchesTried ++ ; if ( msgFetchesTried == 3 ) return resolve ( { } ) // try original/region-stripped/EN
308- msgURL = env . browser . language . includes ( '-' ) && msgFetchesTried == 1 ? // if regional lang on 1st try
309- msgURL . replace ( / ( _ l o c a l e s \/ [ ^ _ ] + ) _ [ ^ _ ] + ( \/ ) / , '$1$2' ) // ...strip region before retrying
308+ msgsURL = env . browser . language . includes ( '-' ) && msgFetchesTried == 1 ? // if regional lang on 1st try
309+ msgsURL . replace ( / ( _ l o c a l e s \/ [ ^ _ ] + ) _ [ ^ _ ] + ( \/ ) / , '$1$2' ) // ...strip region before retrying
310310 : `${ msgBaseURL } /en/messages.json` // else use default English messages
311311 fetchMsgs ( )
312312 }
You can’t perform that action at this time.
0 commit comments