|
|
|
|
|
by bqmjjx0kac
729 days ago
|
|
This got a little stuck on a few of the `.click()` calls for me. Here's my version: const wait = () => new Promise(resolve => setTimeout(resolve, 1000));
const getElementsByAriaLabel = (label) => document.querySelectorAll(`[aria-label="${label}"]`);
const getElementsByRoleAndWidth = (role, width) =>
Array.from(document.querySelectorAll(`[role="${role}"]`)).filter(el => el.clientWidth === width);
const getElementsByText = (text) => Array.from(document.querySelectorAll('*')).filter(el =>
Array.from(el.childNodes).some(node => node.nodeType === Node.TEXT_NODE && node.textContent.includes(text))
);
async function clickAndWait(elem) {
if (!elem)
return;
elem.click();
await wait();
}
await clickAndWait(getElementsByText("See more")[0]);
const ads = getElementsByRoleAndWidth('listitem', 508);
for (const ad of ads) {
console.log(ad.childNodes[0].textContent)
await clickAndWait(ad.childNodes[0]);
await clickAndWait(getElementsByText('They uploaded or used a list to reach you.')[0]);
const dont_allow_btns = getElementsByText('Don\'t allow');
for (const btn of dont_allow_btns) {
btn.click();
}
await wait();
await clickAndWait(getElementsByAriaLabel('Back')[2]);
await clickAndWait(getElementsByAriaLabel('Back')[2]);
}
|
|
Anyone using this may want to s/1000/2000/ on the first line.