Skip to content

Instantly share code, notes, and snippets.

@jameswomack
Created July 19, 2014 09:46
Show Gist options
  • Save jameswomack/eb1e8040f9cb48b7efea to your computer and use it in GitHub Desktop.
Save jameswomack/eb1e8040f9cb48b7efea to your computer and use it in GitHub Desktop.
Filter Tweets on your Twitter profile page based on the amount of favorites they've received.
var kStatCount = 'data-tweet-stat-count';
var kScreenName = 'data-screen-name';
var kProfileTweet = '.ProfileTweet';
jQuery.fn.extend({
statCount: function() {
return parseInt(this.attr(kStatCount));
},
statCountIsGreaterThan: function(n) {
return this.statCount() > n;
},
isFromCurrentUserPage: function(n) {
var screenNameFromURL = location.pathname.substr(1);
return this.closest(kProfileTweet).attr(kScreenName) === screenNameFromURL;
}
});
$('button['+kStatCount+']').filter(function(){
var $button = $(this);
var tweetHasMoreThan2Faves = $button.statCountIsGreaterThan(2);
var tweetIsFromCurrentUser = $button.isFromCurrentUserPage();
return tweetHasMoreThan2Faves && tweetIsFromCurrentUser;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment