Wednesday, October 31, 2012

Un-follow All Twitter Followings

My Twitter account was hacked.  I'm think I read about a Twitter breach at some time, or maybe I had a weak password.  I also ignored the weird follower & following emails I was getting.  Its my own fault, but I just wasnt worried about it.

I decided to check out a new Twitter App on Android today.  When I logged in, I saw all kinds of weird posts that I hadnt made, followers I'd never heard of, and over 1k of people I was following - I think I was following 2 people when I had previously checked.

So I changed my password, deleted the bogus tweets and then moved on to address the 1k of people I was following.  Turns out, this is kind of difficult.  There are some pay apps you can do it with, or you can click through all of the people and unfollow.  Awesome....

I had an idea.  Since the twitter page will load all of my people as I scroll, I could write something that walked the DOM and handled this issue for me.  I assumed Twitter had jQuery installed, so I opened up Firebug's console and hacked it together.

Here is the Javascript :

$("span.button-text.following-text").each(function(iIndex, oElement){
    var oElement = $(oElement);
    if (oElement.css("display") != "none"){
        oElement.click();
    }
})

The script will only click on the buttons with "Following" in the text, so you dont have to scroll all the buttons into view at once.  You also dont have to worry about it toggling the buttons.

Done.  If anyone from Twitter reads this, it would be nice if you guys provided a feature for this.