Skip to content

Instantly share code, notes, and snippets.

@moskytw
Last active May 23, 2019 09:00
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moskytw/3c2854817e3eb0927abeb534fff97f4f to your computer and use it in GitHub Desktop.
Save moskytw/3c2854817e3eb0927abeb534fff97f4f to your computer and use it in GitHub Desktop.
(function () {
const intervalMiliseconds = 10;
const waitToLoadMiliseconds = 1000;
const getUnsaveA = () => document.querySelector('.uiContextualLayerPositioner:not(.hidden_elem) li:last-child a');
const scrollToBottom = () => window.scrollTo(0, document.body.scrollHeight);
const unsaveAndLoad = (recursive) => {
const alpha = waitToLoadMiliseconds;
const beta = intervalMiliseconds;
const buttons = document.querySelectorAll('#saveContentFragment .clearfix [id^="saved-more-button"] button');
var i = 1;
Array.from(buttons).forEach(button => {
if(button.offsetParent === null) return;
setTimeout(() => button.click(), beta*i++);
setTimeout(() => getUnsaveA().click(), beta*i++);
});
setTimeout(scrollToBottom, beta*i);
if(recursive) setTimeout(() => unsaveAndLoad(true), beta*i+alpha);
};
if(confirm('Unsave?')) unsaveAndLoad(confirm('Unsave infinitely?'));
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment