Skip to content

Instantly share code, notes, and snippets.

@OverlordQ
Created September 5, 2018 17:54
Show Gist options
  • Save OverlordQ/56cb1a676e1a83c6cd5719b5f17728f1 to your computer and use it in GitHub Desktop.
Save OverlordQ/56cb1a676e1a83c6cd5719b5f17728f1 to your computer and use it in GitHub Desktop.
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;
} while((scrollY - prevScrollY) > 0 && (typeof maxScrolls === 'undefined' || numScrolls < maxScrolls));
var unblockButtons = $('div.user-actions.btn-group.blocked.not-muting > span.user-actions-follow-button.js-follow-btn.follow-button')
clickAll(unblockButtons);
}
function main() {
unblock(500, 10);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment