<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Conroyp.com</title>
	<atom:link href="http://www.conroyp.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.conroyp.com</link>
	<description>Technically speaking</description>
	<lastBuildDate>Sat, 13 Mar 2010 12:17:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>DeClutter</title>
		<link>http://www.conroyp.com/2010/03/11/declutter/</link>
		<comments>http://www.conroyp.com/2010/03/11/declutter/#comments</comments>
		<pubDate>Thu, 11 Mar 2010 21:23:51 +0000</pubDate>
		<dc:creator>Paul</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[bookmarklet]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.conroyp.com/?p=46</guid>
		<description><![CDATA[Twitter can be a very useful tool, particularly once you've built up a decent-sized network of people with interests common to your own. The twitter timeline is often compared to being in a pub filled exclusively with your friends, and being able to hear all of the conversations going on at once.
However, just as you [...]]]></description>
			<content:encoded><![CDATA[<p>Twitter can be a very useful tool, particularly once you've built up a decent-sized network of people with interests common to your own. The twitter timeline is often compared to being in a pub filled exclusively with your friends, and being able to hear all of the conversations going on at once.</p>
<p>However, just as you have that friend who occasionally likes to go in to excrutiating detail about his collection of porcelain squirrels, there are times when your interests diverge and you'd rather not hear the full details of next weekend's Porcelainathon. And so it is with Twitter.</p>
<p>Once you've started following more than a handful of people, you'll occasionally find your timeline filling up with tweets about things that you're really not that interested in. You'd rather not take the nuclear option and unfollow those involved, as they generally have interesting/useful tweets. But equally you'd rather not have to scroll through 3 pages of automated tweets about foursquare checkins, app downloads and the like.</p>
<p>&nbsp;</p>
<h3>Enter DeClutter</h3>
<p>DeClutter is a javascript bookmarklet which will remove from your timeline any tweets which match a "blacklist" of keywords you've defined. </p>
<p>Below you can enter a series of terms which you want to banish from your timeline (one term per line). After entering them, you can either copy and paste the resulting javascript in to a bookmarklet in your browser, or drag the DeClutter link at the bottom of the page to your browser's bookmarks bar.<br />
<span id="more-46"></span><br />
Once it has been saved, log on to twitter.com and click your new bookmarklet. Straight away you should see tweets disappearing from the timeline. This filter can re-apply itself automatically in the background, so you don't need to re-click the bookmarklet whenever you refresh your timeline by clicking "@ replies", "more", saved searches, etc.<br />
You can specify how often the bookmarklet should re-run below, default value is every 5 seconds. Depending on the age and decrepitude of your browser, turning this feature on may cause memory to like a sieve. So if you're running IE6, it's probably best to leave this option off.</p>
<p>&nbsp;</p>
<h3>Customise DeClutter</h3>
<p>Enter words or phrases you wish to banish from your timeline below. Alternatively, you can try one of the below general category links to get you started!<br />
<a href="#txtFilter" onclick="jQuery('#txtFilters').val('mufc\nlfc\nrooney\nchelsea\ndrogba\ngoal\nkeane\ntorres\ngerrard\nronaldo').trigger('keyup');">Sport</a> | <a href="#txtFilter" onclick="jQuery('#txtFilters').val('fianna\nfine gael\nsinn fein\ndail\ndáil\nlenihan\ncowen\nharney\ngilmore\ninda').trigger('keyup');">Irish Politics</a> | <a href="#txtFilter" onclick="jQuery('#txtFilters').val('ps3\nxbox\npsp\nnintendo\nwii').trigger('keyup');">Computer games</a> | <a href="#txtFilter" onclick="jQuery('#txtFilters').val('foursquare\nxboxtweet\nmacheist\nmr. tweet').trigger('keyup');">Auto-tweets</a></p>
<p><script type="text/javascript">
var filters = Array();
var repoller = 5000;
jQuery(document).ready(function(){
    // Catch default values..
    filters = jQuery('#txtFilters').val().trim().split("\n");
    updateBookmarklet();
    var jInput = jQuery( "#txtin" );
    jQuery( "#txtFilters" ).keyup(
        function(){
            filters = jQuery(this).val().trim().split("\n");
            updateBookmarklet();
        }
    );
    jQuery( "#repoll" ).keyup(
        function(){
            repoller = jQuery(this).val().trim() * 1000;
            updateBookmarklet();
        }
    );
});
var bkmrkFirst = "javascript:void(declutter());function declutter(){";
var bkmrkLast = "$.each($('.hentry'), function(){var c = $(this).html(); var p = $(this); $.each(rk, function(i, v){ if(c.toLowerCase().indexOf(v) > 0){p.remove();}});});";
function updateBookmarklet()
{
    var conds = Array();
    var fcon = Array();
    var str = '';
    jQuery.each(filters, function(){
        fcon.push(this.toLowerCase().replace(/[']/, "\\\'"));
    });
    timerStr = '';
    if(repoller > 0)
    {
        timerStr = "setTimeout('declutter()', "+repoller+");";
    }
    var htmlin = bkmrkFirst+"var rk=['"+fcon.join("', '")+"'];"+bkmrkLast+timerStr+'}';
    jQuery('#bkmrk').html(htmlin);
    jQuery('#quickLink').attr('href', htmlin);    
}
</script></p>
<p>Enter keywords below:<br />
<textarea id="txtFilters" class="inputFilters" cols="30" rows="4">Crystal Swing</textarea></p>
<p>Enter the number of seconds between re-runs (0 to turn off):<br />
<input type="text" id="repoll" value="5" size="2" /> (seconds)</p>
<p>&nbsp;</p>
<h3>Your bookmarklet</h3>
<p>The text below will automatically update as you enter keywords above. When you're done adding, copy the below text in to a new bookmarklet.</p>
<div id="bkmrk" style='width:400px;font-size:12px;font-face:Courier;line-height:16px;padding:2px;border:1px dotted grey;'>&nbsp;</div>
<p>Alternatively, drag this <a id="quickLink">DeClutter bookmarklet</a> to your browser's bookmark bar.</p>
<p>&nbsp;</p>
<h3>What now?</h3>
<p>After dragging the bookmarklet to your browser's bookmark bar, log in to twitter.com, click it and that's all there is to it!</p>
<p>If you've got any suggestions for refinements to this bookmarklet, let me know in the comments below. Equally, feel free to share your own list of keyword filters for inclusion on the category list above!</p>
<p>&nbsp;</p>
<h3>The Tech Bit</h3>
<p>The twitter web interface presents the timeline as a styled list. Each list element has a number of classes, chief amongst them "hentry".<br />
The declutter function inside the bookmarklet loops through all elements with the class "hentry" on the currently-visible page, then checks whether any of the blacklisted keywords are present in the html of that element.</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #003366; font-weight: bold;">function</span> declutter<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// Remove tweets containing these terms!</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> rk<span style="color: #339933;">=</span><span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'crystal swing'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// Twitter timeline entries have class &quot;hentry&quot; - loop through them, </span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// removing those that match blacklisted term</span><br />
&nbsp; &nbsp; $.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.hentry'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> c <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> p <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// Iterate through the keywords, removing the parent element </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// where a match is found</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; $.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span>rk<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">,</span> v<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// Lower-case the text so case issues don't trip us up</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>c.<span style="color: #660066;">toLowerCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span>v.<span style="color: #660066;">toLowerCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> 0<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; p.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// Call this function again in 5 seconds (5000ms)</span><br />
&nbsp; &nbsp; setTimeout<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'declutter()'</span><span style="color: #339933;">,</span> 5000<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>&nbsp;</p>
<h3>FAQ</h3>
<p>- <i>Will I still see the hidden tweets if I use Tweetie/Echofon/Twitter API?</i><br />
Yes, this bookmarklet only affects the web interface to twitter.</p>
<p>- <i>Will this bookmarklet automatically run every time I visit twitter.com?</i><br />
If you have closed your browser or the tab in which you first ran the bookmarklet, then you will need to start it again.</p>
<p>- <i>On which browsers have you tested this?</i><br />
It's been tested in the latest versions of Firefox, IE &#038; Chrome. If you're using an earlier version of any of these, it *should* work, but YMMV. If it fails horribly in earlier browsers, let me know via the comments below and I'll see about updating it.</p>
<p>- <i>You say 'bookmarklet' a lot. What is that?</i><br />
A bookmarklet is a small application, stored as the URL of a bookmark in a web browser or as a hyperlink on a web page, or so sayeth <a href="http://en.wikipedia.org/wiki/Bookmarklet">the wiki</a>.</p>
<p>- <i>Hmm. I think there's a better way of doing this</i><br />
This has been hacked together very quickly using a few basic jQuery functions, I'm sure there's plenty of room for improvement! If you've got suggestions for improvement, let me know via the comments below.</p>
<p>- <i>How very Web2.0 - why didn't you call it DeCluttr?</i><br />
I did originally, then discovered that the name had already <a href="http://www.decluttr.com">been taken</a>. After that I tried to come up with a catchy new name, but <a href="http://blog.stackoverflow.com/2009/03/it-stack-overflow-update-naming-is-hard/">naming things is hard</a>.</p>
<p>- <i>You should have some pictures on this post. I like pictures.</i><br />
That's not really a question. Still, if you must, <a href="http://gallery.mtbr.com/data/mtbr/500/orson_welles.gif">have an image</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.conroyp.com/2010/03/11/declutter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
