diff --git a/src/_locales/de/main.json b/src/_locales/de/main.json index 450f97e8..9e5df2a5 100644 --- a/src/_locales/de/main.json +++ b/src/_locales/de/main.json @@ -8,7 +8,6 @@ "Theme": "Thema", "API Mode": "API-Modus", "Get": "Erhalten", - "Balance": "Kontostand", "Preferred Language": "Bevorzugte Sprache", "Insert ChatGPT at the top of search results": "ChatGPT am Anfang der Suchergebnisse einfügen", "Lock scrollbar while answering": "Bildlaufleiste beim Beantworten sperren", diff --git a/src/_locales/en/main.json b/src/_locales/en/main.json index 174f99af..44981fbc 100644 --- a/src/_locales/en/main.json +++ b/src/_locales/en/main.json @@ -8,7 +8,6 @@ "Theme": "Theme", "API Mode": "API Mode", "Get": "Get", - "Balance": "Balance", "Preferred Language": "Preferred Language", "Insert ChatGPT at the top of search results": "Insert ChatGPT at the top of search results", "Lock scrollbar while answering": "Lock scrollbar while answering", diff --git a/src/_locales/es/main.json b/src/_locales/es/main.json index df4c8a4a..f4452535 100644 --- a/src/_locales/es/main.json +++ b/src/_locales/es/main.json @@ -8,7 +8,6 @@ "Theme": "Tema", "API Mode": "Modo API", "Get": "Obtener", - "Balance": "Balance", "Preferred Language": "Idioma preferido", "Insert ChatGPT at the top of search results": "Insertar ChatGPT en la parte superior de los resultados de búsqueda", "Lock scrollbar while answering": "Bloquear barra de desplazamiento mientras se responde", diff --git a/src/_locales/fr/main.json b/src/_locales/fr/main.json index c8e76ca4..7fbc4ecb 100644 --- a/src/_locales/fr/main.json +++ b/src/_locales/fr/main.json @@ -8,7 +8,6 @@ "Theme": "Thème", "API Mode": "Mode API", "Get": "Obtenir", - "Balance": "Solde", "Preferred Language": "Langue préférée", "Insert ChatGPT at the top of search results": "Insérer ChatGPT en haut des résultats de recherche", "Lock scrollbar while answering": "Verrouiller la barre de défilement pendant la réponse", diff --git a/src/_locales/in/main.json b/src/_locales/in/main.json index 064372ff..69bc49bd 100644 --- a/src/_locales/in/main.json +++ b/src/_locales/in/main.json @@ -8,7 +8,6 @@ "Theme": "Tema", "API Mode": "Mode API", "Get": "Dapatkan", - "Balance": "Saldo", "Preferred Language": "Bahasa yang Dipilih", "Insert ChatGPT at the top of search results": "Masukkan ChatGPT di bagian atas hasil pencarian", "Lock scrollbar while answering": "Kunci scrollbar saat menjawab", diff --git a/src/_locales/it/main.json b/src/_locales/it/main.json index 87c9e46c..1b81c251 100644 --- a/src/_locales/it/main.json +++ b/src/_locales/it/main.json @@ -8,7 +8,6 @@ "Theme": "Tema", "API Mode": "Modalità API", "Get": "Ottenere", - "Balance": "Saldo", "Preferred Language": "Lingua preferita", "Insert ChatGPT at the top of search results": "Inserisci ChatGPT in cima ai risultati di ricerca", "Lock scrollbar while answering": "Blocca la barra di scorrimento durante la risposta", diff --git a/src/_locales/ja/main.json b/src/_locales/ja/main.json index 4f6ebf80..92d6c62f 100644 --- a/src/_locales/ja/main.json +++ b/src/_locales/ja/main.json @@ -8,7 +8,6 @@ "Theme": "テーマ", "API Mode": "APIモード", "Get": "取得", - "Balance": "残高", "Preferred Language": "言語設定", "Insert ChatGPT at the top of search results": "検索結果のトップにチャットGPTを挿入", "Lock scrollbar while answering": "回答中にスクロールバーをロック", diff --git a/src/_locales/ko/main.json b/src/_locales/ko/main.json index 92fe01a2..3f01a2d6 100644 --- a/src/_locales/ko/main.json +++ b/src/_locales/ko/main.json @@ -8,7 +8,6 @@ "Theme": "테마", "API Mode": "API 모드", "Get": "받다", - "Balance": "잔액", "Preferred Language": "선호하는 언어", "Insert ChatGPT at the top of search results": "검색 결과 상단에 ChatGPT 삽입", "Lock scrollbar while answering": "답변 중 스크롤바 잠금", diff --git a/src/_locales/pt/main.json b/src/_locales/pt/main.json index 1cb7ef46..3cfc8427 100644 --- a/src/_locales/pt/main.json +++ b/src/_locales/pt/main.json @@ -8,7 +8,6 @@ "Theme": "Tema", "API Mode": "Modo API", "Get": "Obter", - "Balance": "Saldo", "Preferred Language": "Idioma Preferido", "Insert ChatGPT at the top of search results": "Inserir ChatGPT no topo dos resultados de pesquisa", "Lock scrollbar while answering": "Bloquear barra de rolagem ao responder", diff --git a/src/_locales/ru/main.json b/src/_locales/ru/main.json index 08b701e3..6e0ff84f 100644 --- a/src/_locales/ru/main.json +++ b/src/_locales/ru/main.json @@ -8,7 +8,6 @@ "Theme": "Тема", "API Mode": "Режим API", "Get": "Получить", - "Balance": "Баланс", "Preferred Language": "Предпочитаемый язык", "Insert ChatGPT at the top of search results": "Вставить ChatGPT в верхней части результатов поиска", "Lock scrollbar while answering": "Начало блокировки прокрутки во время ответа", diff --git a/src/_locales/tr/main.json b/src/_locales/tr/main.json index 7ecad89d..99e1b364 100644 --- a/src/_locales/tr/main.json +++ b/src/_locales/tr/main.json @@ -8,7 +8,6 @@ "Theme": "Tema", "API Mode": "API Modu", "Get": "Al", - "Balance": "Bakiye", "Preferred Language": "Tercih Edilen Dil", "Insert ChatGPT at the top of search results": "ChatGPT'yi arama sonuçlarının en üstüne ekle", "Lock scrollbar while answering": "Cevap verirken kaydırma çubuğunu kilitle", diff --git a/src/_locales/zh-hans/main.json b/src/_locales/zh-hans/main.json index 80d06c85..fd3263fb 100644 --- a/src/_locales/zh-hans/main.json +++ b/src/_locales/zh-hans/main.json @@ -8,7 +8,6 @@ "Theme": "主题", "API Mode": "API模式", "Get": "获取", - "Balance": "余额", "Preferred Language": "语言偏好", "Insert ChatGPT at the top of search results": "将对话卡片插入到搜索结果顶部", "Lock scrollbar while answering": "回答时锁定滚动条", diff --git a/src/_locales/zh-hant/main.json b/src/_locales/zh-hant/main.json index e8edea88..87b41242 100644 --- a/src/_locales/zh-hant/main.json +++ b/src/_locales/zh-hant/main.json @@ -8,7 +8,6 @@ "Theme": "主題", "API Mode": "API 模式", "Get": "取得", - "Balance": "餘額", "Preferred Language": "偏好語言", "Insert ChatGPT at the top of search results": "在搜尋結果頂端插入 ChatGPT 對話卡片", "Lock scrollbar while answering": "回答時鎖定捲軸", diff --git a/src/popup/sections/GeneralPart.jsx b/src/popup/sections/GeneralPart.jsx index 9af6e542..30e6c20a 100644 --- a/src/popup/sections/GeneralPart.jsx +++ b/src/popup/sections/GeneralPart.jsx @@ -2,7 +2,6 @@ import { useTranslation } from 'react-i18next' import { useLayoutEffect, useState } from 'react' import FileSaver from 'file-saver' import { - openUrl, modelNameToDesc, isApiModeSelected, getApiModesFromConfig, @@ -38,66 +37,12 @@ GeneralPart.propTypes = { setTabIndex: PropTypes.func.isRequired, } -function formatDate(date) { - const year = date.getFullYear() - const month = (date.getMonth() + 1).toString().padStart(2, '0') - const day = date.getDate().toString().padStart(2, '0') - - return `${year}-${month}-${day}` -} - -async function checkBilling(apiKey, apiUrl) { - const now = new Date() - let startDate = new Date(now - 90 * 24 * 60 * 60 * 1000) - const endDate = new Date(now.getTime() + 24 * 60 * 60 * 1000) - const subDate = new Date(now) - subDate.setDate(1) - - const urlSubscription = `${apiUrl}/v1/dashboard/billing/subscription` - let urlUsage = `${apiUrl}/v1/dashboard/billing/usage?start_date=${formatDate( - startDate, - )}&end_date=${formatDate(endDate)}` - const headers = { - Authorization: 'Bearer ' + apiKey, - 'Content-Type': 'application/json', - } - - try { - let response = await fetch(urlSubscription, { headers }) - if (!response.ok) { - console.log('Your account has been suspended. Please log in to OpenAI to check.') - return [null, null, null] - } - const subscriptionData = await response.json() - const totalAmount = subscriptionData.hard_limit_usd - - if (totalAmount > 20) { - startDate = subDate - } - - urlUsage = `${apiUrl}/v1/dashboard/billing/usage?start_date=${formatDate( - startDate, - )}&end_date=${formatDate(endDate)}` - - response = await fetch(urlUsage, { headers }) - const usageData = await response.json() - const totalUsage = usageData.total_usage / 100 - const remaining = totalAmount - totalUsage - - return [totalAmount, totalUsage, remaining] - } catch (error) { - console.error(error) - return [null, null, null] - } -} - function isUsingSpecialCustomModel(configOrSession) { return isUsingCustomModel(configOrSession) && !configOrSession.apiMode } export function GeneralPart({ config, updateConfig, setTabIndex }) { const { t, i18n } = useTranslation() - const [balance, setBalance] = useState(null) const [apiModes, setApiModes] = useState([]) useLayoutEffect(() => { @@ -109,21 +54,6 @@ export function GeneralPart({ config, updateConfig, setTabIndex }) { config.ollamaModelName, ]) - const getBalance = async () => { - const response = await fetch(`${config.customOpenAiApiUrl}/dashboard/billing/credit_grants`, { - headers: { - 'Content-Type': 'application/json', - Authorization: `Bearer ${config.apiKey}`, - }, - }) - if (response.ok) setBalance((await response.json()).total_available.toFixed(2)) - else { - const billing = await checkBilling(config.apiKey, config.customOpenAiApiUrl) - if (billing && billing.length > 2 && billing[2]) setBalance(`${billing[2].toFixed(2)}`) - else openUrl('https://platform.openai.com/account/usage') - } - } - return ( <>