Ubuntu insights, Programming in groovy, java, et als!

Thursday, August 09, 2012

A stupid hack to open short urls blocked by proxy via Launchy

This script will be useful when short urls are blocked by a proxy within a network.

For example:

Lets say the link to an article or blog on the web is this:

LongUrl : http://something.com/somethingelse

Your friend reads the above article and mails the link to you in its shortened form:

ShortUrl : http://bit.ly/s1 or http://t.co/se1

Now when you are on a company network or a protected network, there is a good chance that bit.ly or t.co services are blocked by the proxy though the original site itself (something.com in this case) might not be blocked.

For such cases this silly vbscript can be handy. It basically talks to a longurl.org which lengthens the shortened url and opens it up on the browser.

lurl.vbs

set ws = CreateObject("WScript.Shell")
siteUrl = "http://longurl.org/expand?url=" & Wscript.Arguments.Named("u")

Dim objHttp
Set objHttp = CreateObject("Msxml2.ServerXMLHTTP")
objHttp.Open "GET", siteUrl, False
objHttp.Send
page = objHttp.ResponseText
Set objHttp = Nothing

longUrl = Split(Split(page,"Long URL:")(1),"""")(1)
ws.Run(longUrl)

I have saved the above lurl.vbs file under C:\Temp\Scripts.

From command prompt, running the below command will open up the link in the browser.

lurl /u:your-short-url        


                          
Further more, you can even configure it via the Launchy Runner plugin which makes it more fun.

                                   

Within launchy, typing lurl (tab) followed by site's short url will launch the site directly.