-
Notifications
You must be signed in to change notification settings - Fork 2
/
user.js
92 lines (74 loc) · 2.2 KB
/
user.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// ==UserScript==
// @name Cibus extension
// @namespace Violentmonkey Scripts
// @match https://consumers.pluxee.co.il/*
// @grant none
// @version 1.1
// @author -
// @description 20/09/2024, 15:19:45
// ==/UserScript==
function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
async function addDomain(domain) {
console.log(`Adding domain ${domain}`);
while (true) {
var friends = document.querySelector(".cib-btn");
friends.click();
await sleep(1000);
var input = document.querySelector(".mat-input-element");
if (input == null) {
console.log("Cannot find the input field");
return;
}
var confirmButton = document.querySelectorAll(".cib-btn")[2];
if (confirmButton == null || confirmButton.textContent != " אישור ") {
console.log("Cannot find the confirm button");
return;
}
input.value = domain;
input.dispatchEvent(new Event("input", { bubbles: true }));
await sleep(2000);
var users = document.querySelectorAll(".friends-add");
if (users.length == 0) {
console.log("No users found");
break;
}
for (var i = 0; i < users.length; i++) {
var user = users[i];
console.log(user);
user.dispatchEvent(new Event("click", { bubbles: true }));
}
confirmButton.click();
await sleep(1000);
if (users.length < 10) {
break;
}
}
var xButton = document.querySelector(".search-panel > a");
if (xButton != null) {
xButton.click();
}
}
async function addEveryone() {
await addDomain("wiz");
await addDomain("com");
}
async function main() {
while (true) {
await sleep(1000);
if (document.querySelector("#addEveryoneButton") != null) {
continue;
}
var friends = document.querySelector(".cib-btn");
if (friends == null || friends.textContent.trim() != "להוספת חברים") {
continue;
}
var addEveryoneButton = friends.cloneNode(true);
addEveryoneButton.id = "addEveryoneButton";
addEveryoneButton.textContent = "להוספת כל החברים";
addEveryoneButton.onclick = addEveryone;
friends.insertAdjacentElement("afterend", addEveryoneButton);
}
}
main();