You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
3.0 KiB
75 lines
3.0 KiB
|
4 months ago
|
/**
|
||
|
|
* Clicks a button at a controlled rate over a specific duration, with randomized timing
|
||
|
|
* to better avoid rate-limiting and detection.
|
||
|
|
*
|
||
|
|
* @param {string} selector - The CSS selector for the button to click.
|
||
|
|
* @param {number} clicksPerSecond - The target average number of clicks per second.
|
||
|
|
* @param {number} durationSeconds - The total duration in seconds to run the clicker.
|
||
|
|
* @param {number} timingRandomnessPercent - The percentage of randomness to apply to the timing.
|
||
|
|
*/
|
||
|
|
async function controlledRateClicker(selector, clicksPerSecond, durationSeconds, timingRandomnessPercent) {
|
||
|
|
const buttonToClick = document.querySelector(selector);
|
||
|
|
|
||
|
|
if (!buttonToClick) {
|
||
|
|
console.error(`Error: Button not found with selector "${selector}".`);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
const startTime = Date.now();
|
||
|
|
const endTime = startTime + durationSeconds * 1000;
|
||
|
|
const baseIntervalMs = 1000 / clicksPerSecond;
|
||
|
|
let clickCount = 0;
|
||
|
|
let successfulClicks = 0;
|
||
|
|
|
||
|
|
console.log(`--- 🐢 Starting Controlled-Rate Clicker ---`);
|
||
|
|
console.log(` - Target Rate: ${clicksPerSecond} clicks/sec`);
|
||
|
|
console.log(` - Duration: ${durationSeconds / 60} minutes`);
|
||
|
|
console.log(` - Base Interval: ${baseIntervalMs.toFixed(2)}ms`);
|
||
|
|
console.log(` - Timing Randomness: ±${timingRandomnessPercent}%`);
|
||
|
|
|
||
|
|
// A recursive function is more robust than setInterval for managing random delays.
|
||
|
|
const clickLoop = async () => {
|
||
|
|
// Stop if the duration has passed or the button is gone/disabled.
|
||
|
|
const currentButton = document.querySelector(selector);
|
||
|
|
if (Date.now() >= endTime || !currentButton || currentButton.disabled) {
|
||
|
|
const totalTime = (Date.now() - startTime) / 1000;
|
||
|
|
console.log(`\n--- 🏁 Clicker Finished ---`);
|
||
|
|
console.log(` - Total Clicks Attempted: ${clickCount}`);
|
||
|
|
console.log(` - Successful Clicks: ${successfulClicks}`);
|
||
|
|
console.log(` - Duration: ${totalTime.toFixed(2)} seconds`);
|
||
|
|
alert(`Controlled-Rate Clicker Finished!\nSuccessful clicks: ${successfulClicks}`);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// Perform the click
|
||
|
|
currentButton.click();
|
||
|
|
clickCount++;
|
||
|
|
successfulClicks++; // Assuming success for this example
|
||
|
|
console.log(`Click #${clickCount}`);
|
||
|
|
|
||
|
|
// Calculate the next delay with random jitter
|
||
|
|
const jitter = (Math.random() - 0.5) * 2 * baseIntervalMs * (timingRandomnessPercent / 100);
|
||
|
|
const nextDelay = Math.max(50, baseIntervalMs + jitter); // Ensure a minimum delay of 50ms
|
||
|
|
|
||
|
|
// Schedule the next click
|
||
|
|
setTimeout(clickLoop, nextDelay);
|
||
|
|
};
|
||
|
|
|
||
|
|
// Start the first click
|
||
|
|
clickLoop();
|
||
|
|
}
|
||
|
|
|
||
|
|
// --- Configuration ---
|
||
|
|
const buttonSelector = 'button.n1vthr6p.n155pca5';
|
||
|
|
|
||
|
|
// Target an average of 10 clicks per second.
|
||
|
|
const clicksPerSecond = 4;
|
||
|
|
|
||
|
|
// Run for 5 minutes (300 seconds) as requested.
|
||
|
|
const durationInSeconds = 300;
|
||
|
|
|
||
|
|
// Add 25% randomness to the timing between clicks to seem more human.
|
||
|
|
const timingRandomness = 25;
|
||
|
|
|
||
|
|
// --- Run the Clicker ---
|
||
|
|
controlledRateClicker(buttonSelector, clicksPerSecond, durationInSeconds, timingRandomness);
|