Skip to content

Instantly share code, notes, and snippets.

@ankschoubey
Created January 13, 2019 07:39
Show Gist options
  • Save ankschoubey/db5b276c5953bcb6bb8a7c3dd5ca2453 to your computer and use it in GitHub Desktop.
Save ankschoubey/db5b276c5953bcb6bb8a7c3dd5ca2453 to your computer and use it in GitHub Desktop.
Pocket Automation (Delete articles that are either not 'Best of' or not star)
//Copy and paste this to developer console
function selectArticlesToDelete() {
var articles = document.getElementsByTagName('article');
var flag = false;
for (i = 0; i < articles.length; i++) {
article = articles[i];
if (article.getElementsByTagName('svg').length == 2 || article.textContent.includes('Best Of')) {
} else {
article.children[0].click();
flag = true;
}
}
return flag;
}
function deleteArticles() {
document.querySelectorAll('[data-tooltip="Delete"]')[0].click();
buttons = document.getElementsByTagName('button');
for (i = 0; i < buttons.length; i++) {
button = buttons[i];
if (button.innerText.includes('Delete Item')) {
button.click();
break;
}
}
}
function pocketDeleter() {
document.querySelectorAll('[data-tooltip="Bulk Edit"]')[0].click();
screen_height = window.screen.height;
for (height = 0; height < screen_height; height = height + 100) {
setTimeout(function () {
if (selectArticlesToDelete()) {
deleteArticles();
}
window.scrollBy(0, height)
}, 1000);
}
}
function pocketDeleter() {
screen_height = window.screen.height;
for (height = 0; height < screen_height + 100; height = height + 10) {
if (selectArticlesToDelete()) {
deleteArticles();
}
}
}
document.querySelectorAll('[data-tooltip="Bulk Edit"]')[0].click();
setInterval(function () {
pocketDeleter();
window.scrollBy(0, 200);
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment