Tweet That Thang…

While there are countless ways to post to Twitter, I recently found myself wanting something particular that wasn’t well served. I didn’t want a full fledged Twitter client open in the background all the time, and I didn’t want to have to visit twitter.com to tweet out a simple link, and I really didn’t want to install some chrome extension that would do countless other things that I really didn’t want it doing.

What I wanted was a button I could click that would copy the current URL and put it in one of Twitter’s handy-dandy popup windows. Getting it in a popup window was key, as the omnibox solutions which allow you to tweet from the browser bar don’t offer a running word count, and with the parsimonious nature of tweets and myself always pushing the limit I like to know just where I’m at so I can prune accordingly. So, enter Twitter’s share bookmarklet. Or so I thought. The one problem with the bookmarklet is that it spawned an empty popup, carrying over none of the current page info with it. So I tweaked it a bit and figure it’s worth sharing if someone else is looking for a similar experience.

Here’s the javascript code. You can paste this into the URL field of any bookmark and it will generate a Twitter popup and populate it with the current URL and — if the page supports it — sometimes the page title comes along for the ride. The ‘?url=’ + window.location.href’ is what I added for those who’re wondering.
javascript:(function(){window.twttr=window.twttr||{};var D=550,A=450,C=screen.height,B=screen.width,H=Math.round((B/2)-(D/2)),G=0,F=document,E;if(C>A){G=Math.round((C/2)-(A/2))}window.twttr.shareWin=window.open('http://twitter.com/share?url=' + window.location.href,'','left='+H+', top='+G+',width='+D+',height='+A+',personalbar=0,toolbar=0,scrollbars=1,resizable=1'); E=F.createElement('script'); E.src='http://platform.twitter.com/bookmarklets/share.js?v=1'; F.getElementsByTagName('head')[0].appendChild(E)}());
Hope this makes Twitter a bit more useful for you, as it has me…

Advertisements

One response to “Tweet That Thang…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s