Last active
December 12, 2023 05:09
-
-
Save greenido/ba1f7fdbd59cae92d12a01e76d2401bc to your computer and use it in GitHub Desktop.
Remove all the artifacts from https://gitlab.com/YOUR_COMPANY/YOUR_GIT_REPO/-/artifacts
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
// 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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
...and to move X pages into history: