mirror of
https://github.com/woodchen-ink/openai-billing-query.git
synced 2025-07-18 05:51:59 +08:00
Merge pull request #25 from woodchen-ink/woodchen-ink/issue24
This commit is contained in:
commit
d418a7be85
23
static/js.js
23
static/js.js
@ -289,30 +289,35 @@ function sendRequest() {
|
|||||||
apiUrl = apiUrlSelect.value;
|
apiUrl = apiUrlSelect.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let apiKeys = parseKeys(apiKeyInput.value);
|
let apiKeys = parseKeys(apiKeyInput.value);
|
||||||
|
|
||||||
if (apiKeys.length === 0) {
|
if (apiKeys.length === 0) {
|
||||||
alert("未匹配到 API-KEY,请检查输入内容");
|
alert("未匹配到 API-KEY,请检查输入内容");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
alert("成功匹配到 API Key,确认后开始查询:" + apiKeys);
|
alert("成功匹配到 API Key,确认后开始查询:" + apiKeys);
|
||||||
|
|
||||||
function parseKeys(input) {
|
function parseKeys(input) {
|
||||||
let lines = input.split(/\n/);
|
let lines = input.split(/\n/);
|
||||||
let result = [];
|
let result = [];
|
||||||
for (let line of lines) {
|
for (let line of lines) {
|
||||||
if (line.includes("sk-") && line.includes("sess-")) {
|
let sessKeyMatch = line.match(/sess-[^-]+/);
|
||||||
let sessKey = line.match(/sess-[^\-]+/)[0];
|
let skKeyMatch = line.match(/sk-[^-]+/);
|
||||||
result.push(sessKey);
|
|
||||||
|
if (sessKeyMatch !== null && skKeyMatch !== null) {
|
||||||
|
result.push(sessKeyMatch[0]);
|
||||||
}
|
}
|
||||||
else if (line.includes("sk-")) {
|
else if (skKeyMatch !== null) {
|
||||||
let skKey = line.match(/sk-[^\-]+/)[0];
|
result.push(skKeyMatch[0]);
|
||||||
result.push(skKey);
|
}
|
||||||
|
else if (sessKeyMatch !== null) {
|
||||||
|
result.push(sessKeyMatch[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let lastQueryPromise = null;
|
let lastQueryPromise = null;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user