Skip to content

Commit

Permalink
Updated apis[api].expectedOrigin.headers, abstracted majority ones …
Browse files Browse the repository at this point in the history
…to `createHeaders()` ↞ [auto-sync from https://github.com/adamlui/ai-web-extensionss/tree/main/bravegpt]
  • Loading branch information
kudo-sync-bot committed Jan 14, 2025
1 parent 2f5546b commit 2b8d8a3
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions chatgpt/bravegpt/bravegpt.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
// @description:zu Yengeza izimpendulo ze-AI ku-Brave Search (inikwa amandla yi-GPT-4o!)
// @author KudoAI
// @namespace https://kudoai.com
// @version 2025.1.14
// @version 2025.1.14.1
// @license MIT
// @icon https://assets.bravegpt.com/images/icons/bravegpt/icon48.png?v=df624b0
// @icon64 https://assets.bravegpt.com/images/icons/bravegpt/icon64.png?v=df624b0
Expand Down Expand Up @@ -577,10 +577,7 @@
endpoint: 'https://am.aifree.site/api/generate',
expectedOrigin: {
url: 'https://am.aifree.site',
headers: {
'Accept': '*/*', 'Alt-Used': 'am.aifree.site', 'Content-Type': 'text/plain;charset=UTF-8',
'Priority': 'u=4', 'Sec-Fetch-Site': 'same-origin'
}
headers: { 'Alt-Used': 'am.aifree.site', 'Content-Type': 'text/plain;charset=UTF-8', 'Priority': 'u=4' }
},
method: 'POST', streamable: true
},
Expand All @@ -589,7 +586,8 @@
expectedOrigin: {
url: 'https://ai28.gptforlove.com',
headers: {
'Accept': 'application/json, text/plain, */*', 'Priority': 'u=0', 'Sec-Fetch-Site': 'same-site'
'Accept': 'application/json, text/plain, */*',
'Priority': 'u=0', 'Sec-Fetch-Site': 'same-site', 'TE': 'trailers'
}
},
method: 'POST', streamable: true, accumulatesText: true,
Expand All @@ -598,9 +596,7 @@
'MixerBox AI': {
endpoint: 'https://chatai.mixerbox.com/api/chat/stream',
expectedOrigin: {
url: 'https://chatai.mixerbox.com',
headers: { 'Accept': '*/*', 'Alt-Used': 'chatai.mixerbox.com', 'Sec-Fetch-Site': 'same-origin' }
},
url: 'https://chatai.mixerbox.com', headers: { 'Alt-Used': 'chatai.mixerbox.com', 'TE': 'trailers' }},
method: 'POST', streamable: true, accumulatesText: false
},
'OpenAI': {
Expand All @@ -609,10 +605,7 @@
completions: 'https://api.openai.com/v1/chat/completions',
session: 'https://chatgpt.com/api/auth/session'
},
expectedOrigin: {
url: 'https://chatgpt.com',
headers: { 'Accept': '*/*', 'Priority': 'u=4', 'Sec-Fetch-Site': 'same-site' }
},
expectedOrigin: { url: 'https://chatgpt.com', headers: { 'Priority': 'u=4' }},
method: 'POST', streamable: true
}
}
Expand Down Expand Up @@ -3151,6 +3144,7 @@
} catch (err) { return false }
}
}

// Define API functions

const api = {
Expand All @@ -3163,12 +3157,11 @@
createHeaders(api) {
const ip = ipv4.generate({ verbose: false })
const headers = {
'Accept-Encoding': 'gzip, deflate, br, zstd',
'Accept': '*/*', 'Accept-Encoding': 'gzip, deflate, br, zstd',
'Connection': 'keep-alive', 'Content-Type': 'application/json', 'DNT': '1',
'Host': new URL(apis[api].endpoints?.completions || apis[api].endpoint).hostname,
'Origin': apis[api].expectedOrigin.url,
'Sec-Fetch-Dest': 'empty', 'Sec-Fetch-Mode': 'cors',
'TE': 'trailers', 'X-Forwarded-For': ip, 'X-Real-IP': ip
'Origin': apis[api].expectedOrigin.url, 'Sec-Fetch-Site': 'same-origin',
'Sec-Fetch-Dest': 'empty', 'Sec-Fetch-Mode': 'cors', 'X-Forwarded-For': ip, 'X-Real-IP': ip
}
headers.Referer = headers.Origin + '/'
if (api == 'OpenAI') headers.Authorization = 'Bearer ' + config.openAIkey
Expand Down

0 comments on commit 2b8d8a3

Please sign in to comment.