Created
November 19, 2024 18:18
-
-
Save maksii/6da5175b3455b2df72126ab6e842d27d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Function to simulate clicks on buttons | |
function simulateClicks() { | |
// Select all anchor elements with the specified class | |
const buttons = document.querySelectorAll('a.torrent-search--list__file.form__standard-icon-button'); | |
// Retrieve the clicked URLs from local storage or initialize an empty array | |
const clickedUrls = JSON.parse(localStorage.getItem('clickedUrls')) || []; | |
// Log the number of buttons found | |
console.log(`Found ${buttons.length} button(s).`); | |
// Function to click a button with a delay | |
function clickButton(index) { | |
if (index < buttons.length) { | |
const button = buttons[index]; | |
const href = button.href; | |
// Check if the button's href is already in the clicked URLs | |
if (!clickedUrls.includes(href)) { | |
// Log the click action | |
console.log(`Clicking button ${index + 1} of ${buttons.length}. URL: ${href}`); | |
// Simulate a click on the button | |
button.click(); | |
// Add the URL to the clicked URLs and update local storage | |
clickedUrls.push(href); | |
localStorage.setItem('clickedUrls', JSON.stringify(clickedUrls)); | |
// Wait 5 seconds before the next click | |
setTimeout(() => clickButton(index + 1), 5000); | |
} else { | |
// Log that the button was already clicked and skip | |
console.log(`Button ${index + 1} already clicked. URL: ${href}`); | |
clickButton(index + 1); | |
} | |
} else { | |
// Log when all buttons have been processed | |
console.log('Finished processing all buttons.'); | |
} | |
} | |
// Start clicking from the first button | |
clickButton(0); | |
} | |
// Call the function to start the process | |
simulateClicks(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment