Last active
March 21, 2018 11:46
-
-
Save jbutz/1a23f7d9dcfefc5b288f2d12bc16058e to your computer and use it in GitHub Desktop.
Greasemonkey Scripts - #DeleteFacebook Albums
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Delete Facebook Albums | |
// @version 1 | |
// @grant none | |
// @match https://www.facebook.com/*/photos_albums | |
// @run-at document-idle | |
// ==/UserScript== | |
function promiseDelay(timeout) { | |
return new Promise((r) => { | |
setTimeout(() => r(), timeout); | |
}); | |
} | |
// Get menu elements | |
var menuDotsEls = Array.from(document.querySelectorAll('i.img')).filter((el) => el.innerText.indexOf('3-dots-h') >= 0); | |
function popAndRun() { | |
let dotEl = menuDotsEls.shift(); | |
if(!dotEl) return false; | |
dotEl.click(); | |
return promiseDelay(500) | |
.then(() => { | |
let deleteEls = Array.from(document.querySelectorAll('.__MenuItem a')).filter(el => el.innerText.indexOf('Delete album') >= 0); | |
if(deleteEls.length !== 1) return popAndRun(); | |
deleteEls[0].click(); | |
return promiseDelay(500) | |
.then(() => { | |
document.querySelector('.layerConfirm').click(); | |
}) | |
}) | |
} | |
popAndRun(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment