<?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; bookmarklet</title>
	<atom:link href="http://www.conroyp.com/tags/bookmarklet/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>Malkovich Malkovich Malkovich</title>
		<link>http://www.conroyp.com/2011/06/19/malkovich-malkovich-malkovich/</link>
		<comments>http://www.conroyp.com/2011/06/19/malkovich-malkovich-malkovich/#comments</comments>
		<pubDate>Sun, 19 Jun 2011 21:33:10 +0000</pubDate>
		<dc:creator>Paul</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[bookmarklet]]></category>
		<category><![CDATA[completely-useless]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.conroyp.com/?p=519</guid>
		<description><![CDATA[In the film Being John Malkovich, John Cusack plays a puppeteer who finds a portal to inside John Malkovich's head. Eventually John Malkovich himself goes through this portal, and the ensuing paradox means that every word he hears is "Malkovich", and every face he sees is his own. Re-watching this film lately gave me an [...]]]></description>
			<content:encoded><![CDATA[<div class="clear"></div>
<p><img src="http://www.conroyp.com/wp-content/uploads/2011/06/Malkovich1.jpg" alt="Malkovich Malkovich Malkovich" title="" width="440" height="192" class="aligncenter size-full wp-image-528" /><br />
In the film <a href="http://www.imdb.com/title/tt0120601/">Being John Malkovich</a>, John Cusack plays a puppeteer who finds a portal to inside John Malkovich's head. Eventually John Malkovich himself goes through this portal, and the ensuing paradox means that every word he hears is "Malkovich", and every face he sees is his own.</p>
<p>Re-watching this film lately gave me an idea for the latest trivial entry in my <a href="http://www.conroyp.com/tags/bookmarklet/">ongoing bookmarklets collection</a>, where every image on a website is changed to show the same one. So read below the jump to find out how to <a href="javascript: var newImg = 'http://www.conroyp.com/wp-content/uploads/2011/06/Malkovich-head.jpg';for(i=0; i<document.getElementsByTagName('img').length; i++){var swapH = document.getElementsByTagName('img')[i].height; var swapW = document.getElementsByTagName('img')[i].width; document.getElementsByTagName('img')[i].src=newImg;document.getElementsByTagName('img')[i].height = swapH; document.getElementsByTagName('img')[i].width = swapW;};void(0);">Malkovich a website</a> - or customise the effect to use an image of your choosing!</p>
<p><span id="more-519"></span></p>
<h3>How it works</h3>
<p>Being a very simple and silly bookmarklet, the idea behind it is pretty simple:<br />
- loop through each image on a website<br />
- change the image on the site to a new image (John Malkovich, in this case)<br />
- ensure the new image has the same height and width of the previous image, to keep the page layout the same</p>
<p><b>Step 1: Pick an image</b></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: #003366; font-weight: bold;">var</span> newImg <span style="color: #339933;">=</span> <span style="color: #3366CC;">'http://www.conroyp.com/wp-content/uploads/2011/06/Malkovich-head.jpg'</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
</p>
<p><b>Step 2: Loop through each image on the page</b></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: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'img'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span></div></td></tr></tbody></table></div>
</p>
<p><b>Step 3: Get the height and width of the existing image</b><br />
We need to get the current height and width of the current image on the page. We do this as if the image dimensions haven't been explicitly specified in the target's site html and differ from our "Malkovich" image, the target site's layout can get quite borked.</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">&nbsp; &nbsp;<span style="color: #003366; font-weight: bold;">var</span> swapH <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'img'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">height</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;<span style="color: #003366; font-weight: bold;">var</span> swapW <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'img'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">width</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
</p>
<p><b>Step 4: Enter Malkovich</b></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 /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp;document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'img'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">src</span><span style="color: #339933;">=</span>newImg<span style="color: #339933;">;</span><br />
&nbsp; &nbsp;<span style="color: #006600; font-style: italic;">// Ensure height &amp; width kept consistent</span><br />
&nbsp; &nbsp;document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'img'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">height</span> <span style="color: #339933;">=</span> swapH<span style="color: #339933;">;</span> <br />
&nbsp; &nbsp;document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'img'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">width</span> <span style="color: #339933;">=</span> swapW<span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
</p>
<p><b>Step 5: Wrap it all up in a bookmarklet</b><br />
A void(0) is required at the end of the bookmarklet to stop the browser from trying to open a new page.</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: #003366; font-weight: bold;">var</span> newImg <span style="color: #339933;">=</span> <span style="color: #3366CC;">'http://www.conroyp.com/wp-content/uploads/2011/06/Malkovich-head.jpg'</span><span style="color: #339933;">;</span><span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'img'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #003366; font-weight: bold;">var</span> swapH <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'img'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">height</span><span style="color: #339933;">;</span> <span style="color: #003366; font-weight: bold;">var</span> swapW <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'img'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">width</span><span style="color: #339933;">;</span> document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'img'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">src</span><span style="color: #339933;">=</span>newImg<span style="color: #339933;">;</span>document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'img'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">height</span> <span style="color: #339933;">=</span> swapH<span style="color: #339933;">;</span> document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'img'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">width</span> <span style="color: #339933;">=</span> swapW<span style="color: #339933;">;</span><span style="color: #009900;">&#125;</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>You can also drag the <a href="javascript: var newImg = 'http://www.conroyp.com/wp-content/uploads/2011/06/Malkovich-head.jpg';for(i=0; i<document.getElementsByTagName('img').length; i++){var swapH = document.getElementsByTagName('img')[i].height; var swapW = document.getElementsByTagName('img')[i].width; document.getElementsByTagName('img')[i].src=newImg;document.getElementsByTagName('img')[i].height = swapH; document.getElementsByTagName('img')[i].width = swapW;};void(0);">Malkovich Malkovich Malkovich</a> bookmarklet to your browser's bookmarks bar, click it on any website, and behold the Malkovication of that site.</p>
<p>&nbsp;</p>
<h3>Make your own</h3>
<p>The novelty of seeing John Malkovich all over the place is nice, but it would be better if you could customise the effect a little more.</p>
<p><script type="text/javascript">
var imgUrl;
jQuery(document).ready(function(){
    // Catch default values..
    imgUrl = jQuery('#imageUrl').val().trim().split("\n");
    updateBookmarklet();
    var jInput = jQuery( "#imageUrl" );
    jQuery( "#imageUrl" ).keyup(
        function(){
            updateBookmarklet();
        }
    );
});
var bkmrkFirst = "javascript: var newImg = '";
var bkmrkLast = "';for(i=0; i<document.getElementsByTagName('img').length; i++){var swapH = document.getElementsByTagName('img')[i].height; var swapW = document.getElementsByTagName('img')[i].width; document.getElementsByTagName('img')[i].src=newImg;document.getElementsByTagName('img')[i].height = swapH; document.getElementsByTagName('img')[i].width = swapW;};void(0);";
function updateBookmarklet()
{
    var htmlin = bkmrkFirst+jQuery('#imageUrl').val()+bkmrkLast;
    jQuery('#quickLink').attr('href', htmlin);    
}
</script></p>
<input type="text" id="imageUrl" size="80" value="http://www.conroyp.com/wp-content/uploads/2011/06/Malkovich-head.jpg" />
<p>Enter the address of any image you wish in the box above. Then drag your very own custom <a id="quickLink">Malkovich bookmarklet</a> to your bookmarks bar, and you're done! The bookmarklet updates in real time as you type in the box above.</p>
<p>&nbsp;</p>
<div id="attachment_556" class="wp-caption alignright" style="width: 210px"><a href="http://www.conroyp.com/wp-content/uploads/2011/06/Malkovich-paul.jpg"><img src="http://www.conroyp.com/wp-content/uploads/2011/06/Malkovich-paul-300x175.jpg" alt="" title="A Daft idea" width="200" class="size-medium wp-image-556" /></a><p class="wp-caption-text">A Daft idea</p></div>
<h3>But why...</h3>
<p>- <i>Why not just use jQuery?</i><br />
JQuery isn't loaded on all websites by default. Loading jQuery is possible in a bookmarklet, but adds far more overhead than using the more-verbose JS above.</p>
<p>- <i>Why didn't all images on the site I tried change?</i><br />
This bookmarklet works only on images loaded in an img tag. If an image is a background image on a div, then the bookmarklet won't catch it.</p>
<p>- <i>Wait, a bookmarklet? What is that?</i><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>- <i>This is ridiculous. What's the point?</i><br />
There is absolutely no point or useful function to this whatsoever. Any potential amusement you may derive from using it is linked directly to your imagination when selecting an image and website.</p>
<p>And that's it. If you've any thoughts on improving the implementation above, or have an hilarious screenshot resulting from use of the bookmarklet, let me know in the comments below!</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%2F2011%2F06%2F19%2Fmalkovich-malkovich-malkovich%2F&title=Malkovich+Malkovich+Malkovich&desc=%0D%0A%0D%0AIn+the+film+Being+John+Malkovich%2C+John+Cusack+plays+a+puppeteer+who+finds+a+portal+to+inside+John+Malkovich%27s+head.+Eventually+John+Malkovich+himself+goes+through+this+portal%2C+and+the+ensuing+para&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/2011/06/19/malkovich-malkovich-malkovich/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>A Grab Bag of Bookmarklets</title>
		<link>http://www.conroyp.com/2010/04/18/a-grab-bag-of-bookmarklets/</link>
		<comments>http://www.conroyp.com/2010/04/18/a-grab-bag-of-bookmarklets/#comments</comments>
		<pubDate>Sun, 18 Apr 2010 15:46:21 +0000</pubDate>
		<dc:creator>Paul</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[bookmarklet]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[whois]]></category>

		<guid isPermaLink="false">http://www.conroyp.com/?p=179</guid>
		<description><![CDATA[A (semi-) frequently updated list of simple bookmarklets I've found somewhat useful. Some of the more complex ones for use on twitter.com (Custom filtering of the timeline and Hovercard removal) are discussed in more detail elsewhere on the site. The below are a collection of short and sweet bookmarklets that do a simple but effective [...]]]></description>
			<content:encoded><![CDATA[<p>A (semi-) frequently updated list of simple bookmarklets I've found somewhat useful. Some of the more complex ones for use on twitter.com (<a href="http://www.conroyp.com/2010/03/11/declutter/">Custom filtering of the timeline</a> and <a href="http://www.conroyp.com/2010/03/20/decluttering-twitter-part-deux/">Hovercard removal</a>) are discussed in more detail elsewhere on the site. The below are a collection of short and sweet bookmarklets that do a simple but effective job.</p>
<p><span id="more-179"></span><br />
<b>Quick Links</b></p>
<ul>
<li><a href='#whois'>WHOIS Lookup</a></li>
<li><a href='#dual_site'>Dual Site Toggle</a></li>
<li><a href='#dfeojm'>Down for everyone, or just me?</a></li>
</ul>
<p></p>
<h3 id='whois'>WHOIS Lookup</h3>
<p><a href="http://en.wikipedia.org/wiki/WHOIS">WHOIS</a> is a protocol for finding out the contact details of the owner of a domain. Traditionally this information is accessed via the command line, however a number of websites now exist as wrappers for this information. </p>
<p>Sites such as <a href="http://who.is/">Who.is</a> allow accessing of domain ownership and contact info via a web browser. What's particularly nice about the who.is site is that you can query any site by placing the domain name you wish to query at the end of the who.is url, i.e. http://who.is/daft.ie will give WHOIS info for Daft.ie.</p>
<p>This simple <a href="javascript:window.location = 'http://who.is/whois/'+window.location.host;">WHOIS bookmarklet</a> automates this process. Clicking this bookmarklet will query the WHOIS info for the site you're currently on, via the who.is site. Copy the code below in to a new bookmarklet, or drag the WHOIS bookmarklet link above to your browser's bookmarks bar.</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">window.<span style="color: #660066;">location</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'http://who.is/whois/'</span><span style="color: #339933;">+</span>window.<span style="color: #660066;">location</span>.<span style="color: #660066;">host</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p></p>
<h3 id='dual_site'>Dual Site Toggle</h3>
<p>This bookmarklet when you want compare the same page on two different sites which both use the same url structure, e.g. a local development environment (localhost) and the same page on the live server (example.com).<br />
For this example, we'll compare property result pages on <a href="http://www.daft.ie">Daft.ie</a> with the same ones on the mobile version of the site, <a href="http://m.daft.ie">m.daft.ie</a>.</p>
<p>First, we decide on the two sites between which we want to toggle.</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: #003366; font-weight: bold;">var</span> siteA <span style="color: #339933;">=</span> <span style="color: #3366CC;">'www.daft.ie'</span><span style="color: #339933;">;</span><br />
<span style="color: #003366; font-weight: bold;">var</span> siteB <span style="color: #339933;">=</span> <span style="color: #3366CC;">'m.daft.ie'</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>
Next we need to grab the filename of the current page, as well as any query string arguments. This value will stay the same between both sites.</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 /></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: #006600; font-style: italic;">// Store the filename and query string, where applicable</span><br />
<span style="color: #003366; font-weight: bold;">var</span> sstr <span style="color: #339933;">=</span> <span style="color: #3366CC;">''</span><span style="color: #339933;">;</span><br />
<span style="color: #006600; font-style: italic;">// Query string exists?</span><br />
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">location</span>.<span style="color: #660066;">search</span>.<span style="color: #660066;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">length</span><span style="color: #339933;">&gt;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; sstr <span style="color: #339933;">=</span> window.<span style="color: #660066;">location</span>.<span style="color: #660066;">pathname</span><span style="color: #339933;">+</span><span style="color: #3366CC;">'?'</span><span style="color: #339933;">+</span>window.<span style="color: #660066;">location</span>.<span style="color: #660066;">search</span>.<span style="color: #660066;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #000066; font-weight: bold;">else</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; sstr <span style="color: #339933;">=</span> window.<span style="color: #660066;">location</span>.<span style="color: #660066;">pathname</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>
Finally, we need to figure out which host we're on, and then switch to the other one!</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 /></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: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">location</span>.<span style="color: #660066;">host</span>.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span>siteA<span style="color: #009900;">&#41;</span><span style="color: #339933;">==-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; window.<span style="color: #660066;">location</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'http://'</span><span style="color: #339933;">+</span>siteA<span style="color: #339933;">+</span>sstr<span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #000066; font-weight: bold;">else</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; window.<span style="color: #660066;">location</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'http://'</span><span style="color: #339933;">+</span>siteB<span style="color: #339933;">+</span>sstr<span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>As it's a bookmarklet, we need to compress it all down to one line.</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: #003366; font-weight: bold;">var</span> siteA <span style="color: #339933;">=</span> <span style="color: #3366CC;">'www.daft.ie'</span><span style="color: #339933;">;</span><span style="color: #003366; font-weight: bold;">var</span> siteB <span style="color: #339933;">=</span> <span style="color: #3366CC;">'m.daft.ie'</span><span style="color: #339933;">;</span><span style="color: #003366; font-weight: bold;">var</span> sstr <span style="color: #339933;">=</span> <span style="color: #3366CC;">''</span><span style="color: #339933;">;</span><span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">location</span>.<span style="color: #660066;">search</span>.<span style="color: #660066;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">length</span><span style="color: #339933;">&gt;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>sstr <span style="color: #339933;">=</span> window.<span style="color: #660066;">location</span>.<span style="color: #660066;">pathname</span><span style="color: #339933;">+</span><span style="color: #3366CC;">'?'</span><span style="color: #339933;">+</span>window.<span style="color: #660066;">location</span>.<span style="color: #660066;">search</span>.<span style="color: #660066;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #000066; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>sstr <span style="color: #339933;">=</span> window.<span style="color: #660066;">location</span>.<span style="color: #660066;">pathname</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span><span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">location</span>.<span style="color: #660066;">host</span>.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span>siteA<span style="color: #009900;">&#41;</span><span style="color: #339933;">==-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>window.<span style="color: #660066;">location</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'http://'</span><span style="color: #339933;">+</span>siteA<span style="color: #339933;">+</span>sstr<span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #000066; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>window.<span style="color: #660066;">location</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'http://'</span><span style="color: #339933;">+</span>siteB<span style="color: #339933;">+</span>sstr<span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>To use this toggle, you can either copy the above code to a new bookmarklet, or drag this <a href="javascript:var siteA = 'www.daft.ie';var siteB = 'm.daft.ie';var sstr = '';if(window.location.search.substring(1).length>1){sstr = window.location.pathname+'?'+window.location.search.substring(1);}else{sstr = window.location.pathname;};if(window.location.host.indexOf(siteA)==-1){window.location='http://'+siteA+sstr;}else{window.location = 'http://'+siteB+sstr;};">Site toggle</a> link to your bookmarks bar.<br />
<br />To see it in action, we can pick <a href="http://www.daft.ie/searchsale.daft?id=428175">a random house on Daft.ie</a> (in this case, the house used by TV3's The Apprentice), then click the bookmarklet to toggle between the mobile and web versions of the same page.</p>
<p>Updating this for any other pair of sites is as simple as editing the siteA and siteB variables in the bookmarklet.</p>
<p></p>
<h3 id='dfeojm'>Down for everyone, or just me?</h3>
<p><a href="http://www.downforeveryoneorjustme.com">Downforeveryoneorjustme.com</a> is a site that comes in handy when trying to check whether a site being inaccessible is a problem with the site itself, or your local network. It will basically ping the server from a location different to your own, and see if it's still available from there.</p>
<p>We're basically doing the same thing here as we did for the WHOIS bookmarklet above, so:</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">window.<span style="color: #660066;">location</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'http://www.downforeveryoneorjustme.com/'</span><span style="color: #339933;">+</span>window.<span style="color: #660066;">location</span>.<span style="color: #660066;">host</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>
Dragging this <a href="javascript:window.location = 'http://www.downforeveryoneorjustme.com/'+window.location.host;">DFEOJM bookmarklet</a> to your browser's bookmarks bar will let you check the next time you get a "server inaccessible" error message whether the problem is on your network or with the site itself.</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%2F04%2F18%2Fa-grab-bag-of-bookmarklets%2F&title=A+Grab+Bag+of+Bookmarklets&desc=A+%28semi-%29+frequently+updated+list+of+simple+bookmarklets+I%27ve+found+somewhat+useful.+Some+of+the+more+complex+ones+for+use+on+twitter.com+%28Custom+filtering+of+the+timeline+and+Hovercard+removal%29+are+d&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/04/18/a-grab-bag-of-bookmarklets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bookmarklets &#8211; a quick explanation!</title>
		<link>http://www.conroyp.com/2010/04/04/bookmarklets-a-quick-explanation/</link>
		<comments>http://www.conroyp.com/2010/04/04/bookmarklets-a-quick-explanation/#comments</comments>
		<pubDate>Sun, 04 Apr 2010 00:37:28 +0000</pubDate>
		<dc:creator>Paul</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[bookmarklet]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.conroyp.com/?p=154</guid>
		<description><![CDATA[I've been tinkering quite a bit lately with improving the twitter web interface with the use of bookmarklets. I've put together a series of bookmarklets which allow you to do everything from apply custom filters to your twitter timeline, to removing the "Hovercards" which Twitter have recently added. Most of the feedback I've received both [...]]]></description>
			<content:encoded><![CDATA[<p>I've been tinkering quite a bit lately with improving the <a href="http://www.twitter.com">twitter</a> web interface with the use of bookmarklets. I've put together a series of bookmarklets which allow you to do everything from <a href="http://www.conroyp.com/2010/03/11/declutter/">apply custom filters to your twitter timeline</a>, to <a href="http://www.conroyp.com/2010/03/20/decluttering-twitter-part-deux/">removing the "Hovercards"</a> which Twitter have recently added.</p>
<p>Most of the feedback I've received both in the comments here and on twitter has been very positive, but I've also heard from a few folk who have had difficulty actually saving the bookmarklets and getting them to work.</p>
<p>Admittedly, the posts on the bookmarklets did assume a certain level of technical know-how, so this post is intended as a quick intro for those who want to use the bookmarklets, but aren't quite sure where to start.</p>
<p><span id="more-154"></span></p>
<h3>So what is a bookmarklet?</h3>
<p>A <a href="http://en.wikipedia.org/wiki/Bookmarklet">bookmarklet</a> is:</p>
<blockquote><p>a small computer application, stored as the URL of a bookmark in a web  browser or as a hyperlink on a web page. [...] They are  designed to add one-click functionality to a browser or web  page. When clicked, a bookmarklet performs some function, one of a wide  variety such as a search query or data extraction.</p></blockquote>
<p>So bookmarklets basically allow us as a user to add some basic functionality to a web site from our browser, without needing to have access to that site's server. Once the bookmarklet is clicked, whatever javascript it contains will execute on the current page.</p>
<p>In this case, we have bookmarklets specifically crafted for twitter's web site (filtering our timeline, removing hovercards, etc) so when we go to twitter.com and click the bookmarklet, our custom code shall be run by our browser as if it were part of twitter's own code.</p>
<p>So, how do we save and then run these bookmarklets? Well, there are several different options..</p>
<p>&nbsp;</p>
<h3>Option 1 - Drag and drop!</h3>
<p>Probably the quickest way of saving a bookmarklet is to drag it from it's location on the page and drop it on your bookmark bar.<br />
First, we need to make sure the bookmarks bar is accessible. The bookmark bar is typically found immediately under the address bar in your browser (highlighted in red on the image below).</p>
<p>If you're running Firefox or Internet Explorer, then it should be showing by default. On Chrome, you may have to press "Ctrl+B", or go to "Settings" (spanner icon) then click "Always show bookmark bar".</p>
<div id="attachment_157" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.conroyp.com/wp-content/uploads/2010/04/BookmarkBar.png"><img class="size-medium wp-image-157" title="BookmarkBar" src="http://www.conroyp.com/wp-content/uploads/2010/04/BookmarkBar-300x63.png" alt="Bookmark Bar (Firefox)" width="300" height="63" /></a><p class="wp-caption-text">Bookmark Bar (Firefox)</p></div>
<p>Once your bookmark bar is visible, you can click on a bookmarklet link, drag it to this bar, then have it ready to run!</p>
<p>So, given this <a href="javascript:twttr.HOVERCARD.disable();$('ul.sidebar-menu%20a').bind('click',%20function(e)%20{twttr.HOVERCARD.disable();});void(0);">Disable Hovercard</a> link, all you need to do is:</p>
<ul>
<li>press your mouse down on the link above (do not let go of the mouse button!)</li>
<li>drag your mouse to an empty spot on your bookmark bar</li>
<li>let go of the mouse button</li>
</ul>
<p>You should know see a "Disable Hovercard" bookmarklet on your bookmark bar. Go to twitter.com, click this bookmarklet and you should not see any more hovercards!</p>
<div id="attachment_159" class="wp-caption aligncenter" style="width: 464px"><a href="http://www.conroyp.com/wp-content/uploads/2010/04/BookmarkletSuccess.png"><img class="size-full wp-image-159" title="BookmarkletSuccess" src="http://www.conroyp.com/wp-content/uploads/2010/04/BookmarkletSuccess.png" alt="Bookmarklet" width="454" height="96" /></a><p class="wp-caption-text">Success!</p></div>
<p>&nbsp;</p>
<h3>Option 2 - Let the browser do it</h3>
<p>Most browsers have menu options which will do the same thing as the dragging-and-dropping above.</p>
<p>&nbsp;</p>
<p><strong>Internet Explorer</strong></p>
<div id="attachment_161" class="wp-caption aligncenter" style="width: 310px"><strong> </strong><strong><a href="http://www.conroyp.com/wp-content/uploads/2010/04/IEFav.png"><img class="size-medium wp-image-161" title="IEFav" src="http://www.conroyp.com/wp-content/uploads/2010/04/IEFav-300x155.png" alt="Adding a bookmarklet - IE" width="300" height="155" /></a></strong><p class="wp-caption-text">Adding a Bookmarklet - IE</p></div>
<ul>
<li>Right-click on the "<a href="javascript:twttr.HOVERCARD.disable();$('ul.sidebar-menu%20a').bind('click',%20function(e)%20{twttr.HOVERCARD.disable();});void(0);">Disable Hovercard</a>" bookmarklet link</li>
<li>Select "Add a Favourite.."</li>
<li>You can re-title the bookmarklet using the "Name" field, if you want</li>
<li>Select "Favourites Bar" from the "Create in" menu</li>
<li>Press "Add"</li>
</ul>
<p>&nbsp;</p>
<p><strong>Firefox</strong></p>
<div id="attachment_164" class="wp-caption aligncenter" style="width: 310px"><strong> </strong><strong><a href="http://www.conroyp.com/wp-content/uploads/2010/04/FFFav.png"><img class="size-medium wp-image-164" title="FFFav" src="http://www.conroyp.com/wp-content/uploads/2010/04/FFFav-300x157.png" alt="Adding a bookmarklet - FF" width="300" height="157" /></a></strong><p class="wp-caption-text">Adding a Bookmarklet - Firefox</p></div>
<ul>
<li>Right-click on the "<a href="javascript:twttr.HOVERCARD.disable();$('ul.sidebar-menu%20a').bind('click',%20function(e)%20{twttr.HOVERCARD.disable();});void(0);">Disable  Hovercard</a>" bookmarklet link</li>
<li>Select "Bookmark This Link"</li>
<li>If you want, you can rename the bookmarklet using the "Name" field</li>
<li>Select "Bookmarks Toolbar" from the "Folder" drop-down</li>
<li>Click "Save"</li>
</ul>
<p><strong>Chrome</strong><br />
Currently, Chrome doesn't have an easy right-click option for saving bookmarklets, so if you're on Chrome, you'll have to follow Option 1 above!</p>
<p>&nbsp;</p>
<h3>That's all folks!</h3>
<p>And that's all there is to it! You should now have a "Disable Hovercard" bookmarklet on your bookmark bar. To see it in action:</p>
<ul>
<li>go to twitter.com and log in</li>
<li>mouse over a username in a tweet to see the hovercard appear</li>
<li>click the bookmarklet</li>
<li>mouse over the same username, and - hey presto - the hovercard should now be gone</li>
</ul>
<p>And that's all there is to it! The same process can be applied for any other bookmarklet, including the <a href="http://www.conroyp.com/2010/03/11/declutter/">timeline filtering bookmarklet</a> (remove those foursquare check-ins, xbox achievements and other such auto-tweets!)</p>
<p>So hopefully this post should help make things a little clearer for those who were having trouble with the bookmarklets previously - if not, let me know in the comments below!</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%2F04%2F04%2Fbookmarklets-a-quick-explanation%2F&title=Bookmarklets+-+a+quick+explanation%21&desc=I%27ve+been+tinkering+quite+a+bit+lately+with+improving+the+twitter+web+interface+with+the+use+of+bookmarklets.+I%27ve+put+together+a+series+of+bookmarklets+which+allow+you+to+do+everything+from+apply+cus&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/04/04/bookmarklets-a-quick-explanation/feed/</wfw:commentRss>
		<slash:comments>3</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>

