fix: do not work after openai updates
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -13,3 +13,4 @@
|
|||||||
|
|
||||||
# Dependency directories (remove the comment below to include it)
|
# Dependency directories (remove the comment below to include it)
|
||||||
# vendor/
|
# vendor/
|
||||||
|
.DS_Store
|
||||||
@@ -1,21 +1,32 @@
|
|||||||
function addCheckboxes() {
|
function addCheckboxes() {
|
||||||
const conversations = document.querySelectorAll(
|
const conversations = document.querySelectorAll('.flex.py-3.px-3.items-center.gap-3.relative.rounded-md');
|
||||||
'.flex.py-3.px-3.items-center.gap-3.relative.rounded-md'
|
|
||||||
);
|
|
||||||
|
|
||||||
conversations.forEach((conversation, index) => {
|
conversations.forEach((conversation, index) => {
|
||||||
const existingCheckbox = conversation.querySelector('.conversation-checkbox');
|
|
||||||
if (!existingCheckbox) {
|
|
||||||
const checkbox = document.createElement('input');
|
const checkbox = document.createElement('input');
|
||||||
checkbox.type = 'checkbox';
|
checkbox.type = 'checkbox';
|
||||||
checkbox.className = 'conversation-checkbox';
|
checkbox.className = 'conversation-checkbox';
|
||||||
checkbox.dataset.index = index; // 设置 data-index 属性
|
checkbox.dataset.index = index;
|
||||||
checkbox.addEventListener('click', (e) => {
|
|
||||||
e.stopPropagation();
|
conversation.insertAdjacentElement('afterbegin', checkbox);
|
||||||
|
|
||||||
|
// Add click event listener to the conversation title
|
||||||
|
const titleElement = conversation.querySelector('.flex-1.text-ellipsis.max-h-5.overflow-hidden.break-all.relative');
|
||||||
|
if (titleElement) {
|
||||||
|
titleElement.style.cursor = 'default'; // Ensure the cursor is the default arrow pointer
|
||||||
|
titleElement.addEventListener('click', function(event) {
|
||||||
|
// Toggle the checkbox state
|
||||||
|
checkbox.checked = !checkbox.checked;
|
||||||
|
// Prevent the event from propagating further
|
||||||
|
event.stopPropagation();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Ensure the checkbox click doesn't trigger the title's click event
|
||||||
|
checkbox.addEventListener('click', function(event) {
|
||||||
|
event.stopPropagation();
|
||||||
});
|
});
|
||||||
conversation.insertBefore(checkbox, conversation.firstChild);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addCheckboxes();
|
||||||
|
|
||||||
addCheckboxes();
|
|
||||||
|
|||||||
@@ -13,39 +13,16 @@ async function bulkDeleteConversations() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const waitForElement = (selector, timeout = 5000) => {
|
async function waitForElement(selector, timeout = 5000) {
|
||||||
return new Promise((resolve, reject) => {
|
const startedAt = Date.now();
|
||||||
const element = document.querySelector(selector);
|
let el = null;
|
||||||
if (element) {
|
while ((Date.now() - startedAt) < timeout) {
|
||||||
resolve(element);
|
el = document.querySelector(selector);
|
||||||
|
if (el) return el;
|
||||||
|
await new Promise(r => setTimeout(r, 100));
|
||||||
}
|
}
|
||||||
|
throw new Error(`Element ${selector} not found within ${timeout}ms`);
|
||||||
const observer = new MutationObserver((mutations) => {
|
}
|
||||||
mutations.forEach((mutation) => {
|
|
||||||
if (!mutation.addedNodes) return;
|
|
||||||
|
|
||||||
for (const node of mutation.addedNodes) {
|
|
||||||
if (node.matches && node.matches(selector)) {
|
|
||||||
observer.disconnect();
|
|
||||||
resolve(node);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
observer.disconnect();
|
|
||||||
reject(new Error('Element not found.'));
|
|
||||||
}, timeout);
|
|
||||||
|
|
||||||
observer.observe(document.body, {
|
|
||||||
childList: true,
|
|
||||||
subtree: true
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
console.log("开始删除...")
|
console.log("开始删除...")
|
||||||
const checkbox = conversationCheckboxes[0];
|
const checkbox = conversationCheckboxes[0];
|
||||||
@@ -55,14 +32,18 @@ async function bulkDeleteConversations() {
|
|||||||
conversationElement.click(); // Click the conversation first
|
conversationElement.click(); // Click the conversation first
|
||||||
await new Promise(resolve => setTimeout(resolve, 500)); // Add a delay of 0.5 second
|
await new Promise(resolve => setTimeout(resolve, 500)); // Add a delay of 0.5 second
|
||||||
|
|
||||||
const deleteButton = document.querySelector('.absolute.flex.right-1.z-10.text-gray-300.visible button:nth-child(3)'); // Updated delete button selector
|
const deleteButton = document.querySelector('.absolute.flex.right-1.z-10.text-gray-300.visible button:nth-child(2)'); // Updated delete button selector
|
||||||
|
|
||||||
if (deleteButton) {
|
if (deleteButton) {
|
||||||
console.log("点击删除按钮...")
|
console.log("点击删除按钮1...")
|
||||||
deleteButton.click(); // Click the delete button
|
deleteButton.click(); // Click the delete button
|
||||||
await waitForElement('.absolute.flex.right-1.z-10.text-gray-300.visible');
|
console.log("点击删除按钮2...")
|
||||||
const buttonsContainer = document.querySelector('.absolute.flex.right-1.z-10.text-gray-300.visible');
|
await waitForElement('div[role="dialog"][data-state="open"] button.btn-danger');
|
||||||
const confirmButton = buttonsContainer.querySelector('button:nth-child(1)'); // Get the first button as confirm button
|
|
||||||
|
console.log("点击删除按钮3...")
|
||||||
|
// const buttonsContainer = document.querySelector('mt-5 flex flex-col gap-3 sm:mt-4 sm:flex-row-reverse');
|
||||||
|
const confirmButton = document.querySelector('button.btn.btn-danger');
|
||||||
|
|
||||||
if (confirmButton) {
|
if (confirmButton) {
|
||||||
console.log("点击确认按钮...")
|
console.log("点击确认按钮...")
|
||||||
confirmButton.click();
|
confirmButton.click();
|
||||||
@@ -70,7 +51,7 @@ async function bulkDeleteConversations() {
|
|||||||
// 等待删除按钮消失
|
// 等待删除按钮消失
|
||||||
const deleteButtonDisappeared = new Promise((resolve) => {
|
const deleteButtonDisappeared = new Promise((resolve) => {
|
||||||
const observer = new MutationObserver(() => {
|
const observer = new MutationObserver(() => {
|
||||||
if (!document.querySelector('.absolute.flex.right-1.z-10.text-gray-300.visible')) {
|
if (!document.querySelector('button.btn.btn-danger')) {
|
||||||
observer.disconnect();
|
observer.disconnect();
|
||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user