Skip to content

Instantly share code, notes, and snippets.

@avidal
Last active February 7, 2017 15:47
Show Gist options
  • Save avidal/26d68dc5665472dc3750a66b3f9bf8a1 to your computer and use it in GitHub Desktop.
Save avidal/26d68dc5665472dc3750a66b3f9bf8a1 to your computer and use it in GitHub Desktop.
public snippets
/* Remove facebook photos
Just run the below snippet on the console after browsing to Your Photos (click Photos, then Your Photos)
It kind of works on videos with a couple of caveats: need to change data-action-type to delete_video,
and change contains('button') to select 'Confirm' instead of 'Delete'
However, FB reloads the page after removing each video so it can't be run in a loop
*/
function contains(selector, text) {
var elements = document.querySelectorAll(selector);
return Array.prototype.filter.call(elements, function(element){
return RegExp(text).test(element.textContent);
});
}
var timer = setInterval(() => {
document.querySelector('a[data-tooltip-content="Edit or Remove"]').click();
setTimeout(() => {
document.querySelector('a[data-action-type=delete_photo]').click();
setTimeout(() => {
contains('button', 'Delete')[0].click();
}, 1000);
}, 1000);
}, 3000);
// run clearInterval(timer) when it's done
// to delete a video, run this snippet. You'll need to run these one at a time unfortunately because of the forced page reload
function contains(selector, text) {
var elements = document.querySelectorAll(selector);
return Array.prototype.filter.call(elements, function(element){
return RegExp(text).test(element.textContent);
});
}
document.querySelector('a[data-tooltip-content="Edit or Remove"]').click();
setTimeout(() => {
document.querySelector('a[data-action-type=delete_video]').click();
setTimeout(() => {
contains('button', 'Confirm')[0].click();
}, 1000);
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment