add bulk archive
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"name": "ChatGPT Bulk Delete",
|
"name": "ChatGPT Bulk Delete",
|
||||||
"version": "4.6",
|
"version": "5.0",
|
||||||
"description": "A Chrome extension to bulk delete ChatGPT conversations",
|
"description": "A Chrome extension to bulk delete ChatGPT conversations",
|
||||||
"icons": {
|
"icons": {
|
||||||
"48": "icon48.png"
|
"48": "icon48.png"
|
||||||
@@ -11,11 +11,8 @@
|
|||||||
"default_popup": "popup.html",
|
"default_popup": "popup.html",
|
||||||
"default_title": "Bulk Delete Conversations"
|
"default_title": "Bulk Delete Conversations"
|
||||||
},
|
},
|
||||||
"permissions": [
|
"permissions": ["scripting", "activeTab", "identity", "identity.email"],
|
||||||
"scripting",
|
"host_permissions": ["https://bulk-delete-chatgpt-worker.qcrao.com/*"],
|
||||||
"activeTab",
|
|
||||||
"https://bulk-delete-chatgpt-worker.qcrao.com/*"
|
|
||||||
],
|
|
||||||
"content_scripts": [
|
"content_scripts": [
|
||||||
{
|
{
|
||||||
"matches": ["*://chat.openai.com/*"],
|
"matches": ["*://chat.openai.com/*"],
|
||||||
@@ -23,7 +20,7 @@
|
|||||||
"globals.js",
|
"globals.js",
|
||||||
"addCheckboxes.js",
|
"addCheckboxes.js",
|
||||||
"bulkDeleteConversations.js",
|
"bulkDeleteConversations.js",
|
||||||
"deleteConversations.js"
|
"bulkArchiveConversations.js"
|
||||||
],
|
],
|
||||||
"run_at": "document_idle"
|
"run_at": "document_idle"
|
||||||
}
|
}
|
||||||
|
|||||||
107
popup.js
107
popup.js
@@ -28,7 +28,100 @@ function initializeButtons() {
|
|||||||
addButtonListener("bulk-delete", "bulkDeleteConversations.js");
|
addButtonListener("bulk-delete", "bulkDeleteConversations.js");
|
||||||
addButtonListener("toggle-checkboxes", "toggleCheckboxes.js");
|
addButtonListener("toggle-checkboxes", "toggleCheckboxes.js");
|
||||||
addButtonListener("remove-checkboxes", "removeCheckboxes.js");
|
addButtonListener("remove-checkboxes", "removeCheckboxes.js");
|
||||||
addButtonListener("bulk-archive", "bulkArchiveConversations.js");
|
|
||||||
|
const bulkArchiveButton = document.getElementById("bulk-archive");
|
||||||
|
bulkArchiveButton.addEventListener("click", handleBulkArchive);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function checkMembershipStatus() {
|
||||||
|
const userInfo = await getUserInfo();
|
||||||
|
if (!userInfo) {
|
||||||
|
console.error("Unable to get user info");
|
||||||
|
updateBulkArchiveButton(false);
|
||||||
|
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();
|
||||||
|
updateBulkArchiveButton(data.isPaid);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error checking membership status:", error);
|
||||||
|
updateBulkArchiveButton(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateBulkArchiveButton(isPaid) {
|
||||||
|
const bulkArchiveButton = document.getElementById("bulk-archive");
|
||||||
|
if (isPaid) {
|
||||||
|
bulkArchiveButton.classList.remove("locked");
|
||||||
|
bulkArchiveButton.querySelector("span").textContent = "";
|
||||||
|
} else {
|
||||||
|
bulkArchiveButton.classList.add("locked");
|
||||||
|
bulkArchiveButton.querySelector("span").textContent = "🔒";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleBulkArchive() {
|
||||||
|
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) {
|
||||||
|
chrome.scripting.executeScript({
|
||||||
|
target: { tabId: tab.id },
|
||||||
|
files: ["bulkArchiveConversations.js"],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} 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",
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const payData = await payResponse.json();
|
||||||
|
console.log("payData", payData);
|
||||||
|
if (payData.paymentUrl) {
|
||||||
|
window.open(payData.paymentUrl, "_blank");
|
||||||
|
} else {
|
||||||
|
alert("获取支付链接失败,请稍后再试。");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getUserInfo() {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
chrome.identity.getProfileUserInfo({ accountStatus: "ANY" }, (userInfo) => {
|
||||||
|
if (chrome.runtime.lastError) {
|
||||||
|
console.error(chrome.runtime.lastError);
|
||||||
|
resolve(null);
|
||||||
|
} else {
|
||||||
|
resolve(userInfo);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateCopyrightYear() {
|
function updateCopyrightYear() {
|
||||||
@@ -38,5 +131,17 @@ function updateCopyrightYear() {
|
|||||||
).innerHTML = `© ${currentYear} <a href="https://github.com/qcrao/bulk-delete-chatGPT" target="_blank">qcrao@GitHub</a>`;
|
).innerHTML = `© ${currentYear} <a href="https://github.com/qcrao/bulk-delete-chatGPT" target="_blank">qcrao@GitHub</a>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
initializeButtons();
|
initializeButtons();
|
||||||
updateCopyrightYear();
|
updateCopyrightYear();
|
||||||
|
checkMembershipStatus();
|
||||||
|
});
|
||||||
|
|
||||||
|
// 每次打开popup时检查会员状态
|
||||||
|
chrome.runtime.onConnect.addListener(function (port) {
|
||||||
|
if (port.name === "popup") {
|
||||||
|
port.onDisconnect.addListener(function () {
|
||||||
|
checkMembershipStatus();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user