-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
88 lines (70 loc) · 2.18 KB
/
Copy pathscript.js
File metadata and controls
88 lines (70 loc) · 2.18 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
var imageURL = "https://upload.wikimedia.org/wikipedia/commons/3/3f/Mute_Icon.svg"
var diceURL = "https://www.svgrepo.com/show/198053/dice.svg"
const htmlBtnMuteAll = '<div title="MuteAll" tabindex="0"> <img src="' + imageURL + '" width="22"> </div>';
const htmlBtnDice = '<div title="Dice" tabindex="0"> <img src="' + diceURL + '" width="22"> </div>';
const interval = setInterval(() => {
const header = document.querySelector(".NzPR9b");
if(header){
console.log(header);
clearInterval(interval);
const btnMuteAll = document.createElement("button");
const btnDice = document.createElement("button");
btnMuteAll.style.background = "red";
btnDice.style.background = "gray";
btnMuteAll.innerHTML = htmlBtnMuteAll;
btnDice.innerHTML = htmlBtnDice;
btnMuteAll.classList.add("btnMuteAll");
btnDice.classList.add("btnDice");
btnMuteAll.addEventListener("click", () => {
start();
});
btnDice.addEventListener("click", () => {
startDice();
});
header.insertBefore(btnDice, header.childNodes[0]);
header.insertBefore(btnMuteAll, header.childNodes[0]);
}
}, 1000);
let allUsers, allUsersLength;
function start(){
allUsers = document.querySelectorAll('.uArJ5e.Y5FYJe.cjq2Db.HZJnJ.RfqEId');
allUsersLength = allUsers.length - 1;
var myInterval = setInterval( function() {
if(allUsersLength >= 0){
muteUser(allUsersLength);
}
else{
clearMyInterval(myInterval);
}
}, 800);
}
function startDice(){
allUsers = document.querySelectorAll('.uArJ5e.Y5FYJe.cjq2Db.HZJnJ.RfqEId');
allUsersLength = allUsers.length;
var rand = Math.floor(Math.random() * allUsersLength);
muteUser2(rand)
}
function muteUser(index) {
allUsers[index].click();
setTimeout( function() {
confirm();
}, 100);
allUsersLength--;
}
function muteUser2(index) {
allUsers[index].click();
setTimeout( function() {
confirm();
}, 100);
}
function clearMyInterval(interval){
clearInterval(interval);
}
function confirm(){
var confirm = document.querySelector(".U26fgb.O0WRkf.oG5Srb.HQ8yf.C0oVfc.kHssdc");
if(confirm)
confirm.click();
}
chrome.runtime.onMessage.addListener(msgObj => {
start();
});