Skip to content

Instantly share code, notes, and snippets.

@romac
Created November 29, 2010 22:20
Show Gist options
  • Select an option

  • Save romac/720748 to your computer and use it in GitHub Desktop.

Select an option

Save romac/720748 to your computer and use it in GitHub Desktop.
A bookmarklet that will let you choose to hide or not the @replies on a Twitter timeline.
// You will find the draggable version there: http://bookmarklets.heroku.com/bookmarklets/1798
(
function( $ )
{
var removedTweets = [],
$button = null,
interval = null;
insertButton();
hideReplies();
function hideReplies()
{
if( !interval )
{
interval = window.setInterval( hideReplies, 250 );
}
// This could surely be improved by fetching only tweets containing an element with '.reply-icon'.
$( '.tweet-text:visible' ).each(
function()
{
var $this = $( this );
if( $.trim( $this.html() )[ 0 ] === '@' )
{
removedTweets.push(
$this.closest( '.stream-item' ).fadeOut( 'fast' )
);
}
}
);
}
function putRepliesBack()
{
window.clearInterval( interval );
interval = null;
for( var i = 0; i < removedTweets.length; i++ )
{
removedTweets[ i ].fadeIn( 'fast' );
}
removedTweets = [];
}
function insertButton()
{
$button = $( '<a id="rr-button" class="rr-put-back" href="#">Put @replies back</a>' );
$button.css(
{
position : 'fixed',
bottom : 0,
right : 0,
display : 'inline-block',
background : '#444',
color : '#FFF',
padding : '0px 5px',
textTransform : 'uppercase',
zIndex : 7800
}
);
$button.hover(
function()
{
$( this ).css( 'textDecoration', 'underline' );
},
function()
{
$( this ).css( 'textDecoration', 'none' );
}
);
$button.click( function()
{
if( $button.hasClass( 'rr-put-back' ) )
{
$button.html( 'Hide @replies' );
$button.removeClass( 'rr-put-back' ).addClass( 'rr-hide' );
putRepliesBack();
}
else
{
$button.html( 'Put @replies back' );
$button.removeClass( 'rr-hide' ).addClass( 'rr-put-back' );
hideReplies();
}
} );
$( 'body' ).append( $button );
}
}
)( jQuery );
@romac
Copy link
Author

romac commented Nov 29, 2010

Here is the draggable version: http://bookmarklets.heroku.com/bookmarklets/1798

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment