fix chatgpt web mode arkose_token (#469, #543, #545)

This commit is contained in:
josc146
2023-10-30 12:58:04 +08:00
parent 74033b538f
commit 4859e9a905
18 changed files with 127 additions and 22 deletions
+2 -1
View File
@@ -126,5 +126,6 @@
"Exceeded quota": "Überschrittenes Kontingent: Prüfen Sie Ihr Guthaben oder Ablaufdatum unter folgendem Link: https://platform.openai.com/account/usage",
"Rate limit": "Rate-Limit erreicht",
"Jump to bottom": "Zum Ende springen",
"Explain": "Erklären"
"Explain": "Erklären",
"Failed to get arkose token, please keep https://chat.openai.com open": "Arkose-Token konnten nicht abgerufen werden. Bitte halten Sie https://chat.openai.com geöffnet"
}
+2 -1
View File
@@ -126,5 +126,6 @@
"Exceeded quota": "You exceeded your current quota, check https://platform.openai.com/account/usage",
"Rate limit": "Rate limit exceeded",
"Jump to bottom": "Jump to bottom",
"Explain": "Explain"
"Explain": "Explain",
"Failed to get arkose token, please keep https://chat.openai.com open": "Failed to get arkose token, please keep https://chat.openai.com open"
}
+2 -1
View File
@@ -126,5 +126,6 @@
"Exceeded quota": "Cuota superada: Verifique su saldo o fecha de vencimiento en el siguiente enlace: https://platform.openai.com/account/usage",
"Rate limit": "Límite de velocidad alcanzado",
"Jump to bottom": "Saltar al final",
"Explain": "Explicar"
"Explain": "Explicar",
"Failed to get arkose token, please keep https://chat.openai.com open": "No se pudo obtener el token de arkose, por favor mantenga https://chat.openai.com abierto"
}
+2 -1
View File
@@ -126,5 +126,6 @@
"Exceeded quota": "Quota dépassé : Vérifiez votre solde ou la date d'expiration à l'adresse suivante: https://platform.openai.com/account/usage",
"Rate limit": "Limite de taux atteinte",
"Jump to bottom": "Aller en bas",
"Explain": "Expliquer"
"Explain": "Expliquer",
"Failed to get arkose token, please keep https://chat.openai.com open": "Impossible d'obtenir le jeton arkose, veuillez garder https://chat.openai.com ouvert"
}
+2 -1
View File
@@ -126,5 +126,6 @@
"Exceeded quota": "Anda telah melebihi kuota saat ini, periksa https://platform.openai.com/account/usage",
"Rate limit": "Batas penggunaan terlampaui",
"Jump to bottom": "Lompat ke bawah",
"Explain": "Jelaskan"
"Explain": "Jelaskan",
"Failed to get arkose token, please keep https://chat.openai.com open": "Gagal mendapatkan token arkose, harap tetap buka https://chat.openai.com"
}
+2 -1
View File
@@ -126,5 +126,6 @@
"Exceeded quota": "Limite superato o scaduto, controlla questo link: https://platform.openai.com/account/usage",
"Rate limit": "Limite di frequenza delle richieste raggiunto",
"Jump to bottom": "Salta in fondo",
"Explain": "Spiega"
"Explain": "Spiega",
"Failed to get arkose token, please keep https://chat.openai.com open": "Impossibile ottenere il token arkose, per favore mantieni aperto https://chat.openai.com"
}
+2 -1
View File
@@ -126,5 +126,6 @@
"Exceeded quota": "クォータを超過しました。https://platform.openai.com/account/usage で残高を確認してください",
"Rate limit": "レート制限",
"Jump to bottom": "最下部にジャンプ",
"Explain": "説明"
"Explain": "説明",
"Failed to get arkose token, please keep https://chat.openai.com open": "arkoseトークンを取得できませんでした。https://chat.openai.com を開いたままにしてください"
}
+2 -1
View File
@@ -126,5 +126,6 @@
"Exceeded quota": "할당량 초과: https://platform.openai.com/account/usage 링크에서 잔액을 확인하세요.",
"Rate limit": "요청 비율 제한",
"Jump to bottom": "아래로 이동",
"Explain": "설명"
"Explain": "설명",
"Failed to get arkose token, please keep https://chat.openai.com open": "arkose 토큰을 가져오지 못했습니다. https://chat.openai.com 을 열어두세요."
}
+2 -1
View File
@@ -126,5 +126,6 @@
"Exceeded quota": "Cota excedida: Verifique o seu saldo ou a validade em https://platform.openai.com/account/usage.",
"Rate limit": "Limite de taxa atingido",
"Jump to bottom": "Ir para o fundo",
"Explain": "Explicar"
"Explain": "Explicar",
"Failed to get arkose token, please keep https://chat.openai.com open": "Falha ao obter o token arkose, por favor, mantenha https://chat.openai.com aberto"
}
+2 -1
View File
@@ -126,5 +126,6 @@
"Exceeded quota": "Превышено квоту: Проверьте ваш баланс или срок годности по следующей ссылке: https://platform.openai.com/account/usage",
"Rate limit": "Лимит запросов",
"Jump to bottom": "Перейти вниз",
"Explain": "Объяснить"
"Explain": "Объяснить",
"Failed to get arkose token, please keep https://chat.openai.com open": "Не удалось получить токен arkose, пожалуйста, оставьте открытым https://chat.openai.com"
}
+2 -1
View File
@@ -126,5 +126,6 @@
"Exceeded quota": "Mevcut kotanızı aştınız, https://platform.openai.com/account/usage adresini kontrol edin",
"Rate limit": "Hız sınırı aşıldı",
"Jump to bottom": "En alta git",
"Explain": "Açıkla"
"Explain": "Açıkla",
"Failed to get arkose token, please keep https://chat.openai.com open": "Arkose jetonu alınamadı, lütfen https://chat.openai.com adresini açık tutun"
}
+2 -1
View File
@@ -126,5 +126,6 @@
"Exceeded quota": "余额不足或过期, 检查此链接: https://platform.openai.com/account/usage",
"Rate limit": "请求频率过高",
"Jump to bottom": "跳转到底部",
"Explain": "解释"
"Explain": "解释",
"Failed to get arkose token, please keep https://chat.openai.com open": "获取arkose token失败, 请保持 https://chat.openai.com 打开"
}
+2 -1
View File
@@ -126,5 +126,6 @@
"Exceeded quota": "您已超出目前的使用額度,請至 OpenAI Usage 頁面請確認您的方案和帳單詳細資訊: https://platform.openai.com/account/usage",
"Rate limit": "請求太頻繁,超過限制次數",
"Jump to bottom": "轉跳至底部",
"Explain": "解釋"
"Explain": "解釋",
"Failed to get arkose token, please keep https://chat.openai.com open": "無法取得 arkose token,請保持 https://chat.openai.com 開啟"
}
+25 -1
View File
@@ -26,7 +26,6 @@ import {
getUserConfig,
githubThirdPartyApiModelKeys,
gptApiModelKeys,
Models,
poeWebModelKeys,
setUserConfig,
} from '../config/index.mjs'
@@ -230,6 +229,31 @@ Browser.runtime.onMessage.addListener(async (message, sender) => {
}
})
Browser.webRequest.onBeforeRequest.addListener(
(details) => {
if (
details.url.includes('/public_key') &&
!details.url.includes(defaultConfig.chatgptArkoseReqParams)
) {
let formData = new URLSearchParams()
for (const k in details.requestBody.formData) {
formData.append(k, details.requestBody.formData[k])
}
setUserConfig({
chatgptArkoseReqUrl: details.url,
chatgptArkoseReqForm: formData.toString(),
}).then(() => {
console.log('Arkose req url and form saved')
})
}
},
{
urls: ['https://*.openai.com/*'],
types: ['xmlhttprequest'],
},
['requestBody'],
)
Browser.webRequest.onBeforeSendHeaders.addListener(
(details) => {
const headers = details.requestHeaders
+3
View File
@@ -217,11 +217,14 @@ export const defaultConfig = {
bingAccessToken: '',
chatgptJumpBackTabId: 0,
chatgptTabId: 0,
chatgptArkoseReqUrl: '',
chatgptArkoseReqForm: '',
// unchangeable
userLanguage: getNavigatorLanguage(),
apiModes: Object.keys(Models),
chatgptArkoseReqParams: 'cgb=vhwi',
selectionTools: [
'explain',
'translate',
+12
View File
@@ -319,6 +319,18 @@ async function prepareForForegroundRequests() {
render(<NotificationForChatGPTWeb container={div} />, div)
}
if (location.pathname === '/') {
const input = document.querySelector('#prompt-textarea')
if (input) {
input.textContent = ' '
input.dispatchEvent(new Event('input', { bubbles: true }))
setTimeout(() => {
input.textContent = ''
input.dispatchEvent(new Event('input', { bubbles: true }))
}, 300)
}
}
await Browser.runtime.sendMessage({
type: 'SET_CHATGPT_TAB',
data: {},
+44
View File
@@ -20,5 +20,49 @@
"requestDomains": ["sydney.bing.com", "www.bing.com"],
"resourceTypes": ["xmlhttprequest", "websocket"]
}
},
{
"id": 2,
"action": {
"type": "modifyHeaders",
"requestHeaders": [
{
"operation": "set",
"header": "origin",
"value": "https://chat.openai.com"
},
{
"operation": "set",
"header": "referer",
"value": "https://chat.openai.com"
}
]
},
"condition": {
"requestDomains": ["chat.openai.com"],
"resourceTypes": ["xmlhttprequest"]
}
},
{
"id": 3,
"action": {
"type": "modifyHeaders",
"requestHeaders": [
{
"operation": "set",
"header": "origin",
"value": "https://tcr9i.chat.openai.com"
},
{
"operation": "set",
"header": "referer",
"value": "https://tcr9i.chat.openai.com/v2/1.5.5/enforcement.fbfc14b0d793c6ef8359e0e4b4a91f67.html"
}
]
},
"condition": {
"requestDomains": ["tcr9i.chat.openai.com"],
"resourceTypes": ["xmlhttprequest"]
}
}
]
+17 -8
View File
@@ -83,6 +83,22 @@ export async function generateAnswersWithChatgptWebApi(port, question, session,
})
.join('; ')
if (!config.chatgptArkoseReqUrl) throw new Error('Please login at https://chat.openai.com first')
const arkoseToken = await fetch(
config.chatgptArkoseReqUrl + '?' + config.chatgptArkoseReqParams,
{
method: 'POST',
body: config.chatgptArkoseReqForm,
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
},
},
)
.then((resp) => resp.json())
.then((resp) => resp.token)
.catch(() => null)
if (!arkoseToken)
throw new Error('Failed to get arkose token, please keep https://chat.openai.com open')
let answer = ''
await fetchSSE(`${config.customChatGptWebApiUrl}${config.customChatGptWebApiPath}`, {
method: 'POST',
@@ -111,15 +127,8 @@ export async function generateAnswersWithChatgptWebApi(port, question, session,
model: usedModel,
parent_message_id: session.parentMessageId,
timezone_offset_min: new Date().getTimezoneOffset(),
variant_purpose: 'none',
history_and_training_disabled: config.disableWebModeHistory,
arkose_token: usedModel.startsWith('gpt-4')
? `${Array.from({ length: 17 }, () => Math.floor(Math.random() * 16).toString(16)).join(
'',
)}|r=ap-southeast-1|meta=3|meta_width=300|metabgclr=transparent|metaiconclr=%23555555|guitextcolor=%23000000|pk=35536E1E-65B4-4D96-9D97-6ADB7EFF8147|at=40|sup=1|rid=${
Math.floor(Math.random() * 99) + 1
}|ag=101|cdn_url=https%3A%2F%2Ftcr9i.chat.openai.com%2Fcdn%2Ffc|lurl=https%3A%2F%2Faudio-ap-southeast-1.arkoselabs.com|surl=https%3A%2F%2Ftcr9i.chat.openai.com|smurl=https%3A%2F%2Ftcr9i.chat.openai.com%2Fcdn%2Ffc%2Fassets%2Fstyle-manager`
: undefined,
arkose_token: arkoseToken,
}),
onMessage(message) {
console.debug('sse message', message)