-
Notifications
You must be signed in to change notification settings - Fork 0
/
content.js
43 lines (38 loc) · 1.26 KB
/
content.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
function waitForElement(selector) {
return new Promise((resolve) => {
if (document.querySelector(selector)) {
return resolve(document.querySelector(selector));
}
const observer = new MutationObserver(() => {
if (document.querySelector(selector)) {
resolve(document.querySelector(selector));
observer.disconnect();
}
});
observer.observe(document.body, {
childList: true,
subtree: true,
});
});
}
function setupEmailClickListener() {
const ticketNumber = window.location.href.replace(/\D/g, "");
waitForElement(
`div[id$="${ticketNumber}"] div[data-test-id="attribute-email-display"] div[color="blue"]`
).then((element) => {
// 모든 기존 'click' 이벤트 리스너를 제거
const newElement = element.cloneNode(true);
element.parentNode.replaceChild(newElement, element);
// 새 'click' 이벤트 리스너 등록
newElement.addEventListener("click", () => {
const encodedEmail =
newElement.textContent && encodeURIComponent(newElement.textContent);
window.open(
`https://foa-v2.rememberapp.co.kr/users/direct_search?value=${encodedEmail}`,
"_blank",
"noopener=yes,noreferrer=yes"
);
});
});
}
setupEmailClickListener();