update xpath

This commit is contained in:
Admin 2025-09-05 16:18:35 +07:00
parent f9b4db8125
commit d20ac8d6ce
3 changed files with 15 additions and 23 deletions

File diff suppressed because one or more lines are too long

View File

@ -207,31 +207,20 @@ export class ContentService {
}
private async _rightClickMessage(date_time: number) {
const xpath = this.service.elTags.container_chat;
const selector = this.service.elTags.container_chat;
const itemId = `content-${date_time}`;
const findElementByXPath = (xpath: string): HTMLElement | null => {
const result = document.evaluate(
xpath,
document,
null,
XPathResult.FIRST_ORDERED_NODE_TYPE,
null
);
return result.singleNodeValue as HTMLElement | null;
};
const maxScrollAttempts = 30;
const scrollStep = 200;
let attempts = 0;
let wrapper = findElementByXPath(xpath);
let wrapper = document.querySelector(selector);
if (!wrapper) {
console.error("Wrapper not found:", xpath);
console.error("Wrapper not found:", selector);
return;
}
let element = wrapper.querySelector<HTMLElement>(`#${itemId}`);
let element = document.querySelector<HTMLElement>(`#${itemId}`);
while (!element && attempts < maxScrollAttempts) {
const scrollContainer = wrapper;
@ -243,7 +232,7 @@ export class ContentService {
);
await delay(200); // Đợi scroll và DOM render lại
wrapper = findElementByXPath(xpath);
wrapper = document.querySelector(selector);
if (!wrapper) break;
element = wrapper.querySelector<HTMLElement>(`#${itemId}`);
@ -254,6 +243,7 @@ export class ContentService {
}
if (!element) {
console.log({ element });
console.error("Không tìm thấy phần tử:", itemId);
return;
}

View File

@ -11,7 +11,9 @@ export class TeamsChatService {
conatainer_conversations:
"/html/body/div[1]/div/div/div/div[5]/div[1]/div[1]/div[2]/div[1]/div[1]/div/div[1]",
container_chat:
"/html/body/div[1]/div/div/div/div[6]/div[4]/div/div[1]/div/div[1]/div/div/div/div[1]/div/div/div[4]",
// "/html/body/div[1]/div/div/div/div[6]/div[4]/div/div[1]/div/div[1]/div/div/div/div[1]/div/div/div[4]",
'[data-testid="message-wrapper"]',
root_id: '[aria-selected="true"] [id^="chat-list-item"]',
room_name: '[data-tid="chat-title"]',
close_reply_btn: