Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Function to auto-click all elements matching a selector
- function autoClicker(selector, interval) {
- setInterval(() => {
- const elements = document.querySelectorAll(selector);
- if (elements.length > 0) {
- elements.forEach((element, index) => {
- // Manually dispatch a click event on the element
- const event = new MouseEvent('click', {
- bubbles: true, // Allows the event to propagate up the DOM
- cancelable: true, // Indicates whether the event can be canceled
- view: window
- });
- element.dispatchEvent(event); // Simulate the click
- console.log(`Dispatched click event for element ${index + 1} of ${elements.length}: ${selector}`);
- });
- } else {
- console.log(`No elements found for selector: ${selector}`);
- }
- }, interval);
- }
- // Call the function with a CSS selector and interval
- autoClicker('.css-ie9j0x', 200); // Click every 200 ms
Advertisement
Add Comment
Please, Sign In to add comment