File tree Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -100,18 +100,21 @@ async function getInput(inputQuery) {
100
100
}
101
101
102
102
async function overwriteAccessToken ( ) {
103
- if ( location . hostname !== 'chat.openai.com' || location . pathname !== '/api/auth/session' ) return
104
-
105
- const response = document . querySelector ( 'pre' ) . textContent
103
+ if ( location . hostname !== 'chat.openai.com' ) return
106
104
107
105
let data
108
- try {
109
- data = JSON . parse ( response )
110
- } catch ( error ) {
111
- console . error ( 'json error' , error )
112
- return
106
+ if ( location . pathname === '/api/auth/session' ) {
107
+ const response = document . querySelector ( 'pre' ) . textContent
108
+ try {
109
+ data = JSON . parse ( response )
110
+ } catch ( error ) {
111
+ console . error ( 'json error' , error )
112
+ }
113
+ } else {
114
+ const resp = await fetch ( 'https://chat.openai.com/api/auth/session' )
115
+ data = await resp . json ( ) . catch ( ( ) => ( { } ) )
113
116
}
114
- if ( data . accessToken ) {
117
+ if ( data && data . accessToken ) {
115
118
await setAccessToken ( data . accessToken )
116
119
console . log ( data . accessToken )
117
120
}
You can’t perform that action at this time.
0 commit comments