-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcontentScript.js
65 lines (58 loc) · 1.26 KB
/
contentScript.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
const isOnJoinPage = () =>
!!document
.evaluate(
"//i[contains(., 'phone_forwarded')]",
document,
null,
XPathResult.ANY_TYPE,
null
)
.iterateNext();
const hideSelfButton = () =>
document
.evaluate(
"//span[i[contains(., 'close_fullscreen')]]",
document,
null,
XPathResult.ANY_TYPE,
null
)
.iterateNext();
const moreButton = () =>
document
.evaluate(
"//i[contains(., 'visual_effects')]/following::i[contains(., 'more_vert')]",
document,
null,
XPathResult.ANY_TYPE,
null
)
.iterateNext();
const closeSendingVideoButton = () =>
document
.evaluate(
"//button[i[contains(., 'close')]]",
document,
null,
XPathResult.ANY_TYPE,
null
)
.iterateNext();
const isElementVisible = (el) => el.offsetParent === null;
const areOthersInTheCall = () =>
document.getElementsByTagName("video").length > 1;
const interval = setInterval(() => {
if (isOnJoinPage()) {
return;
}
if (areOthersInTheCall()) {
clearInterval(interval);
moreButton().click();
setTimeout(() => {
hideSelfButton().click();
}, 200);
setTimeout(() => {
closeSendingVideoButton().click();
}, 4000);
}
}, 2000);