parsa-kafi / t.co bypass

// ==UserScript==
// @name        t.co bypass
// @namespace   http://parsa.ws
// @include     https://twitter.com/*
// @include     https://tweetdeck.com/*
// @include     https://tweetdeck.twitter.com/*
// @version     1.3
// @grant       none
// @description fairly self explanatory, but just in case, this package will replace t.co urls on twitter and tweetdeck by using other attributes in the anchor tag. Programmer: Parsa Kafi , http://parsa.ws
// ==/UserScript==

if(window.attachEvent) {
    window.attachEvent('onload', tcobp_start_timer);
} else {
    if(window.onload) {
        var curronload = window.onload;
        var newonload = function() {
            curronload();
            tcobp_start_timer();
        };
        window.onload = newonload;
    } else {
        window.onload = tcobp_start_timer;
    }
}

function tcobp_start_timer(){
    var myVar = setInterval(function(){tcobp_change_link()}, 1500);  
}

function tcobp_change_link(){
    var host = window.location.host;
    var max = 20;
    var x = "";
    var fbs = new RegExp("http://fb.me");
    var res = false;
    var i;
    var u = "";
    var h = "";
    if(host == "twitter.com")
        x = document.getElementsByClassName("twitter-timeline-link");
    else
        x = document.getElementsByClassName("url-ext");

    for (i = 0; i < x.length, i <= max; i++) {
        if(host == "twitter.com")
            u = x[i].getAttribute("data-expanded-url");
        else
            u = x[i].getAttribute("data-full-url");
        h = x[i].getAttribute("href");
        if(h != u && u !== "" && u !== null){        
            res = fbs.test(u);
            if(res)
                u = u.replace("http://fb.me", "https://fb.me"); 
            x[i].setAttribute('href', u);
        }
    }
}