Tweetdeck url extander

getting over the t.co redirection

Verze ze dne 04. 09. 2015. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name        Tweetdeck url extander
// @namespace   tweetdeck.twitter.com
// @description getting over the t.co redirection
// @include     https://tweetdeck.twitter.com/
// @version     1
// @grant       none
// ==/UserScript==
(function (window) {
    var document = window.document;
    var OneTimeTrigger = function (func, delay) {
        var timerCountdown = 0;
        return function() {
            setTimeout(function() {
                timerCountdown -= 1;
                if (timerCountdown == 0) {
                    func();
                }
            }, delay);
            timerCountdown += 1;
        };
    };
    var expandAllLink = function () {
        var expandedUrl;
        Array.prototype.forEach.call(document.querySelectorAll("a.url-ext:not(.url-ext-expanded)"),
            function (node) {
                if (/^http(?:s)?:\/\/t\.co\/[0-9A-Za-z]+$/g.test(node.href)) {
                    expandedUrl = node.getAttribute("data-full-url");
                    if (expandedUrl) {
                        node.href = expandedUrl;
                    }
                    node.className += " url-ext-expanded";
                }
            });
    };
    var trigger = OneTimeTrigger(expandAllLink, 100);
    var MutationObserver = window.MutationObserver ? window.MutationObserver : window.WebKitMutationObserver;
    if (typeof MutationObserver !== "undefined") {
        var observer = new MutationObserver(trigger);
        observer.observe(document, { childList: true, subtree: true });
    }
    else {
        document.addEventListener("DOMNodeInserted", trigger, false);
        document.addEventListener("DOMSubtreeModified", trigger, false);
    }

})(window);