Skip to content

Instantly share code, notes, and snippets.

@xElkomy
Created December 16, 2023 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xElkomy/45a9c317aeb861ab91b04aa7516e445b to your computer and use it in GitHub Desktop.
Save xElkomy/45a9c317aeb861ab91b04aa7516e445b to your computer and use it in GitHub Desktop.
Basic Javascript macro open https://example/#/scans?status=queued,starting and put this code into your console and click enter and let it, it will loop 100 with delay before every loop 10 seconds.
// Function to click the "Select All" checkbox
function clickSelectAll() {
const selectAllCheckbox = document.querySelector('.mat-checkbox-inner-container.mat-checkbox-inner-container-no-side-margin'); // Adjust the selector based on the actual class or selector for the "Select All" checkbox
selectAllCheckbox.click();
}
// Function to click the "Delete Scans" button
function clickDeleteButton() {
const buttons = document.querySelectorAll('.mat-button-wrapper'); // Adjust the selector based on the actual class or selector for buttons in Acunetix
for (const button of buttons) {
if (button.textContent.includes('Delete Scans')) {
button.click();
break;
}
}
}
// Function to click the "Yes" button in the confirmation dialog
function confirmDeletion() {
const yesButton = document.getElementById('btnDialogYes'); // Adjust the selector based on the actual ID or selector for the "Yes" button in Acunetix
if (yesButton) {
yesButton.click();
console.log('Clicked "Yes" button.');
} else {
console.error('Yes button not found.');
}
}
// Function to perform the entire process
function deleteAllScans() {
clickSelectAll();
clickDeleteButton();
confirmDeletion();
}
// Function to execute the process multiple times with a delay
function executeWithDelay(iterations, delayInSeconds) {
let currentIteration = 0;
function executeLoop() {
if (currentIteration < iterations) {
console.log(`Executing iteration ${currentIteration + 1}`);
deleteAllScans();
currentIteration++;
} else {
console.log('Finished all iterations.');
clearInterval(intervalId);
}
}
const intervalId = setInterval(executeLoop, delayInSeconds * 1000);
}
// Call the function to execute the process 100 times with a 10-second delay between each loop
executeWithDelay(100, 10);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment