Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

blocked-text class name no longer exists #7

Open
vvuk opened this issue Apr 22, 2022 · 2 comments
Open

blocked-text class name no longer exists #7

vvuk opened this issue Apr 22, 2022 · 2 comments

Comments

@vvuk
Copy link

vvuk commented Apr 22, 2022

the blocked-text class name is no longer used; however, replacing the getElementsByClassName with document.querySelectorAll('div[role="button"][aria-label="Blocked"]') seems to work. Twitter also no longer keeps all the elements on the page as you scroll, so it's necessary to unblock in a loop.

@vvuk
Copy link
Author

vvuk commented Apr 22, 2022

Currently using

async function unblock(timeoutMs, maxScrolls) {
    var prevScrollY;
    var scrollY = window.scrollY;
    var numScrolls = 0;
    do {
        window.scrollTo(0,document.body.scrollHeight);
        numScrolls++;
        prevScrollY = scrollY;
        await sleep(timeoutMs);
        scrollY = window.scrollY;

        var unblockButtons = document.querySelectorAll('div[role="button"][aria-label="Blocked"]');
        clickAll(unblockButtons);
    } while((scrollY - prevScrollY) > 0 && (typeof maxScrolls === 'undefined' || numScrolls < maxScrolls));
}

(no confirmation)

@AK47dev1
Copy link

Great! Works like a charm :)
So the whole code is as follows:

function sleep(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
}

function clickAll(buttons) {
    for (i = 0; i < buttons.length; i++) {
        buttons[i].click();
    }
}

async function unblock(timeoutMs, maxScrolls) {
    var prevScrollY;
    var scrollY = window.scrollY;
    var numScrolls = 0;
    do {
        window.scrollTo(0,document.body.scrollHeight);
        numScrolls++;
        prevScrollY = scrollY;
        await sleep(timeoutMs);
        scrollY = window.scrollY;

        var unblockButtons = document.querySelectorAll('div[role="button"][aria-label="Blocked"]');
        clickAll(unblockButtons);
    } while((scrollY - prevScrollY) > 0 && (typeof maxScrolls === 'undefined' || numScrolls < maxScrolls));
}

function main() {
    unblock(500);
}

main()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants