beautify bug dialog

This commit is contained in:
qcrao
2024-07-09 15:55:56 +08:00
parent dae72c6e66
commit bbd81750c9
3 changed files with 140 additions and 18 deletions

View File

@@ -91,26 +91,53 @@ async function handleBulkArchive() {
}
});
} else {
if (confirm("一次性付费 0.99 USD购买权限。是否继续")) {
const payResponse = await fetch(
`https://bulk-delete-chatgpt-worker.qcrao.com/pay-bulk-archive?user_id=${encodeURIComponent(
userInfo.id
)}`,
{
method: "POST",
showModal().then(async (result) => {
if (result) {
const payResponse = await fetch(
`https://bulk-delete-chatgpt-worker.qcrao.com/pay-bulk-archive?user_id=${encodeURIComponent(
userInfo.id
)}`,
{ method: "POST" }
);
const payData = await payResponse.json();
console.log("payData", payData);
if (payData.paymentUrl) {
window.open(payData.paymentUrl, "_blank");
} else {
alert("Failed to get payment link. Please try again later.");
}
);
const payData = await payResponse.json();
console.log("payData", payData);
if (payData.paymentUrl) {
window.open(payData.paymentUrl, "_blank");
} else {
alert("获取支付链接失败,请稍后再试。");
}
}
});
}
}
function showModal() {
return new Promise((resolve) => {
const modal = document.getElementById("customModal");
const okButton = document.getElementById("modalOK");
const cancelButton = document.getElementById("modalCancel");
modal.style.display = "block";
okButton.onclick = () => {
modal.style.display = "none";
resolve(true);
};
cancelButton.onclick = () => {
modal.style.display = "none";
resolve(false);
};
window.onclick = (event) => {
if (event.target == modal) {
modal.style.display = "none";
resolve(false);
}
};
});
}
function getUserInfo() {
return new Promise((resolve) => {
chrome.identity.getProfileUserInfo({ accountStatus: "ANY" }, (userInfo) => {