<?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 &#187; twitter</title>
	<atom:link href="http://www.conroyp.com/tags/twitter/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.conroyp.com</link>
	<description>Technically speaking</description>
	<lastBuildDate>Sun, 29 Jan 2012 20:20:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.4</generator>
		<item>
		<title>Extending Twitter &#8211; adding Imgur previews</title>
		<link>http://www.conroyp.com/2010/11/30/extending-twitter-web-interface-adding-imgur-previews/</link>
		<comments>http://www.conroyp.com/2010/11/30/extending-twitter-web-interface-adding-imgur-previews/#comments</comments>
		<pubDate>Tue, 30 Nov 2010 09:22:46 +0000</pubDate>
		<dc:creator>Paul</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[bookmarklet]]></category>
		<category><![CDATA[imgur]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.conroyp.com/?p=329</guid>
		<description><![CDATA[Update 08/12/2010 - There's now a Firefox Extension in the Add-Ons sandbox available for adding this media preview to Twitter, as well as previews for Daft.ie and Adverts.ie ads. With their recent site redesign, Twitter added a number of interesting new features. One of the more useful of these is the media preview. From the [...]]]></description>
			<content:encoded><![CDATA[<div class="clear"></div>
<div id="attachment_335" class="wp-caption aligncenter" style="width: 460px"><a href="http://www.conroyp.com/wp-content/uploads/2010/11/imgur1.jpg"><img src="http://www.conroyp.com/wp-content/uploads/2010/11/imgur1-1024x275.jpg" alt="Imgur Preview" title="Imgur Preview" width="450" class="size-large wp-image-335" /></a><p class="wp-caption-text">Enabling Imgur preview in Twitter</p></div>
<p><b>Update 08/12/2010 - There's now a <a href="https://addons.mozilla.org/en-US/firefox/addon/261946/">Firefox Extension</a> in the Add-Ons sandbox available for adding this media preview to Twitter, as well as previews for Daft.ie and Adverts.ie ads.</b></p>
<p>With their recent site redesign, Twitter added a number of interesting new features. One of the more useful of these is the media preview. From the <a href="http://blog.twitter.com/2010/09/better-twitter.html">Twitter blog</a>:</p>
<blockquote><p><b>Media</b>. Now, it’s easy to see embedded photos and videos directly on Twitter, thanks to partnerships with DailyBooth, deviantART, Etsy, Flickr, Justin.TV, Kickstarter, Kiva, Photozou, Plixi, Twitgoo, TwitPic, TwitVid, USTREAM, Vimeo, yfrog, and YouTube.
</p></blockquote>
<p>This is definitely one of the more useful features of the new Twitter web interface, and covers most of the more mainstream media sources that I'd notice showing up in my timeline. That said, there are some notable omissions..<br />
<span id="more-329"></span></p>
<h3>Imgur.com</h3>
<p>Anyone who has spent any time on <a href="http://reddit.com">reddit</a> will be familiar with the image hosting service <a href="http://imgur.com">imgur.com</a>. Run by redditor <a href="http://www.reddit.com/user/MrGrim">MrGrim</a>, a quick browse through any of the more popular sub-reddits show how ubiquituous it has become for media sharing on reddit. It would be very handy if tweets mentioning imgur had the same preview functionality as those mentioning twitpic, yfrog, etc. I've recently been digging through the new Twitter javascript whilst working on a <a href="http://www.conroyp.com/2010/03/11/declutter/">Declutter</a> followup, so decided to take a break from that and see how hard it would be to bolt on imgur previewing to the web interface. </p>
<p>Luckily, it turned out to be very straight-forward indeed, and can be done with one simple bookmarklet!</p>
<p>If you're not interested in the technical nuts and bolts behind it, you can skip ahead to <a href="#get">get the bookmarklet now</a>. Otherwise, read on for a bit more technical explanation on the ins and outs of adding a custom media type to Twitter.</p>
<h3>Ur Img, My Img, Everybody's Img..</h3>
<p>The recent rewrite of <a href="http://twitter.com/">Twitter.com</a> pushed a huge additional amount of their logic in to javascript on the client side. My thinking was that the imgur preview functionality should work the same as the twitpic previewing. Taking a look through the <a href="http://a4.twimg.com/a/1290538325/javascripts/phoenix.bundle.js">main application logic</a> for twitpic, we can see the declaration of</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 /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">twttr.<span style="color: #660066;">media</span>.<span style="color: #660066;">types</span></div></td></tr></tbody></table></div>
<p>Below is how we clone the twitpic media type, then tweak for imgur:</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><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 /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">twttr.<span style="color: #660066;">mediaType</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;twttr.media.types.Imgur&quot;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">,</span><span style="color: #009900;">&#123;</span>icon<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;photo&quot;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #339933;">,</span>domain<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;http://imgur.com&quot;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #339933;">,</span>matchers<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span>media<span style="color: #339933;">:/</span>imgur.<span style="color: #660066;">com</span>\<span style="color: #339933;">/</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>a<span style="color: #339933;">-</span>zA<span style="color: #339933;">-</span>Z0<span style="color: #339933;">-</span><span style="color: #CC0000;">9</span>\.<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span>g<span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #339933;">,</span>process<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>A<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #006600; font-style: italic;">// If link is http://imgur.com, ext usually missing</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">slug</span>.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">slug</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">slug</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'.jpg'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">data</span>.<span style="color: #660066;">src</span><span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">slug</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">data</span>.<span style="color: #000066;">name</span><span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">constructor</span>._name<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;A<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #339933;">,</span>render<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>B<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #003366; font-weight: bold;">var</span> A<span style="color: #339933;">=</span><span style="color: #3366CC;">'&lt;div class=&quot;twitpic&quot;&gt;&lt;a class=&quot;inline-media-image&quot; data-inline-type=&quot;{name}&quot; href=&quot;http://i.imgur.com/{src}&quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;http://i.imgur.com/{src}&quot; /&gt;&lt;/a&gt;'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$<span style="color: #009900;">&#40;</span>B<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span>twttr.<span style="color: #660066;">supplant</span><span style="color: #009900;">&#40;</span>A<span style="color: #339933;">,</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000066; font-weight: bold;">void</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>The two key bits of code above are "matchers" and "render". Matchers specifies a regex which Twitter uses to detect whether there are any imgur links within a given tweet. The pattern of imgur urls are generally http://[OPTIONAL_DOMAIN].imgur.com/abcDEF819.jpg, although they're also accessible via http://imgur.com/abcDEF819 (note lack of extension!). The regex we use is:</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 /></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: #339933;">,</span>matchers<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span>media<span style="color: #339933;">:/</span>imgur.<span style="color: #660066;">com</span>\<span style="color: #339933;">/</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>a<span style="color: #339933;">-</span>zA<span style="color: #339933;">-</span>Z0<span style="color: #339933;">-</span><span style="color: #CC0000;">9</span>\.<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span>g<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>Whatever is matched by the ([a-zA-Z0-9\.]+) part of the regex above gets saved in this.slug. We don't care what the optional domain is or if it even exists - we'll ultimately be using i.imgur.com as the host, as it gives direct access to an image. If no file extension is found, we'll stick on a ".jpg". Not ideal, but works in the vast majority of cases. In the process function, this slug is assigned to data.src for convenience during rendering.</p>
<p>Next up is the rendering of the matched data. We're piggy-backing on the twitpic version of this function here as we're essentially trying to achieve the same end goal. The basic html structure of the media preview is div -> href -> img. The twitpic structure is replicated in a var here, which then gets injected in to the expanded tweet pane to give the media preview.</p>
<h3 id="get">Get the bookmarklet!</h3>
<p>All of the above gives us a Twitter bookmarklet for <a href="javascript:twttr.mediaType('twttr.media.types.Imgur',{icon:'photo',domain:'http://imgur.com',matchers:{media:/imgur.com\/([a-zA-Z0-9\.]+)/g},process:function(A){ if(this.slug.indexOf('.') < 0) this.slug = this.slug + '.jpg';this.data.src=this.slug; this.data.name=this.constructor._name; A() } ,render:function(B) { var A='
<div class=\'twitpic\'><img src=\'http://i.imgur.com/{src}\' /'+'/>'; $(B).append(twttr.supplant(A,this.data))}});void(0);">Imgur previews</a>.</p>
<div id="attachment_354" class="wp-caption alignright" style="width: 246px"><a href="http://www.conroyp.com/wp-content/uploads/2010/11/preview_added.png"><img src="http://www.conroyp.com/wp-content/uploads/2010/11/preview_added.png" alt="" title="Preview Added" width="236" height="75" class="size-full wp-image-354" /></a><p class="wp-caption-text">Preview added successfully</p></div>
<p>Simply drag the above link to your browser's bookmark bar, click it when next on Twitter.com and any future tweets with imgur.com should now have a media preview enabled!</p>
<p>The quickest way to check that it's working right is to do a twitter search for "imgur.com", and the media icons should then be shown against the resulting tweets.</p>
<h3>FAQ</h3>
<p><em>- I've applied the bookmarklet, but the imgur links in my timeline still aren't showing a preview</em><br />
This bookmarklet works for any new imgur links which show up after you apply it. Not ideal, but it's a start. The next version should apply itself retrospectively to any previously-loaded tweets.</p>
<p><em>- Wait, a bookmarklet? What is that?</em><br />
A bookmarklet is a small chunk of javascript that allows us to extend the functionality of a given page. See <a href="http://www.conroyp.com/2010/04/04/bookmarklets-a-quick-explanation/">this explanation</a> for a bit more detail.</p>
<p><em>- Bookmarklets are a pain to use, having to re-apply them is annoying</em><br />
True and true. This was more an exercise in seeing how readily extensible the twitter javascript was. Ultimately the plan is to roll this bookmarklet and the various Declutter ones up in to a chrome/firefox extension that is automatically applied on page load.<br />
<b>Update 08/12/2010 - basic Firefox extension to enable this media preview is now available in the <a href="https://addons.mozilla.org/en-US/firefox/addon/261946/">Add-Ons sandbox</a>. This extension also previews Daft.ie and Adverts.ie content</b>.</p>
<div style="padding-top:5px;padding-right:0px;padding-bottom:5px;padding-left:0px;;">
											<iframe
												style="height:25px !important; border:0px solid gray !important; overflow:hidden !important; width:550px !important;" frameborder="0" scrolling="no" allowTransparency="true"
												src="http://www.linksalpha.com/social?blog=Conroyp.com&link=http%3A%2F%2Fwww.conroyp.com%2F2010%2F11%2F30%2Fextending-twitter-web-interface-adding-imgur-previews%2F&title=Extending+Twitter+-+adding+Imgur+previews&desc=%5Bcaption+id%3D%22attachment_335%22+align%3D%22aligncenter%22+width%3D%22450%22+caption%3D%22Enabling+Imgur+preview+in+Twitter%22%5D%5B%2Fcaption%5D%0D%0A%0D%0AUpdate+08%2F12%2F2010+-+There%27s+now+a+Firefox+Extension+in+the+Add-Ons+sandbox+availa&fc=333333&fs=arial&fblname=like&fblref=facebook&fbllang=en_US&fblshow=1&fbsbutton=1&fbsctr=1&fbslang=en&fbsendbutton=0&twbutton=1&twlang=en&twmention=conroyp&twrelated1=&twrelated2=&twctr=1&lnkdshow=show&lnkdctr=1&buzzbutton=0&buzzlang=en&buzzctr=1&diggbutton=0&diggctr=1&stblbutton=0&stblctr=1&g1button=1&g1ctr=1&g1lang=en-US">
											</iframe>
										</div>]]></content:encoded>
			<wfw:commentRss>http://www.conroyp.com/2010/11/30/extending-twitter-web-interface-adding-imgur-previews/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>DeCluttering Twitter, Part Deux</title>
		<link>http://www.conroyp.com/2010/03/20/decluttering-twitter-part-deux/</link>
		<comments>http://www.conroyp.com/2010/03/20/decluttering-twitter-part-deux/#comments</comments>
		<pubDate>Sat, 20 Mar 2010 19:46:42 +0000</pubDate>
		<dc:creator>Paul</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[bookmarklet]]></category>
		<category><![CDATA[hovercard]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.conroyp.com/?p=123</guid>
		<description><![CDATA[If you're just here to learn how to kill the Twitter Hovercards, then drag the Hovercard Removal bookmarklet to your browser's bookmarks bar, go twitter.com, click it and you're done! Read on if you're in any way curious about the technical errata behind this.. Most of my twitter usage comes via applications that makes use [...]]]></description>
			<content:encoded><![CDATA[<p><b>If you're just here to learn how to kill the Twitter Hovercards, then drag the <a href="javascript:twttr.HOVERCARD.disable();$('ul.sidebar-menu a').bind('click', function(e) {twttr.HOVERCARD.disable();});$('#home_link, #logo').attr('data', '{\'dispatch_action\':\'home\'}');$('#home_link, #logo').addClass('in-page-link');$('.in-page-link').isInPageLink();$('#results_update').text('Hovercards removed succesfully').show();void(0);">Hovercard Removal</a> bookmarklet to your browser's bookmarks bar, go twitter.com, click it and you're done!<br />
Read on if you're in any way curious about the technical errata behind this..</b></p>
<p>Most of my <a href="http://twitter.com/conroyp">twitter</a> usage comes via applications that makes use of the API, such as Tweetie on the iPhone or the Echofon plugin for Firefox. However, I still spend a considerable amount of my time a-tweetin' via the web interface.</p>
<p>For the most part, twitter's web interface is reasonably clean, but there are still a few niggly bits that I'd rather do without. Luckily, one of the beauties of the web interface is that it allows the usage of bookmarklets, so if there's something you don't like, a quick line of javascript in the browser's address bar will sort it out!</p>
<p>I've <a href="http://www.conroyp.com/2010/03/11/declutter/">written previously</a> about using bookmarklets to hide tweets from your timeline that contain blacklisted words (sport-related, xbox achievements, etc). The next step is now to use bookmarklets to tweak the web interface itself. A nice side-effect of Twitter's use of jQuery for the web interface is that all of the jQuery selectors and functions are available to us, should we need them. </p>
<p>We'll start by hiding the Hovercard!<br />
<span id="more-123"></span></p>
<p>&nbsp;</p>
<h3>Hiding the Hovercard</h3>
<p>Twitter recently launched <a href="http://blog.twitter.com/2010/02/flying-around-with-hovercards.html">"Hovercards"</a> on the web interface. According to the blog announcement, hovercards are:</p>
<blockquote><p>cards which appear when you hover over a username or avatar. The cards display additional information about the person and allow you to interact with them while staying within the context of your page.</p></blockquote>
<div id="attachment_130" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.conroyp.com/wp-content/uploads/2010/03/boosh-screenshot2.jpg"><img class="size-medium wp-image-130" title="Twitter Hovercards" src="http://www.conroyp.com/wp-content/uploads/2010/03/boosh-screenshot2-300x108.jpg" alt="" width="300" height="108" /></a><p class="wp-caption-text">Hovercards (via Twitter blog)</p></div>
<p>All good and well, and potentially useful. However, whenever I move my  mouse up, down or across my timeline, these hovercards are springing up  and obscuring other tweets in the timeline. Personally, I've been  finding this feature far more annoying than useful, so would like to  turn it off.</p>
<p>Fortunately, twitter have a very handy javascript function call available to do just that:</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 /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">twttr.<span style="color: #660066;">HOVERCARD</span>.<span style="color: #660066;">disable</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>So, sticking</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 /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">javascript<span style="color: #339933;">:</span>twttr.<span style="color: #660066;">HOVERCARD</span>.<span style="color: #660066;">disable</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000066; font-weight: bold;">void</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>in to the browser's address bar will stop these hovercards from appearing again on the main timeline. So far, so good.</p>
<p>However, once any of the links on the right side of the interface are clicked ("@ replies", "Retweets", etc), then suddenly the hovercards are back in force. Now we need to ensure that the hovercards are disabled whenever these links are clicked. We can do this by attaching the disable() call to the click event for any of these links on the sidebar.</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 /></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: #009900;">&#40;</span><span style="color: #3366CC;">'ul.sidebar-menu a'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; twttr.<span style="color: #660066;">HOVERCARD</span>.<span style="color: #660066;">disable</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>One unfortunate limitation of bookmarklets is that their effect only lasts while you stay on the same page - if you hit F5 or reload the page in any way, they need to be re-applied. For most of the links on the twitter web interface, this isn't an issue as they reload dynamically without refreshing the whole page (@ Replies, Direct Messages, etc). </p>
<p>However, somewhat erratically, the "Home" link and twitter logo at the top of the page both link to twitter.com in the traditional fashion. Clicking either of these out of habit to reload the page will mean that the effect of the bookmarklet is lost, and it must be re-applied. </p>
<p>This is a bit of a pain, so instead we will use the bookmarklet to make both of these links behave the same way as the "Home" link on the right hand sidebar.</p>
<p>Looking at the source of the twitter homepage, there are two things on each of the sidebar links which cause them to load content in situ, rather than requiring the browser to load a whole new page:</p>
<ul>
<li>A dispatch_action attached to a data attribute</li>
<li>The class in-page-link</li>
</ul>
<p>So we adjust our bookmarklet to add the same dispatch_action to the data attribute of the main logo link (id #logo) and the "Home" link at the top of the page (id #home_link). We want them to behave the same way as the "Home" link in the sidebar, so we assign the same data action.</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 /></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: #009900;">&#40;</span><span style="color: #3366CC;">'#home_link, #logo'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'data'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'{<span style="color: #000099; font-weight: bold;">\'</span>dispatch_action<span style="color: #000099; font-weight: bold;">\'</span>:<span style="color: #000099; font-weight: bold;">\'</span>home<span style="color: #000099; font-weight: bold;">\'</span>}'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>Next we need to add the appropriate class, in-page-link. However, adding this class alone won't do anything. On initial page load, jQuery applies a handler to each link of this type which causes the opening of links without the need for a full page refresh. We need to re-call this function so that it is applied to our newly-classed links.</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 /></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: #009900;">&#40;</span><span style="color: #3366CC;">'#home_link, #logo'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'in-page-link'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.in-page-link&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">isInPageLink</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>Finally, we want some visual confirmation that this has all worked as planned! We can re-use twitter's notification bar to display a success message.</p>
<div id="attachment_131" class="wp-caption aligncenter" style="width: 510px"><a href="http://www.conroyp.com/wp-content/uploads/2010/05/hovercards_applied.png"><img class="size-medium wp-image-130" title="Twitter Hovercards removed" src="http://www.conroyp.com/wp-content/uploads/2010/05/hovercards_applied.png" alt="Hovercards removed successfully!"" width="500" /></a><p class="wp-caption-text">Hovercards removed successfully!</p></div>
<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 /></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: #009900;">&#40;</span><span style="color: #3366CC;">'#results_update'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Hovercards removed succesfully'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>Combining all of this in to a single bookmarklet gives us <a href="javascript:twttr.HOVERCARD.disable();$('ul.sidebar-menu a').bind('click', function(e) {twttr.HOVERCARD.disable();});$('#home_link, #logo').attr('data', '{\'dispatch_action\':\'home\'}');$('#home_link, #logo').addClass('in-page-link');$('.in-page-link').isInPageLink();$('#results_update').text('Hovercards removed succesfully').show();void(0);">Hovercard removal</a>. Drag this to your browser's toolbar then click it when logged in to twitter.com, and hovercards shall be no more.</p>
<p>Other quick-and-dirty bookmarklets:</p>
<p><b>Removing the "Trending Topics" list</b><br />
The "Trending Topics" list is stored in a div named 'trends'. Removing this using jQuery is as simple as:</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 /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">javascript<span style="color: #339933;">:</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#trends'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000066; font-weight: bold;">void</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>which gives a <a href="javascript:$('#trends').remove();void(0);">Remove Trending List</a> bookmarklet.</p>
<p><b>Removing the Twitter ad</b><br />
It's a small thing, but some people aren't too fond of the small twitter text ad in the top right of the web interface.<br />
This ad has the associated class "promotion", so fortunately, removing it is as simple as</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 /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">javascript<span style="color: #339933;">:</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.promotion'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000066; font-weight: bold;">void</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>which gives the <a href="javascript:$('.promotion').remove();void(0);">Remove Twitter Ad</a> bookmarklet.</p>
<p>&nbsp;</p>
<h3>Quick-access Bookmarklets</h3>
<p>Drag these bookmarklets to your browser's bookmarks bar for quick access when logged in to twitter's web interface.</p>
<ul>
<li><a href="javascript:twttr.HOVERCARD.disable();$('ul.sidebar-menu a').bind('click', function(e) {twttr.HOVERCARD.disable();});$('#home_link, #logo').attr('data', '{\'dispatch_action\':\'home\'}');$('#home_link, #logo').addClass('in-page-link');$('.in-page-link').isInPageLink();$('#results_update').text('Hovercards removed succesfully').show();void(0);">Hovercard Removal</a></li>
<li><a href="javascript:$('#trends').remove();void(0);">Remove Trending List</a></li>
<li><a href="javascript:$('.promotion').remove();void(0);">Remove Twitter Ad</a></li>
<li><a href="javascript:$('.promotion').remove();$('#trends').remove();twttr.HOVERCARD.disable();$('ul.sidebar-menu a').bind('click', function(e) {twttr.HOVERCARD.disable();});$('#home_link, #logo').attr('data', '{\'dispatch_action\':\'home\'}');$('#home_link, #logo').addClass('in-page-link');$('.in-page-link').isInPageLink();$('#results_update').text('Hovercards removed succesfully').show();void(0);">Hovercard, Ad &#038; Trends removal</a> (all 3 of the above combined)</li>
</ul>
<p>&nbsp;</p>
<p><b>Unsure about how exactly to save a bookmarklet?</b><br />
For those of you who may be a little unsure about how exactly you would save or run a bookmarklet, I've put together a <a href="http://www.conroyp.com/2010/04/04/bookmarklets-a-quick-explanation/">quick introduction to bookmarklets</a>, which will hopefully make things a little clearer!</p>
<div style="padding-top:5px;padding-right:0px;padding-bottom:5px;padding-left:0px;;">
											<iframe
												style="height:25px !important; border:0px solid gray !important; overflow:hidden !important; width:550px !important;" frameborder="0" scrolling="no" allowTransparency="true"
												src="http://www.linksalpha.com/social?blog=Conroyp.com&link=http%3A%2F%2Fwww.conroyp.com%2F2010%2F03%2F20%2Fdecluttering-twitter-part-deux%2F&title=DeCluttering+Twitter%2C+Part+Deux&desc=If+you%27re+just+here+to+learn+how+to+kill+the+Twitter+Hovercards%2C+then+drag+the+Hovercard+Removal+bookmarklet+to+your+browser%27s+bookmarks+bar%2C+go+twitter.com%2C+click+it+and+you%27re+done%21+%0D%0ARead+on+if+you&fc=333333&fs=arial&fblname=like&fblref=facebook&fbllang=en_US&fblshow=1&fbsbutton=1&fbsctr=1&fbslang=en&fbsendbutton=0&twbutton=1&twlang=en&twmention=conroyp&twrelated1=&twrelated2=&twctr=1&lnkdshow=show&lnkdctr=1&buzzbutton=0&buzzlang=en&buzzctr=1&diggbutton=0&diggctr=1&stblbutton=0&stblctr=1&g1button=1&g1ctr=1&g1lang=en-US">
											</iframe>
										</div>]]></content:encoded>
			<wfw:commentRss>http://www.conroyp.com/2010/03/20/decluttering-twitter-part-deux/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<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[Updated 28/03/2010 - changed how the bookmarklet re-applies itself to now work in realtime, rather than at clumsy, staggered intervals. 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 [...]]]></description>
			<content:encoded><![CDATA[<p><b><i>Updated 28/03/2010 - changed how the bookmarklet re-applies itself to now work in realtime, rather than at clumsy, staggered intervals.</i></b></p>
<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 will re-apply itself automatically in the background every time you click "more", "@ replies", etc, so you don't need to re-click the bookmarklet whenever your timeline is refreshed.<br />
This can lead to some odd behaviour, such as only 3-4 tweets appearing instead of 20 when you click "more", or not additional tweets appearing when you click the blue "new tweets" bar. This means that tweets which have been loaded matched your filters, and have been removed without ever being displayed to you.</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\nbudget\ntribunal\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\nroflquiz').trigger('keyup');">Auto-tweets</a></p>
<p><script type="text/javascript">
var filters = Array();
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();
        }
    );
});
var bkmrkFirst = "javascript:$('body').bind('ajaxSuccess',declutter);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(/[']/, "\\\'"));
    });
    var htmlin = bkmrkFirst+"var rk=['"+fcon.join("', '")+"'];"+bkmrkLast+'}';
    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">Election</textarea></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 /></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;">'election'</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> <span style="color: #CC0000;">0</span><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 />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p><b>Updated 28/03/2010 - we're now using the ajaxSuccess event, rather than the crude, browser-crashery and slightly hacky setTimeout call!</b></p>
<p>Of course, this bookmarklet wouldn't be all that useufl if you had to re-apply it every time you click "@ replies", "more", "new tweets", etc. In order to have the filters be re-applied automatically, we can bind it to the <a href="http://api.jquery.com/ajaxSuccess/">ajaxSuccess</a> event. This event is conveniently fired by jQuery </p>
<blockquote><p>whenever an Ajax request completes successfully... Any and all handlers that have been registered with the .ajaxSuccess()  method are executed at this time.
</p></blockquote>
<p>As all of the various twitter timelines are loaded via ajax requests, binding the declutter function to this event ensures that it will be re-run after each successful loading of the timeline, meaning that we don't have to worry about manually re-applying the bookmarklet.</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 /></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: #009900;">&#40;</span><span style="color: #3366CC;">'body'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'ajaxSuccess'</span><span style="color: #339933;">,</span>declutter<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>We then wrap the call to declutter() up in a void() call to prevent the browser from opening a new page, and that's all there is to it!</p>
<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>I'm not particularly technical - can you explain how exactly I 'save' a bookmarklet?</i><br />
I've put together a <a href="http://www.conroyp.com/2010/04/04/bookmarklets-a-quick-explanation/">quick introduction to bookmarklets</a> which will hopefully make things a bit clearer!</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>
<div style="padding-top:5px;padding-right:0px;padding-bottom:5px;padding-left:0px;;">
											<iframe
												style="height:25px !important; border:0px solid gray !important; overflow:hidden !important; width:550px !important;" frameborder="0" scrolling="no" allowTransparency="true"
												src="http://www.linksalpha.com/social?blog=Conroyp.com&link=http%3A%2F%2Fwww.conroyp.com%2F2010%2F03%2F11%2Fdeclutter%2F&title=DeClutter&desc=Updated+28%2F03%2F2010+-+changed+how+the+bookmarklet+re-applies+itself+to+now+work+in+realtime%2C+rather+than+at+clumsy%2C+staggered+intervals.%0D%0A%0D%0ATwitter+can+be+a+very+useful+tool%2C+particularly+once+you%27ve+b&fc=333333&fs=arial&fblname=like&fblref=facebook&fbllang=en_US&fblshow=1&fbsbutton=1&fbsctr=1&fbslang=en&fbsendbutton=0&twbutton=1&twlang=en&twmention=conroyp&twrelated1=&twrelated2=&twctr=1&lnkdshow=show&lnkdctr=1&buzzbutton=0&buzzlang=en&buzzctr=1&diggbutton=0&diggctr=1&stblbutton=0&stblctr=1&g1button=1&g1ctr=1&g1lang=en-US">
											</iframe>
										</div>]]></content:encoded>
			<wfw:commentRss>http://www.conroyp.com/2010/03/11/declutter/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
	</channel>
</rss>

