-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript4.js
More file actions
37 lines (32 loc) · 1.56 KB
/
script4.js
File metadata and controls
37 lines (32 loc) · 1.56 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
// Define the text that should be in the 'aria-label' attribute
var buttonTextPart = 'Inviter'; // Part of the aria-label to match
// Function to find, scroll, and click all buttons that match the aria-label text
function findAndClickInviteButtons() {
// Find all buttons with the 'aria-label' attribute
var buttons = document.querySelectorAll('button[aria-label]');
var clickIndex = 0;
// Function to scroll to the button and click it with a delay of 500 ms
function clickNextButton() {
if (clickIndex < buttons.length) {
var button = buttons[clickIndex];
var ariaLabel = button.getAttribute('aria-label');
if (ariaLabel && ariaLabel.includes(buttonTextPart)) {
button.scrollIntoView({ behavior: 'smooth', block: 'center' }); // Scroll to the button smoothly
setTimeout(function() {
button.click(); // Click the button after scrolling
console.log('Clicked button:', button);
clickIndex++; // Move to the next button
clickNextButton(); // Schedule the next click
}, 500); // 500 ms delay before clicking
} else {
clickIndex++; // Skip if aria-label doesn't match and continue
clickNextButton();
}
}
}
// Start clicking the buttons
clickNextButton();
}
// Run the function initially and then every 5 seconds
findAndClickInviteButtons();
setInterval(findAndClickInviteButtons, 5000); // Refresh every 5 seconds