Require real MAX chat removal
This commit is contained in:
@@ -5821,11 +5821,6 @@ async function applyChatMenuActionInMax(p, externalChatId, chatUrl, actionLabels
|
|||||||
await p.waitForTimeout(1200);
|
await p.waitForTimeout(1200);
|
||||||
await clearSidebarSearch(p);
|
await clearSidebarSearch(p);
|
||||||
const removed = await waitForSidebarChatRemoval(p, externalChatId, chatUrl, 10000);
|
const removed = await waitForSidebarChatRemoval(p, externalChatId, chatUrl, 10000);
|
||||||
if (!removed && confirmed && await isResidualEmptyContactStub(p, externalChatId, chatUrl)) {
|
|
||||||
console.info("[chat/delete] confirmed delete but MAX kept an empty contact stub; treating action as complete.");
|
|
||||||
return { success: true, error: null };
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!removed) {
|
if (!removed) {
|
||||||
return { success: false, error: "MAX delete chat action did not remove the chat from the sidebar." };
|
return { success: false, error: "MAX delete chat action did not remove the chat from the sidebar." };
|
||||||
}
|
}
|
||||||
@@ -5927,42 +5922,6 @@ async function isSidebarChatPresent(p, externalChatId, chatUrl = null) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function isResidualEmptyContactStub(p, externalChatId, chatUrl) {
|
|
||||||
const descriptor = decodeDomChatDescriptor(externalChatId);
|
|
||||||
if (!descriptor?.title) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const targetUrl = normalizeMaxChatUrl(chatUrl);
|
|
||||||
if (targetUrl) {
|
|
||||||
await openDomChatByUrl(p, targetUrl);
|
|
||||||
await waitForDomChatReady(p, descriptor.title, 5000, false);
|
|
||||||
await p.waitForTimeout(500);
|
|
||||||
}
|
|
||||||
|
|
||||||
return await p.evaluate((title) => {
|
|
||||||
const normalize = (value) => String(value || "")
|
|
||||||
.replace(/\u00a0/g, " ")
|
|
||||||
.replace(/\s+/g, " ")
|
|
||||||
.trim()
|
|
||||||
.toLowerCase();
|
|
||||||
const wanted = normalize(title);
|
|
||||||
const bodyText = normalize(document.body?.innerText);
|
|
||||||
const headerText = normalize(
|
|
||||||
document.querySelector("[class*='chat' i] [class*='header' i], [class*='header' i], header")?.innerText ||
|
|
||||||
"");
|
|
||||||
const selectedText = normalize(document.querySelector("aside button[class*='selected' i]")?.innerText || "");
|
|
||||||
const hasTitle = Boolean(wanted && (headerText.includes(wanted) || selectedText.includes(wanted) || bodyText.includes(wanted)));
|
|
||||||
if (!hasTitle) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const emptyChat = /(\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043f\u043e\u043a\u0430 \u043d\u0435\u0442|\u043d\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435|no messages yet|write a message)/i.test(bodyText);
|
|
||||||
const maxContactStub = /(\u0442\u0435\u043f\u0435\u0440\u044c \u0432 max|\u043d\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c|now in max|write something)/i.test(selectedText || bodyText);
|
|
||||||
return Boolean(emptyChat && maxContactStub);
|
|
||||||
}, descriptor.title).catch(() => false);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function setMessageReactionInMax(p, externalChatId, externalMessageId, currentText, emoji) {
|
async function setMessageReactionInMax(p, externalChatId, externalMessageId, currentText, emoji) {
|
||||||
const target = await locateMessageForAction(p, externalChatId, externalMessageId, currentText);
|
const target = await locateMessageForAction(p, externalChatId, externalMessageId, currentText);
|
||||||
if (!target) {
|
if (!target) {
|
||||||
|
|||||||
Reference in New Issue
Block a user