fix, wip
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
console.log('addCheckboxes.js loaded');
|
||||
// 查找带有特定选择器的祖先元素
|
||||
function findAncestorWithCheckbox(el, selector) {
|
||||
while ((el = el.parentElement) && !el.querySelector(selector));
|
||||
@@ -6,6 +7,11 @@ function findAncestorWithCheckbox(el, selector) {
|
||||
|
||||
// 切换复选框的选中状态
|
||||
function toggleCheckbox(event) {
|
||||
// 阻止事件的默认行为(例如链接跳转)
|
||||
event.preventDefault();
|
||||
// 阻止事件冒泡到父元素
|
||||
event.stopPropagation();
|
||||
|
||||
const parentElement = findAncestorWithCheckbox(event.currentTarget, `.${CHECKBOX_CLASS}`);
|
||||
const checkbox = parentElement ? parentElement.querySelector(`.${CHECKBOX_CLASS}`) : null;
|
||||
if (checkbox) {
|
||||
@@ -21,7 +27,8 @@ function preventEventPropagation(event) {
|
||||
|
||||
// 添加复选框到每个对话
|
||||
function addCheckboxes() {
|
||||
const conversations = document.querySelectorAll(CONVERSATION_SELECTOR);
|
||||
console.log('Adding checkboxes to conversations...', Selectors, isPlusUser());
|
||||
const conversations = document.querySelectorAll(Selectors.CONVERSATION_SELECTOR);
|
||||
|
||||
conversations.forEach((conversation, index) => {
|
||||
let existingCheckbox = conversation.querySelector(`.${CHECKBOX_CLASS}`);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
console.log('bulkDeleteConversations.js loaded');
|
||||
|
||||
async function bulkDeleteConversations() {
|
||||
const selectedConversations = getSelectedConversations();
|
||||
|
||||
@@ -24,11 +26,28 @@ function removeAllCheckboxes() {
|
||||
}
|
||||
|
||||
async function deleteConversation(checkbox) {
|
||||
const conversationElement = await checkbox.closest('.flex.p-3.items-center.gap-3.relative.rounded-md');
|
||||
const conversationElement = checkbox.parentElement;
|
||||
|
||||
console.log("1. Clicking conversation", conversationElement);
|
||||
conversationElement.click();
|
||||
await delay(300);
|
||||
await delay(500);
|
||||
|
||||
if (isPlusUser()) {
|
||||
// Plus 用户的处理逻辑
|
||||
const threeDotButton = conversationElement.parentElement.querySelector('[id^="radix-"]');
|
||||
await delay(800);
|
||||
console.log(threeDotButton);
|
||||
|
||||
// 创建一个指针事件对象
|
||||
const pointerDownEvent = new PointerEvent('pointerdown', {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
pointerType: 'mouse' // 可以是 'mouse', 'pen', 'touch'
|
||||
});
|
||||
|
||||
// 触发 onPointerDown 事件
|
||||
threeDotButton.dispatchEvent(pointerDownEvent);
|
||||
}
|
||||
|
||||
const deleteButton = await waitForElement(Selectors.deleteButton);
|
||||
|
||||
|
||||
38
globals.js
38
globals.js
@@ -1,13 +1,39 @@
|
||||
console.log('globals.js loaded');
|
||||
|
||||
let lastChecked = null;
|
||||
|
||||
const Selectors = {
|
||||
const standardSelectors = {
|
||||
// 标准用户的选择器
|
||||
conversationsCheckbox: '.conversation-checkbox:checked',
|
||||
deleteButton: 'nav div a>div>button:nth-child(2)',
|
||||
confirmDeleteButton: 'button.btn.btn-danger',
|
||||
// 其他标准用户选择器...
|
||||
CONVERSATION_SELECTOR: 'div div span div ol li>a.flex',
|
||||
TITLE_SELECTOR: '.flex-1.text-ellipsis.max-h-5.overflow-hidden.break-all.relative',
|
||||
};
|
||||
|
||||
|
||||
// 定义选择器和其他常量
|
||||
const CONVERSATION_SELECTOR = 'div div span div ol li>a.flex';
|
||||
const TITLE_SELECTOR = '.flex-1.text-ellipsis.max-h-5.overflow-hidden.break-all.relative';
|
||||
const CHECKBOX_CLASS = 'conversation-checkbox';
|
||||
const plusSelectors = {
|
||||
// Plus 用户的选择器
|
||||
conversationsCheckbox: '.conversation-checkbox:checked',
|
||||
deleteButton: '[class*="text-red"]',
|
||||
confirmDeleteButton: 'button.btn.btn-danger',
|
||||
// 其他 Plus 用户选择器...
|
||||
CONVERSATION_SELECTOR: 'div > div > div > div > div > div > nav > div > div > div > span > div > ol > li > div > a',
|
||||
TITLE_SELECTOR: '.relative.grow.overflow-hidden.whitespace-nowrap',
|
||||
};
|
||||
|
||||
const CHECKBOX_CLASS = 'conversation-checkbox';
|
||||
|
||||
let Selectors;
|
||||
|
||||
function isPlusUser() {
|
||||
const spans = document.querySelectorAll('span.text-sm');
|
||||
return Array.from(spans).some(span => span.textContent.trim() === "Explore");
|
||||
}
|
||||
|
||||
function initializeSelectors() {
|
||||
Selectors = isPlusUser() ? plusSelectors : standardSelectors;
|
||||
}
|
||||
|
||||
// 确保在文档加载完毕后初始化 Selectors
|
||||
document.addEventListener('DOMContentLoaded', initializeSelectors);
|
||||
Reference in New Issue
Block a user