Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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]);
    }


Lol, 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.


I 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


For the facade of caring about user privacy - “look regulators, we even go so far as to tell you why you were shown ads!”


Math.floor(Math.random() * 1000) + 2000


Safer bet: 5000ms.


I 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 ...


clickAndWait is always good! :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: