Last active
February 12, 2021 17:52
-
-
Save A6Brgeuka/695cf802d495b43587d7fe9ed639f84e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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