Return to Snippet

Revision: 36984
at December 2, 2010 03:42 by nikefido

Initial Code
String.prototype.linkify_tweet = function() {
    var tweet = this.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/g, function(url) { 
        var wrap = document.createElement('div');
        var anch = document.createElement('a');
        anch.href = url; = "_blank";
        anch.innerHTML = url;
        return wrap.innerHTML;
    tweet = tweet.replace(/(^|\s)@(\w+)/g, '[email protected]<a href="$2" target="_blank">$2</a>');
    return tweet.replace(/(^|\s)#(\w+)/g, '$1#<a href="$2" target="_blank">$2</a>');

Initial URL

Initial Description
This will let you use the linkify_tweet() function on any string to make @username, #hashtags and http://any.links be clickable in your API-received twitter feeds.

Initial Title
Linkify Twitter feed (Usernames, hashtags and links)

Initial Tags

Initial Language