I'm too
lazy busy to make the GUI, but you could probably use these functions:
JScript code:
var login = "roflmao456";
var api_key = "R_0d142cec1c6940a9d270d5420f2c90fb";
var get_link_hash = function(url){
// Should work on most url shortener sites.
return /(.*)\.(.*)\/(.*)/.test(url)?RegExp.$3:url;
};
function OnEvent_Initialize(MessengerStart){
shorten_url("http://google.com", callbackdebug);
expand_url("http://bit.ly/bZc0H", callbackdebug);
}
function callbackdebug(param){
Debug.Trace(param);
}
function shorten_url(url, callback){
// Shortens url with bit.ly
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("GET", "http://api.bit.ly/shorten?version=2.0.1&longUrl=" + url + "&login=" + login + "&apiKey=" + api_key, 1);
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readystate == 4 && xmlhttp.status == 200){
eval("var result = " + xmlhttp.responseText);
if(result.statusCode == "OK"){
var shortUrl = result.results[url]['shortUrl'];
Debug.Trace("shortened " + url + ": " + shortUrl);
if(typeof callback == "function")
callback(shortUrl);
}
}
}
xmlhttp.send();
}
function expand_url(url, callback){
// Expands a bit.ly url
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("GET", "http://api.bit.ly/expand?version=2.0.1&shortUrl=" + url + "&login=" + login + "&apiKey=" + api_key, 1);
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readystate == 4 && xmlhttp.status == 200){
eval("var result = " + xmlhttp.responseText);
if(result.statusCode == "OK"){
var longUrl = result.results[get_link_hash(url)]['longUrl'];
Debug.Trace("expanded " + url + ": " + longUrl);
if(typeof callback == "function")
callback(longUrl);
}
}
}
xmlhttp.send();
}