Skip to content

Instantly share code, notes, and snippets.

@A6Brgeuka
Last active February 12, 2021 17:52
Show Gist options
  • Save A6Brgeuka/695cf802d495b43587d7fe9ed639f84e to your computer and use it in GitHub Desktop.
Save A6Brgeuka/695cf802d495b43587d7fe9ed639f84e to your computer and use it in GitHub Desktop.
async function delay(ms) {
return new Promise(res => {
setTimeout(res, ms)
})
}
async function findElement(selector, attemps = 10) {
if (!attemps) {
throw Error(`not found ${selector}`);
}
const el = $(selector);
if (!el) {
await delay(1000);
return findElement(el, --attemps);
}
return Promise.resolve(el);
}
async function removeIndexes() {
const moreButtons = $("mat-card mat-icon:contains('more_vert')").toArray();
for (let moreButton of moreButtons) {
await new Promise(async res => {
moreButton.click(); // show menu
await delay(500);
const deleteItem = await findElement('button[aria-label="Delete"]');
deleteItem.click();
await delay(1000);
const el = await findElement('.delete-index-delete-button span.mat-button-wrapper')
el.click()
await delay(1500);
res()
})
}
}
removeIndexes()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment