Remove paywall
This commit is contained in:
@@ -28,7 +28,7 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<button id="toggle-checkboxes">Toggle Checkboxes</button>
|
<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>
|
<button id="bulk-delete" data-progress="0">Bulk Delete</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
108
popup.js
108
popup.js
@@ -90,46 +90,20 @@ function initializeButtons() {
|
|||||||
bulkArchiveButton.addEventListener("click", handleBulkArchive);
|
bulkArchiveButton.addEventListener("click", handleBulkArchive);
|
||||||
}
|
}
|
||||||
|
|
||||||
const storageKey = "BulkDeleteChatGPT_isPaid";
|
// Payment logic removed - bulk archive is now free
|
||||||
async function checkMembershipStatus() {
|
async function checkMembershipStatus() {
|
||||||
const localIsPaid = localStorage.getItem(storageKey) === "true";
|
// Removed payment checking logic
|
||||||
|
updateBulkArchiveButton(true); // Always enable bulk archive
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateBulkArchiveButton(isPaid) {
|
function updateBulkArchiveButton(isPaid) {
|
||||||
const bulkArchiveButton = document.getElementById("bulk-archive");
|
const bulkArchiveButton = document.getElementById("bulk-archive");
|
||||||
if (isPaid) {
|
// Always enable bulk archive (no lock icon)
|
||||||
bulkArchiveButton.querySelector("span").textContent = "";
|
bulkArchiveButton.querySelector("span").textContent = "";
|
||||||
} else {
|
|
||||||
bulkArchiveButton.querySelector("span").textContent = "🔒";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleBulkArchive() {
|
async function handleBulkArchive() {
|
||||||
const localIsPaid = localStorage.getItem(storageKey) === "true";
|
// Removed payment requirements - bulk archive is now free for everyone
|
||||||
if (localIsPaid) {
|
|
||||||
chrome.tabs.query({ active: true, currentWindow: true }, ([tab]) => {
|
chrome.tabs.query({ active: true, currentWindow: true }, ([tab]) => {
|
||||||
if (tab) {
|
if (tab) {
|
||||||
const bulkArchiveButton = document.getElementById("bulk-archive");
|
const bulkArchiveButton = document.getElementById("bulk-archive");
|
||||||
@@ -138,80 +112,8 @@ async function handleBulkArchive() {
|
|||||||
loadGlobalsThenExecute(tab.id, "bulkArchiveConversations.js");
|
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);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// function updateCopyrightYear() {
|
// function updateCopyrightYear() {
|
||||||
// const currentYear = new Date().getFullYear();
|
// const currentYear = new Date().getFullYear();
|
||||||
|
|||||||
Reference in New Issue
Block a user