What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » URL Shortening Script?

URL Shortening Script?
Author: Message:
Shadowajohn
Junior Member
**

Avatar
Addiction, it keeps me sane...

Posts: 19
31 / Male / Flag
Joined: Nov 2008
O.P. URL Shortening Script?
I was just wondering if it possible to make a script that would change all links in to (for example) bit.ly links?

It would basically search the message box, and if any links were found it would submit it to bit.ly and replace the url with the shortened version?

Something similar to URL shortener in TweetDeck(if anyone uses)

This post was edited on 09-21-2009 at 08:34 PM by Shadowajohn.
Xbox360Stuff Script - Twitter - Blog
X360Stuff Script Status: On-Hold.
Will make/edit a new script soon.
[Image: ShadowAjohn.gif]
09-21-2009 07:58 PM
Profile E-Mail PM Web Find Quote Report
foaly
Senior Member
****

Avatar

Posts: 718
Reputation: 20
38 / Male / Flag
Joined: Jul 2006
RE: URL Shortening Script?
well there is a tinyurl script:
http://www.messengerpluslive.com/scripts/view/303-TinyURL/
haven't tried it though...
09-21-2009 11:36 PM
Profile E-Mail PM Find Quote Report
roflmao456
Skinning Contest Winner
****

Avatar

Posts: 955
Reputation: 24
30 / Male / Flag
Joined: Nov 2006
Status: Away
RE: URL Shortening Script?
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();
    }

This post was edited on 09-22-2009 at 12:33 AM by roflmao456.
[quote]
Ultimatess6
: What a noob mod
09-22-2009 12:32 AM
Profile PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On