mirror of
https://github.com/woodchen-ink/openai-billing-query.git
synced 2025-07-18 05:51:59 +08:00
fix: 添加通过PandoraNext获取sess
This commit is contained in:
parent
6df15c2796
commit
2e90adc476
@ -80,13 +80,12 @@
|
||||
<!-- 下半部分 -->
|
||||
<h4>页面列表</h4>
|
||||
<mdui-menu style="width:100%;margin-top:20px;">
|
||||
<mdui-menu-item icon="search" href="index.html">查API信息</mdui-menu-item>
|
||||
<mdui-menu-item icon="vpn_key" href="get_sess.html">通过access token获取sess</mdui-menu-item>
|
||||
<mdui-menu-item icon="build" href="https://woodchen.ink/1266.html"
|
||||
target="_blank">手动获取sess的方法</mdui-menu-item>
|
||||
<mdui-menu-item icon="account_tree" href="https://github.com/pandora-next/deploy"
|
||||
target="_blank">pandora无痛获取access</mdui-menu-item>
|
||||
</mdui-menu>
|
||||
<mdui-menu-item icon="search" href="index.html">查API信息</mdui-menu-item>
|
||||
<mdui-menu-item icon="vpn_key" href="get_sess.html">通过access token获取sess</mdui-menu-item>
|
||||
<mdui-menu-item icon="vpn_key" href="get_sess2.html">通过PandoraNext获取sess</mdui-menu-item>
|
||||
<mdui-menu-item icon="build" href="https://woodchen.ink/1266.html"
|
||||
target="_blank">手动获取sess的方法</mdui-menu-item>
|
||||
</mdui-menu>
|
||||
|
||||
<div style="margin-top:20px;">
|
||||
<mdui-chip elevated icon="code"> 本网页由<a href="https://woodchen.ink"
|
||||
|
146
get_sess2.html
Normal file
146
get_sess2.html
Normal file
@ -0,0 +1,146 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="mdui-theme-light" lang="zh-cmn-Hans">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>通过PandoraNext来获取Sensitive Id</title>
|
||||
<meta
|
||||
name="description"
|
||||
content="批量快速查询OPENAI的余额,支持可视化展现已用比例、额度、已用量、未用量、是否GPT-4、是否GPT4-32K、是否绑卡、绑卡信息、组织信息、是否有效"
|
||||
/>
|
||||
<link rel="stylesheet" href="./static/css-1.css" type="text/css" />
|
||||
<link rel="stylesheet" href="./static/mdui/mdui.css" />
|
||||
<script src="./static/mdui/mdui.global.js"></script>
|
||||
|
||||
<script>
|
||||
mdui.setColorScheme("#0d2d44");
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<style>
|
||||
th,
|
||||
td {
|
||||
cursor: pointer; /* 添加鼠标指针样式 */
|
||||
white-space: normal; /* 设置为normal使内容自动换行 */
|
||||
word-wrap: break-word; /* 设置为break-word以确保长单词/链接被截断换行 */
|
||||
}
|
||||
/* 复制按钮样式 */
|
||||
.copy-button {
|
||||
height: 36px;
|
||||
cursor: pointer;
|
||||
background-color: #4caf50;
|
||||
color: white;
|
||||
padding: 8px;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
margin: 8px 0;
|
||||
margin-top: 20px;
|
||||
}
|
||||
</style>
|
||||
<mdui-layout>
|
||||
<mdui-layout-main>
|
||||
<div class="mdui-main-container">
|
||||
<div style="display: flex">
|
||||
<h2 style="flex: 1">查询结果</h2>
|
||||
<button class="copy-button" onclick="copyTable()">
|
||||
复制全部内容
|
||||
</button>
|
||||
</div>
|
||||
<div class="mdui-table">
|
||||
<table id="result-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>序号</th>
|
||||
<th>邮箱账户</th>
|
||||
<th>手机号</th>
|
||||
<th>Sensitive ID</th>
|
||||
<th>Refresh Token</th>
|
||||
<th>Access Token</th>
|
||||
<th>Sensitive ID创建时间</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="result-tbody" style="max-width: 100%">
|
||||
<!-- 表格内容 -->
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</mdui-layout-main>
|
||||
|
||||
<mdui-top-app-bar>
|
||||
<mdui-button-icon
|
||||
icon="menu"
|
||||
close-on-overlay-click
|
||||
id="toggle-button"
|
||||
style="color: white"
|
||||
></mdui-button-icon>
|
||||
<mdui-top-app-bar-title style="text-align: center; color: white"
|
||||
>通过PandoraNext来获取Sensitive Id</mdui-top-app-bar-title
|
||||
>
|
||||
</mdui-top-app-bar>
|
||||
|
||||
<mdui-navigation-drawer open class="left-drawer" close-on-overlay-click>
|
||||
<div class="left-drawer-main">
|
||||
<h3>输入 API KEY</h3>
|
||||
<p>本站不保存 KEY 信息,查询后请自行保存</p>
|
||||
<mdui-text-field
|
||||
id="api-key-input"
|
||||
placeholder="请输入账号密码,格式为'账号|密码|MFA验证码',多个请换行"
|
||||
label="username|password|MFA"
|
||||
rows="6"
|
||||
></mdui-text-field>
|
||||
|
||||
<mdui-text-field
|
||||
type="text"
|
||||
id="custom-url-input"
|
||||
placeholder="输入PandoraNext的API地址和前缀"
|
||||
></mdui-text-field>
|
||||
|
||||
<div style="height: 2rem"></div>
|
||||
|
||||
<mdui-button
|
||||
full-width
|
||||
id="query-button"
|
||||
icon="search"
|
||||
onclick="sendRequest()"
|
||||
>
|
||||
查询
|
||||
</mdui-button>
|
||||
|
||||
<!-- 下半部分 -->
|
||||
<h4>页面列表</h4>
|
||||
<mdui-menu style="width: 100%; margin-top: 20px">
|
||||
<mdui-menu-item icon="search" href="index.html"
|
||||
>查API信息</mdui-menu-item
|
||||
>
|
||||
<mdui-menu-item icon="vpn_key" href="get_sess.html"
|
||||
>通过access token获取sess</mdui-menu-item
|
||||
>
|
||||
<mdui-menu-item icon="vpn_key" href="get_sess2.html"
|
||||
>通过PandoraNext获取sess</mdui-menu-item
|
||||
>
|
||||
<mdui-menu-item
|
||||
icon="build"
|
||||
href="https://woodchen.ink/1266.html"
|
||||
target="_blank"
|
||||
>手动获取Sensitive Id的方法</mdui-menu-item
|
||||
>
|
||||
</mdui-menu>
|
||||
|
||||
<div style="margin-top: 20px">
|
||||
<mdui-chip elevated icon="code">
|
||||
本网页由<a href="https://woodchen.ink" target="_blank">woodchen</a
|
||||
>开源于<a
|
||||
href="https://github.com/woodchen-ink/openai-billing-query"
|
||||
target="_blank"
|
||||
>Github</a
|
||||
>
|
||||
</mdui-chip>
|
||||
</div>
|
||||
</div>
|
||||
</mdui-navigation-drawer>
|
||||
</mdui-layout>
|
||||
<script src="./static/getsess2.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -92,10 +92,9 @@
|
||||
<mdui-menu style="width:100%;margin-top:20px;">
|
||||
<mdui-menu-item icon="search" href="index.html">查API信息</mdui-menu-item>
|
||||
<mdui-menu-item icon="vpn_key" href="get_sess.html">通过access token获取sess</mdui-menu-item>
|
||||
<mdui-menu-item icon="vpn_key" href="get_sess2.html">通过PandoraNext获取sess</mdui-menu-item>
|
||||
<mdui-menu-item icon="build" href="https://woodchen.ink/1266.html"
|
||||
target="_blank">手动获取sess的方法</mdui-menu-item>
|
||||
<mdui-menu-item icon="account_tree" href="https://github.com/pandora-next/deploy"
|
||||
target="_blank">pandora无痛获取access</mdui-menu-item>
|
||||
</mdui-menu>
|
||||
|
||||
<div style="margin-top:20px;">
|
||||
|
@ -210,4 +210,15 @@ function hideLoadingAnimation() {
|
||||
// 将原始按钮元素替代回来
|
||||
progressElement.parentElement.replaceChild(button, progressElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let isOpen = true;
|
||||
|
||||
toggleButton.addEventListener("click", () => {
|
||||
isOpen = !isOpen;
|
||||
if (isOpen) {
|
||||
navigationDrawer.open = true;
|
||||
} else {
|
||||
navigationDrawer.open = false;
|
||||
}
|
||||
});
|
222
static/getsess2.js
Normal file
222
static/getsess2.js
Normal file
@ -0,0 +1,222 @@
|
||||
let serialNumber = 1;
|
||||
|
||||
function checkBilling(apiKey, apiUrl) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const headers = {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
};
|
||||
const urlGetsess = `${apiUrl}/api/auth/platform/login`;
|
||||
var urlencoded = new URLSearchParams();
|
||||
for (var i in apiKey) {
|
||||
urlencoded.append(i, apiKey[i]);
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(urlGetsess, {
|
||||
method: "POST", // 设置请求方法为 POST
|
||||
headers: headers,
|
||||
body: urlencoded,
|
||||
redirect: "follow",
|
||||
});
|
||||
|
||||
const getsessdata = await response.json();
|
||||
if (getsessdata && getsessdata.login_info && getsessdata.token_info) {
|
||||
resolve(getsessdata); // 返回getsessdata对象
|
||||
} else {
|
||||
reject(getsessdata);
|
||||
}
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//查询函数
|
||||
async function sendRequest() {
|
||||
let apiKeyInput = document.getElementById("api-key-input");
|
||||
let customUrlInput = document.getElementById("custom-url-input");
|
||||
|
||||
document
|
||||
.getElementById("result-table")
|
||||
.getElementsByTagName("tbody")[0].innerHTML = "";
|
||||
|
||||
let apiUrl = customUrlInput.value.trim();
|
||||
let userList = apiKeyInput.value.split(/[,\s,\n]+/);
|
||||
if (!apiUrl) {
|
||||
mdui.alert({
|
||||
headline: "无查询线路",
|
||||
description: "请输入PandoraNext Api的地址",
|
||||
confirmText: "OK",
|
||||
});
|
||||
return;
|
||||
} else if (!apiUrl.startsWith("http://") && !apiUrl.startsWith("https://")) {
|
||||
apiUrl = "https://" + apiUrl;
|
||||
}
|
||||
|
||||
if (userList.length === 0) {
|
||||
mdui.alert({
|
||||
headline: "请检查输入内容",
|
||||
description: "请填写账户信息",
|
||||
confirmText: "OK",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
let userData = [];
|
||||
for (var i = 0; i < userList.length; i++) {
|
||||
var userInfo = userList[i].split(/\|/);
|
||||
if (userInfo.length > 3 || userInfo.length < 2) {
|
||||
mdui.alert({
|
||||
headline: "请检查输入内容",
|
||||
description: "请按格式输入账户信息",
|
||||
confirmText: "OK",
|
||||
});
|
||||
return;
|
||||
}
|
||||
userData.push({
|
||||
username: userInfo[0],
|
||||
password: userInfo[1],
|
||||
mfa_code: userInfo[2] ? userInfo[2] : "",
|
||||
prompt: "login",
|
||||
});
|
||||
}
|
||||
|
||||
showLoadingAnimation();
|
||||
|
||||
let tableBody = document.querySelector("#result-table tbody");
|
||||
let properties = [
|
||||
"email",
|
||||
"phone_number",
|
||||
"sensitive_id",
|
||||
"refresh_token",
|
||||
"access_token",
|
||||
"created",
|
||||
];
|
||||
for (let i = 0; i < userData.length; i++) {
|
||||
let userInfo = userData[i];
|
||||
let row = document.createElement("tr");
|
||||
let serialNumberCell = document.createElement("td");
|
||||
serialNumberCell.textContent = serialNumber;
|
||||
row.appendChild(serialNumberCell);
|
||||
|
||||
try {
|
||||
let data = await checkBilling(userInfo, apiUrl);
|
||||
let user = data.login_info.user;
|
||||
let session = user.session;
|
||||
let token_info = data.token_info;
|
||||
properties.forEach((prop) => {
|
||||
console.log(prop);
|
||||
let cell = document.createElement("td");
|
||||
if (prop === "created") {
|
||||
cell.textContent = new Date(
|
||||
session["created"] * 1000
|
||||
).toLocaleString();
|
||||
} else if (prop === "sensitive_id") {
|
||||
cell.textContent = session[prop]; // 获取 session 对象中的 sensitive_id
|
||||
cell.onclick = function () {
|
||||
copyCell(cell, `Sensitive ID复制成功`);
|
||||
};
|
||||
} else if (prop === "refresh_token" || prop === "access_token") {
|
||||
cell.textContent = token_info[prop];
|
||||
cell.onclick = function () {
|
||||
copyCell(cell, `${prop === "refresh_token" ? 'Refresh Token' : 'Access Token'}复制成功`);
|
||||
};
|
||||
} else {
|
||||
cell.textContent = user[prop];
|
||||
}
|
||||
row.appendChild(cell);
|
||||
});
|
||||
} catch (error) {
|
||||
let username = document.createElement("td");
|
||||
username.textContent = userInfo.username;
|
||||
row.appendChild(username);
|
||||
let errorMessageCell = document.createElement("td");
|
||||
errorMessageCell.colSpan = "8";
|
||||
errorMessageCell.classList.add("status-error");
|
||||
errorMessageCell.textContent =
|
||||
error && error.detail ? error.detail : error;
|
||||
row.appendChild(errorMessageCell);
|
||||
}
|
||||
|
||||
tableBody.appendChild(row);
|
||||
serialNumber++;
|
||||
}
|
||||
hideLoadingAnimation();
|
||||
}
|
||||
|
||||
function copyCell(cell, message) {
|
||||
// 创建一个新的textarea元素
|
||||
var textarea = document.createElement("textarea");
|
||||
// 设置textarea的值为单元格的文本内容
|
||||
textarea.value = cell.innerText;
|
||||
// 将textarea元素添加到body中
|
||||
document.body.appendChild(textarea);
|
||||
// 选择textarea的文本内容
|
||||
textarea.select();
|
||||
// 执行复制命令
|
||||
document.execCommand("copy");
|
||||
// 移除textarea元素
|
||||
document.body.removeChild(textarea);
|
||||
mdui.alert({
|
||||
headline: "提示",
|
||||
description: message,
|
||||
confirmText: "OK",
|
||||
});
|
||||
}
|
||||
|
||||
function copyTable() {
|
||||
// 这个函数可以保留,以便你仍然可以复制整个表格内容
|
||||
var tableBody = document.getElementById("result-tbody");
|
||||
var textarea = document.createElement("textarea");
|
||||
textarea.value = tableBody.innerText;
|
||||
document.body.appendChild(textarea);
|
||||
textarea.select();
|
||||
document.execCommand("copy");
|
||||
document.body.removeChild(textarea);
|
||||
mdui.alert({
|
||||
headline: "提示",
|
||||
description: "复制成功",
|
||||
confirmText: "OK",
|
||||
});
|
||||
}
|
||||
|
||||
function showLoadingAnimation() {
|
||||
const button = document.getElementById("query-button");
|
||||
|
||||
// 创建一个新的 <mdui-linear-progress> 元素
|
||||
const progressElement = document.createElement("mdui-linear-progress");
|
||||
progressElement.id = "query-progress";
|
||||
|
||||
// 将新元素替代原始按钮元素
|
||||
button.parentElement.replaceChild(progressElement, button);
|
||||
}
|
||||
|
||||
function hideLoadingAnimation() {
|
||||
const progressElement = document.querySelector("mdui-linear-progress");
|
||||
|
||||
if (progressElement) {
|
||||
const button = document.createElement("mdui-button");
|
||||
button.id = "query-button";
|
||||
button.innerHTML = "查询";
|
||||
button.setAttribute("full-width", "");
|
||||
button.setAttribute("icon", "search");
|
||||
button.setAttribute("onclick", "sendRequest()");
|
||||
|
||||
// 将原始按钮元素替代回来
|
||||
progressElement.parentElement.replaceChild(button, progressElement);
|
||||
}
|
||||
}
|
||||
|
||||
const navigationDrawer = document.querySelector(".left-drawer");
|
||||
const toggleButton = document.getElementById("toggle-button");
|
||||
|
||||
let isOpen = true;
|
||||
|
||||
toggleButton.addEventListener("click", () => {
|
||||
isOpen = !isOpen;
|
||||
if (isOpen) {
|
||||
navigationDrawer.open = true;
|
||||
} else {
|
||||
navigationDrawer.open = false;
|
||||
}
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user