myesn

myEsn2E9

hi
github

OpenAI Translator 使用指南

  1. 下載 openai-translator 並雙擊安裝
  2. 根據文件安裝 SnipDo,通過 Microsoft Store 下載應用時記得關閉代理軟件
  3. 打開代理軟件,選中美國 IP 的代理
  4. 打開 OpenAI API keys 頁面創建一個 API key(把別人的都刪光光哈哈哈),從獨角獸每日分享或其他平台獲取免費的 ChatGPT 帳號進行登錄
  5. 將創建的 API key 填入 OpenAI Translator 中

刪光腳本(運行於 F12 > Console):
不好意思,實在是不好意思,因為每個帳號免費的額度太少了

// !!首次運行前需要設置 Authorization、apiKeySentitiveId 兩個參數
const authorizationHeader = {
  Authorization: "Bearer sess-p70aSrrGmA5ZrlDCSFTlvmZoogv2Sjbx7OiYJgP6",
};
let apiKeySentitiveId = "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";

const apiKeyName = "this-account-belongs-me";
const interval = 5000;

async function bootstrap() {
  console.log("流程開啟");

  const apiKeys = await retrieveApiKeys();
  // 刪除所有 apiKeyName 不匹配的
  const otherApiKeys = apiKeys.filter((x) => x.name !== apiKeyName);

  for (const otherApiKey of otherApiKeys) {
    await deleteApiKey(otherApiKey.sensitive_id, otherApiKey.created);
  }
  console.log("無關數據刪除完畢");

  const apiKey = apiKeys.find((x) => x.name === apiKeyName);

  if (!apiKey) {
    console.log(`找不到 ${apiKeyName},正在自動創建`);
    await createApiKey(apiKeyName);
    console.warn(`自動創建 API Key 成功,請手動複製然後重新設置翻譯軟件:`);
    console.log(apiKeySentitiveId);
  } else {    
    console.log(`API Key 已存在,不需要重新創建:`);
    console.log(apiKeySentitiveId);
  }

  console.log(`流程開啟,${interval} 毫秒後會再次執行`);

  setTimeout(bootstrap, interval);
}
bootstrap();

async function retrieveApiKeys() {
  var apiKeysResponse = await fetch(
    "https://api.openai.com/dashboard/user/api_keys",
    {
      headers: {
        ...authorizationHeader,
      },
    }
  );
  var apiKeys = (await apiKeysResponse.json()).data;
  return apiKeys;
}

async function createApiKey(name) {
  var deleteApiKeyResponse = await fetch(
    "https://api.openai.com/dashboard/user/api_keys",
    {
      method: "POST",
      headers: {
        ...authorizationHeader,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        action: "create",
        name,
      }),
    }
  );

  const content = await deleteApiKeyResponse.json();
  const isSuccess = content.result === "success";

  if (isSuccess) {
    // 保存最新的 key
    apiKeySentitiveId = content.key.sensitive_id;
  }

  return isSuccess;
}

async function deleteApiKey(redacted_key, created_at) {
  var deleteApiKeyResponse = await fetch(
    "https://api.openai.com/dashboard/user/api_keys",
    {
      method: "POST",
      headers: {
        ...authorizationHeader,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        action: "delete",
        redacted_key: redacted_key,
        created_at: created_at,
      }),
    }
  );

  const content = await deleteApiKeyResponse.json();
  return content.result === "success";
}
載入中......
此文章數據所有權由區塊鏈加密技術和智能合約保障僅歸創作者所有。