// ==UserScript==
// @name           Twitter Friends Following
// @namespace      greasemonkey.hubkey.com
// @description    Identifies whether Twitter users you follow are following you in return.
// @include        http://twitter.com/*following*
// @include        https://twitter.com/*following*
// @include        http://twitter.com/*friends*
// @include        https://twitter.com/*friends*
// ==/UserScript==
 
twitter_friends_following = {
    count: 0,
 
    identify: function() {
    	debugger;
        var afollowers = document.getElementsByClassName('direct-messageable');
        for (var i = 0; i < afollowers.length; i++) {
            var avcard = afollowers[i].getElementsByClassName('about vcard');
            if (avcard.length != 1)
                continue;
            var node = document.createElement('span');
            node.setAttribute('class', 'is-following');
            node.innerHTML = '<i></i><strong>Following</strong>';
            avcard[0].appendChild(node);
        }
 
        try {
            twitter_friends_following.count = document.getElementsByClassName('direct-messageable').length;
        } catch (e) {
            twitter_friends_following.count = 0;
        }
    },
 
    monitor: function() {
        if (document.getElementsByClassName('direct-messageable').length != twitter_friends_following.count)
            twitter_friends_following.identify();
 
        setTimeout(twitter_friends_following.monitor, 200);
    }
};
 
setTimeout(twitter_friends_following.monitor, 200);


