Skip to content

Commit

Permalink
added start stop and counter buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
unofficialdxnny authored Sep 25, 2024
1 parent cd75bcf commit b532a96
Showing 1 changed file with 86 additions and 5 deletions.
91 changes: 86 additions & 5 deletions SnapifyWebALL.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,59 @@
counterElement.textContent = `Elements clicked: ${clickCounter}`;
document.body.appendChild(counterElement);

// Add start and stop buttons
const buttonContainer = document.createElement('div');
buttonContainer.style.position = 'fixed';
buttonContainer.style.top = '50px';
buttonContainer.style.left = '10px';
buttonContainer.style.zIndex = 10000;
buttonContainer.style.display = 'flex';
buttonContainer.style.flexDirection = 'column';
buttonContainer.style.gap = '10px'; // Add space between buttons
document.body.appendChild(buttonContainer);

const startButton = document.createElement('button');
startButton.textContent = 'Start';
startButton.style.padding = '10px 15px';
startButton.style.backgroundColor = '#4CAF50'; // Green color
startButton.style.color = 'white';
startButton.style.border = 'none';
startButton.style.borderRadius = '5px';
startButton.style.cursor = 'pointer';
startButton.style.fontSize = '16px';
startButton.style.transition = 'background-color 0.3s';
buttonContainer.appendChild(startButton);

const stopButton = document.createElement('button');
stopButton.textContent = 'Stop';
stopButton.style.padding = '10px 15px';
stopButton.style.backgroundColor = '#f44336'; // Red color
stopButton.style.color = 'white';
stopButton.style.border = 'none';
stopButton.style.borderRadius = '5px';
stopButton.style.cursor = 'pointer';
stopButton.style.fontSize = '16px';
stopButton.style.transition = 'background-color 0.3s';
buttonContainer.appendChild(stopButton);

// Add hover effects
startButton.addEventListener('mouseover', () => {
startButton.style.backgroundColor = '#45a049'; // Darker green
});
startButton.addEventListener('mouseout', () => {
startButton.style.backgroundColor = '#4CAF50'; // Original green
});

stopButton.addEventListener('mouseover', () => {
stopButton.style.backgroundColor = '#e53935'; // Darker red
});
stopButton.addEventListener('mouseout', () => {
stopButton.style.backgroundColor = '#f44336'; // Original red
});

let isClicking = false; // Flag to control clicking process
let clickInterval; // Variable to hold the setInterval for clicking

// Function to update the visual counter
function updateCounter() {
clickCounter++;
Expand Down Expand Up @@ -118,7 +171,7 @@
"/html/body/main/div[1]/div[3]/div/div/div/div[2]/div[1]/div/div/div/div/div[2]/div[2]/button[2]"
];

const delay = 100; // Delay in milliseconds between each click
const delay = 500; // Delay in milliseconds between each click

clickElementsInSequence(xpaths, delay, function () {
// Click all specific elements with the class 'hSQnC' that are children of 'Ewflr'
Expand All @@ -128,15 +181,43 @@
finalElement.click();
updateCounter(); // Increment counter for the final click
console.log(`Final element clicked.`);

// Wait for 10 seconds before allowing the site to perform its actions
setTimeout(function() {
console.log(`Waiting for the site to do its thing...`);

// Wait an additional 5 seconds before running the process again
setTimeout(function() {
console.log(`Restarting the clicking process...`);
performClicks(); // Restart clicking process
}, 5000); // 5 seconds delay
}, 10000); // 10 seconds delay
} else {
console.log(`Final element not visible.`);
}

// Restart the clicking process after a 10-second delay
setTimeout(performClicks, 5000); // 5 seconds delay
});
});
}

performClicks();
// Event listener for start button
startButton.addEventListener('click', function () {
if (!isClicking) {
isClicking = true;
performClicks(); // Start clicking process
startButton.disabled = true; // Disable the start button
stopButton.disabled = false; // Enable the stop button
}
});

// Event listener for stop button
stopButton.addEventListener('click', function () {
isClicking = false;
clearTimeout(clickInterval); // Stop the clicking process
startButton.disabled = false; // Enable the start button
stopButton.disabled = true; // Disable the stop button
});

// Initialize stop button to be disabled at first
stopButton.disabled = true;

})();

0 comments on commit b532a96

Please sign in to comment.