update xpath
This commit is contained in:
parent
f9b4db8125
commit
d20ac8d6ce
File diff suppressed because one or more lines are too long
|
|
@ -207,31 +207,20 @@ export class ContentService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _rightClickMessage(date_time: number) {
|
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 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 maxScrollAttempts = 30;
|
||||||
const scrollStep = 200;
|
const scrollStep = 200;
|
||||||
let attempts = 0;
|
let attempts = 0;
|
||||||
|
|
||||||
let wrapper = findElementByXPath(xpath);
|
let wrapper = document.querySelector(selector);
|
||||||
if (!wrapper) {
|
if (!wrapper) {
|
||||||
console.error("Wrapper not found:", xpath);
|
console.error("Wrapper not found:", selector);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let element = wrapper.querySelector<HTMLElement>(`#${itemId}`);
|
let element = document.querySelector<HTMLElement>(`#${itemId}`);
|
||||||
|
|
||||||
while (!element && attempts < maxScrollAttempts) {
|
while (!element && attempts < maxScrollAttempts) {
|
||||||
const scrollContainer = wrapper;
|
const scrollContainer = wrapper;
|
||||||
|
|
@ -243,7 +232,7 @@ export class ContentService {
|
||||||
);
|
);
|
||||||
await delay(200); // Đợi scroll và DOM render lại
|
await delay(200); // Đợi scroll và DOM render lại
|
||||||
|
|
||||||
wrapper = findElementByXPath(xpath);
|
wrapper = document.querySelector(selector);
|
||||||
if (!wrapper) break;
|
if (!wrapper) break;
|
||||||
|
|
||||||
element = wrapper.querySelector<HTMLElement>(`#${itemId}`);
|
element = wrapper.querySelector<HTMLElement>(`#${itemId}`);
|
||||||
|
|
@ -254,6 +243,7 @@ export class ContentService {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!element) {
|
if (!element) {
|
||||||
|
console.log({ element });
|
||||||
console.error("Không tìm thấy phần tử:", itemId);
|
console.error("Không tìm thấy phần tử:", itemId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,9 @@ export class TeamsChatService {
|
||||||
conatainer_conversations:
|
conatainer_conversations:
|
||||||
"/html/body/div[1]/div/div/div/div[5]/div[1]/div[1]/div[2]/div[1]/div[1]/div/div[1]",
|
"/html/body/div[1]/div/div/div/div[5]/div[1]/div[1]/div[2]/div[1]/div[1]/div/div[1]",
|
||||||
container_chat:
|
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"]',
|
root_id: '[aria-selected="true"] [id^="chat-list-item"]',
|
||||||
room_name: '[data-tid="chat-title"]',
|
room_name: '[data-tid="chat-title"]',
|
||||||
close_reply_btn:
|
close_reply_btn:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue