From 2e90adc4765354b03c7a1d66b813986a054cfd8b Mon Sep 17 00:00:00 2001 From: Johnathan Abts Date: Fri, 29 Dec 2023 13:41:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0=E9=80=9A=E8=BF=87Pand?= =?UTF-8?q?oraNext=E8=8E=B7=E5=8F=96sess?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- get_sess.html | 13 ++- get_sess2.html | 146 +++++++++++++++++++++++++++++ index.html | 3 +- static/getsess.js | 13 ++- static/getsess2.js | 222 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 387 insertions(+), 10 deletions(-) create mode 100644 get_sess2.html create mode 100644 static/getsess2.js diff --git a/get_sess.html b/get_sess.html index 5e80fea..d91d0e4 100644 --- a/get_sess.html +++ b/get_sess.html @@ -80,13 +80,12 @@

页面列表

- 查API信息 - 通过access token获取sess - 手动获取sess的方法 - pandora无痛获取access - + 查API信息 + 通过access token获取sess + 通过PandoraNext获取sess + 手动获取sess的方法 +
本网页由 + + + + + 通过PandoraNext来获取Sensitive Id + + + + + + + + + + + + +
+
+

查询结果

+ +
+
+ + + + + + + + + + + + + + + +
序号邮箱账户手机号Sensitive IDRefresh TokenAccess TokenSensitive ID创建时间
+
+
+
+ + + + 通过PandoraNext来获取Sensitive Id + + + +
+ + + + + diff --git a/index.html b/index.html index a42500a..caaec1b 100644 --- a/index.html +++ b/index.html @@ -92,10 +92,9 @@ 查API信息 通过access token获取sess + 通过PandoraNext获取sess 手动获取sess的方法 - pandora无痛获取access
diff --git a/static/getsess.js b/static/getsess.js index a759896..eee1bcf 100644 --- a/static/getsess.js +++ b/static/getsess.js @@ -210,4 +210,15 @@ function hideLoadingAnimation() { // 将原始按钮元素替代回来 progressElement.parentElement.replaceChild(button, progressElement); } -} \ No newline at end of file +} + +let isOpen = true; + +toggleButton.addEventListener("click", () => { + isOpen = !isOpen; + if (isOpen) { + navigationDrawer.open = true; + } else { + navigationDrawer.open = false; + } +}); \ No newline at end of file diff --git a/static/getsess2.js b/static/getsess2.js new file mode 100644 index 0000000..7ccb117 --- /dev/null +++ b/static/getsess2.js @@ -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"); + + // 创建一个新的 元素 + 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; + } +});