Skip to content

Instantly share code, notes, and snippets.

@greenido
Last active December 12, 2023 05:09
Show Gist options
  • Save greenido/ba1f7fdbd59cae92d12a01e76d2401bc to your computer and use it in GitHub Desktop.
Save greenido/ba1f7fdbd59cae92d12a01e76d2401bc to your computer and use it in GitHub Desktop.
// Find all buttons with data-testid="job-artifacts-delete-button"
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
// Function to click on the second button within the pop-up
const clickSecondButtonInPopup = async () => {
const secondButton = document.querySelector('.btn.js-modal-action-primary.btn-danger.btn-md.gl-button');
// If the second button is found, click on it
if (secondButton) {
secondButton.click();
} else {
// If the second button is not found, log an error or handle accordingly
console.error('Second button not found in the pop-up');
}
};
// Loop through the buttons and click on each of them
async function clickOnButtons() {
const buttons = document.querySelectorAll('[data-testid="job-artifacts-delete-button"]');
console.log("🌹🌹🌹🌹🌹 found: " + buttons.length + " buttons");
for (let i = 0; i < buttons.length; i++) {
const button = buttons[i];
// Click on the current button
console.log("click on the first button");
button.click();
await sleep(500);
await clickSecondButtonInPopup();
console.log("🌹 confirmation Clicked");
}
}
async function clickOnNextButton() {
const nextPageLink = document.querySelector('.gl-link.page-link.next-page-item.gl-display-flex');
// Check if the link element is found
if (nextPageLink) {
// Click on the link
nextPageLink.click();
} else {
// Log an error or handle accordingly if the link is not found
console.error('Next page link not found');
}
}
// Call the function to click on all buttons for X pages
for (let j = 0; j < 10; j++) {
await clickOnButtons();
console.log("🌹 all buttons clicked - Going for the next page");
await sleep(1000);
await clickOnNextButton();
await sleep(1000);
}
@greenido
Copy link
Author

...and to move X pages into history:

async function clickOnNextButton() {
  const nextPageLink = document.querySelector('.gl-link.page-link.next-page-item.gl-display-flex');
  // Check if the link element is found
  if (nextPageLink) {
    // Click on the link
    nextPageLink.click();
  } else {
    // Log an error or handle accordingly if the link is not found
    console.error('Next page link not found');
  }
}

const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));

// Call the function to click on all buttons for X pages
async function clickOnNextButtons() {
  for (let j = 0; j < 20; j++) {
    console.log("🌹 Going for the next page");
    await clickOnNextButton();  
    await sleep(1000);
  }
}

clickOnNextButtons();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment