Remove paywall
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
</button>
|
||||
</div>
|
||||
<button id="toggle-checkboxes">Toggle Checkboxes</button>
|
||||
<button id="bulk-archive" data-progress="0"><span id="locked">🔒</span>Bulk Archive</button>
|
||||
<button id="bulk-archive" data-progress="0">Bulk Archive</button>
|
||||
<button id="bulk-delete" data-progress="0">Bulk Delete</button>
|
||||
</div>
|
||||
|
||||
|
||||
126
popup.js
126
popup.js
@@ -90,129 +90,31 @@ function initializeButtons() {
|
||||
bulkArchiveButton.addEventListener("click", handleBulkArchive);
|
||||
}
|
||||
|
||||
const storageKey = "BulkDeleteChatGPT_isPaid";
|
||||
// Payment logic removed - bulk archive is now free
|
||||
async function checkMembershipStatus() {
|
||||
const localIsPaid = localStorage.getItem(storageKey) === "true";
|
||||
|
||||
updateBulkArchiveButton(localIsPaid);
|
||||
|
||||
const userInfo = await getUserInfo();
|
||||
if (!userInfo) {
|
||||
console.error("Unable to get user info");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(
|
||||
`https://bulk-delete-chatgpt-worker.qcrao.com/check-payment-status?user_id=${encodeURIComponent(
|
||||
userInfo.id
|
||||
)}`
|
||||
);
|
||||
const data = await response.json();
|
||||
|
||||
// 更新本地存储和按钮状态
|
||||
localStorage.setItem(storageKey, data.isPaid);
|
||||
updateBulkArchiveButton(data.isPaid);
|
||||
} catch (error) {
|
||||
console.error("Error checking membership status:", error);
|
||||
}
|
||||
// Removed payment checking logic
|
||||
updateBulkArchiveButton(true); // Always enable bulk archive
|
||||
}
|
||||
|
||||
function updateBulkArchiveButton(isPaid) {
|
||||
const bulkArchiveButton = document.getElementById("bulk-archive");
|
||||
if (isPaid) {
|
||||
bulkArchiveButton.querySelector("span").textContent = "";
|
||||
} else {
|
||||
bulkArchiveButton.querySelector("span").textContent = "🔒";
|
||||
}
|
||||
// Always enable bulk archive (no lock icon)
|
||||
bulkArchiveButton.querySelector("span").textContent = "";
|
||||
}
|
||||
|
||||
async function handleBulkArchive() {
|
||||
const localIsPaid = localStorage.getItem(storageKey) === "true";
|
||||
if (localIsPaid) {
|
||||
chrome.tabs.query({ active: true, currentWindow: true }, ([tab]) => {
|
||||
if (tab) {
|
||||
const bulkArchiveButton = document.getElementById("bulk-archive");
|
||||
bulkArchiveButton.disabled = true;
|
||||
bulkArchiveButton.classList.add("progress");
|
||||
loadGlobalsThenExecute(tab.id, "bulkArchiveConversations.js");
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const userInfo = await getUserInfo();
|
||||
if (!userInfo) {
|
||||
console.error("Unable to get user info");
|
||||
alert("Unable to verify user. Please try again later.");
|
||||
return;
|
||||
}
|
||||
|
||||
const response = await fetch(
|
||||
`https://bulk-delete-chatgpt-worker.qcrao.com/check-payment-status?user_id=${encodeURIComponent(
|
||||
userInfo.id
|
||||
)}`
|
||||
);
|
||||
const data = await response.json();
|
||||
|
||||
if (data.isPaid) {
|
||||
chrome.tabs.query({ active: true, currentWindow: true }, ([tab]) => {
|
||||
if (tab) {
|
||||
const bulkArchiveButton = document.getElementById("bulk-archive");
|
||||
bulkArchiveButton.disabled = true;
|
||||
bulkArchiveButton.classList.add("progress");
|
||||
|
||||
loadGlobalsThenExecute(tab.id, "bulkArchiveConversations.js");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
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.");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
};
|
||||
// Removed payment requirements - bulk archive is now free for everyone
|
||||
chrome.tabs.query({ active: true, currentWindow: true }, ([tab]) => {
|
||||
if (tab) {
|
||||
const bulkArchiveButton = document.getElementById("bulk-archive");
|
||||
bulkArchiveButton.disabled = true;
|
||||
bulkArchiveButton.classList.add("progress");
|
||||
loadGlobalsThenExecute(tab.id, "bulkArchiveConversations.js");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// function updateCopyrightYear() {
|
||||
// const currentYear = new Date().getFullYear();
|
||||
// document.getElementById(
|
||||
|
||||
Reference in New Issue
Block a user