Skip to content

Instantly share code, notes, and snippets.

@ryansinn
Last active August 29, 2015 14:07
Show Gist options
  • Save ryansinn/15f09ecb6c346045bd17 to your computer and use it in GitHub Desktop.
Save ryansinn/15f09ecb6c346045bd17 to your computer and use it in GitHub Desktop.
Facebook Activity Purge
// ==UserScript==
// @name FaceBook Activity Purge
// @namespace http://ryansinn.com/
// @include http://*.facebook.com/*/allactivity*
// @include https://*.facebook.com/*/allactivity*
// @require http://code.jquery.com/jquery-latest.js
// @version 1.2.2
// @description delete all FB Activity
// @author Ryan Sinn
// @match *://*.facebook.com/*/allactivity*
// ==/UserScript==
// version log
// 1.0 - automated
// rotates through purging comments and likes
// purging posts is disabled until I write the overlay code
//
// 1.1 - script compartmentalization
//
// 1.2 - start at any point in the timeline
// populate the start* variable with:
// yyyy -- to start at a year
// yyyy/mm -- to start at a specific month
// tested likes, interests, and comments -- successful
// more code tidying
//
//
//
// future versions
// 1.2 - get post purging with overlay confirmation prompt working
// 1.x - purge photos
// x.x - initiate by buttons
// x.x - code clean up into scripts
// global variables
// activeVariables are not used yet
var activePost = false;
var activeComment = true;
var activeLike = false;
var delayStart = "3000";
var delayScroll = "10000";
var delayOpen = "13000";
var delayPost = "18000";
var delayComment = delayPost;
var delayLike = delayPost;
var delayReload = (delayPost * 2);
var pathBase = "https://www.facebook.com/";
var pathUser = "ryan.sinn";
var pathPost = pathBase+pathUser+"/allactivity?privacy_source=activity_log&log_filter=cluster_11"; // this is broken now
var pathComment = pathBase+pathUser+"/allactivity?privacy_source=activity_log&log_filter=cluster_116";
var pathLike = pathBase+pathUser+"/allactivity?privacy_source=activity_log&log_filter=likedinterests";
var pathPhoto = pathBase+pathUser+"";
var pathTimeline = "/timeline/";
var elementMenu = ["i._2fmu", "._55pe"]; // not used right now
var buttonPost = "";
var buttonComment = "i._2fmu";
var buttonLike = "i._2fmu";
var matchPost = "log_filter=cluster_11";
var matchComment = "log_filter=cluster_116";
var matchLike = "log_filter=like";
var year = new Date().getFullYear();
var startPost = pathUser+pathTimeline+year;
var startLike = pathUser+pathTimeline+year;
var startComment = pathUser+pathTimeline+"2009";
// these pattern variables don't work as expected yet
var patternDelete = "Delete";
var patternUnlike = "Unlike";
var actionName = ""; // leave this blank
$( document ).ready(function()
{
// wait for jQuery to load up
// kick off the removal script wrapper function
console.log("removal starting...")
setTimeout(removeIt,delayStart)
})
function scrollIt()
{
// scroll down the page to get FB to load more content to purge
$('html, body').animate({scrollTop: $(document).height()}, 'slow')
console.log("Scrolled Down the Page...")
}
function openIt(elementClass)
{
elementClass = typeof elementClass !== 'undefined' ? elementClass : buttonComment;
$( elementClass ).trigger("click")
console.log("Opening menus matching "+elementClass+" ...")
}
function unpostIt() {
// run this from the YOUR POSTS activity pages
// Find all spans that say "Delete", and click them.
}
function uncommentIt() {
// Find all spans that say "Delete", and click them.
// run this from the YOUR POSTS or COMMENTS activity pages
actionName = "Deleting Comments";
dataArray = $("span:contains(Delete)");
console.log("Total "+actionName+" "+ dataArray.length)
// if there's nothing to do, switch to something else
if(dataArray.length === 0)
{
console.log("Nothing to do here... switching to something else.")
// likes
location.assign(pathLike)
}
$(dataArray).each(
// for each pattern match found do this
function( intIndex )
{
$( this ).trigger("click")
console.log( actionName+" # "+intIndex )
if( intIndex == (dataArray.length - 1) )
{
console.log( actionName+" some more!")
location.reload()
// location.assign(pathLike)
}
}
)
}
function unlikeIt() {
// Find all spans that say "unlike", and click them.
// run this from the PAGES and INTERESTS page "liked interests"
// run this from the YOUR POSTS or COMMENTS activity pages
actionName = "Deleting Likes";
dataArray = $("span:contains(Unlike)")
console.log("Total "+actionName+" "+ dataArray.length)
// if there's nothing to do, switch to something else
if(dataArray.length === 0)
{
console.log("Nothing to do here... switching to something else.")
// likes
location.assign(pathComment)
}
$(dataArray).each(
// for each pattern match found do this
function( intIndex )
{
$( this ).trigger("click")
console.log( actionName+" # "+intIndex )
if( intIndex == (dataArray.length - 1) )
{
console.log( actionName+" some more!")
location.reload()
// location.assign(pathComment)
}
}
)
}
function startHere(startValue)
{
linkList = $("a[href$='" + startValue + "']")
$(linkList).each(
function()
{ // the click isn't working right
$( this ).css("background-color","white")
$( this ).css("color","black")
$( this ).html("STARTING HERE")
var clickEvent = document.createEvent ('MouseEvents');
clickEvent.initEvent ('click', true, true);
this.dispatchEvent (clickEvent);
}
)
}
function removeIt() {
// This is the 'drop down' that exposes the post options of a post. Click them all.
// if we're on the comments activity page, run the delete comment function
if (window.location.href.indexOf(matchComment) > -1)
{
actionName = "Comment";
console.log("Starting "+actionName+" Search at "+startComment)
startHere(startComment);
setTimeout(openIt, delayOpen)
setTimeout(uncommentIt, delayComment)
}
// if we're on the like activity page, run the unlike function
if (window.location.href.indexOf(matchLike) > -1)
{
actionName = "Like";
console.log("Starting "+actionName+" Search at "+startComment)
startHere(startLike);
setTimeout(openIt, delayOpen)
setTimeout(unlikeIt, delayLike)
}
// setTimeout(function(){location.reload()}, delayReload)
// reloading the page to keep purging
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment