4 ms·
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));
by bqmjjx0kac 2y 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]);
}
- maltelau 2y agoI wonder if hn (or wherever else this was posted) is big enough to register on the ads-vs-adblocker war. Ads are 509 pixels wide coming in 3 ... 2 ... 1 ...
- GeoHubToday 2y agoclickAndWait is always good! :)
- bqmjjx0kac 2y agoLol, I got hit with this: "You're Temporarily Blocked: It looks like you were misusing this feature by going too fast. You’ve been temporarily blocked from using it." Anyone using this may want to s/1000/2000/ on the first line.
- metadat 2y agoSafer bet: 5000ms.
- jazzyjackson 2y agoI got this message once without even trying, I was just clicking the button for "see why this ad was shown to you" and it was always "You are in the USA and 18-35" which seemed pretty vague for very relevant ads. I never understood why they give the option if A. you don't want me to actually check B. you're not going to tell me how you knew I was in the market for a vacuum cleaner
- ssss11 2y agoFor the facade of caring about user privacy - “look regulators, we even go so far as to tell you why you were shown ads!”
- exabrial 2y agoMath.floor(Math.random() * 1000) + 2000