Greasy Fork is available in English.

Direct links

Direct links out

Per 30-09-2016. Zie de nieuwste versie.

// ==UserScript==
// @name            Direct links
// @name:ru         Прямые ссылки
// @namespace       FIX
// @version         0.0.8
// @description     Direct links out
// @description:ru  Замена ссылок на прямые. Высокое быстродействие в сравнении с аналогичными скриптами.
// @author          raletag
// @match           *://*/*
// @grant           unsafeWindow
// ==/UserScript==

(function() {
    'use strict';
    if (document.documentElement.clientWidth < 5 || document.documentElement.clientHeight < 5) return;

    console.time('Direct links load');

    var win = unsafeWindow || window,
        doc = document.body || document,
        r0 = new RegExp('\/(share|intent\/tweet)([^?]*)\?', 'i'),
        r1 = new RegExp('[?&](url|r|z|to|u|go|st.link)=([^&]*)(&|$)', 'i'),
        r2 = new RegExp('(\/leech_out\\.php\\?.:|\/phpBB2\/goto\/|\/go\/\\?)(.*)', 'i'),
        impCodes = '%3B%2C%2F%3F%3A%40%26%3D%2B%24%23',
        impRegex = new RegExp((impCodes.replace(/%/g,'|%').replace('|','')), 'gi'),
        impDecoded = decodeURIComponent(impCodes),
        impReplacer = function(ch) {
            return impDecoded[impCodes.indexOf(ch.toUpperCase())/3];
        };

    function decodeImportant(text) {
        return text.replace(impRegex, impReplacer);
    }

    function Handler (e) {
        console.time('HandlerTime');
        try {
        var link = e.target, url = link.href, tourl;
        while (!url && link !== this) {
            link = link.parentNode;
            url = link.href;
        }
        link.removeEventListener('mouseenter', Handler, false);
        if (url.length < 5 || r0.test(url)) {
            return true;
        }
        tourl = ((url.match(r1)||url.match(r2)||[])[2]);
        if (!tourl) {
            return true;
        }
        try {
            tourl = decodeURIComponent(tourl);
            tourl = win.atob(tourl);
            tourl = decodeURIComponent(tourl);
            tourl = escape(tourl);
        } catch (err) {
        }
        tourl = decodeImportant(tourl);
        if (tourl.match(/^http(|s):\/\//i)) {
            console.group("Direct links");
            console.info(url);
            console.info(tourl);
            link.removeAttribute('onclick');
            link.href = tourl;
            console.timeEnd('HandlerTime');
            console.groupEnd();
        }
        } catch (err) {
            console.error('Direct links error: ' + err);
            console.timeEnd('HandlerTime');
            alert('Direct links error: ' + err);
        }
        return true;
    }

    function attachEvent (e) {
        for (var links = e.querySelectorAll('a[href*="/"], a[href*="?"]'), i = links.length - 1; i >= 0; --i) {
            links[i].addEventListener('mouseenter', Handler, false);
        }
    }

    attachEvent(doc);

    var o = new MutationObserver(function(ms){
        ms.forEach(function(m){
            m.addedNodes.forEach(function(n){
                if (n.nodeType !== Node.ELEMENT_NODE) {
                    return;
                }
                if (n.href) {
                    n.addEventListener('mouseenter', Handler, false);
                } else {
                    attachEvent(n);
                }
            });
        });
    });
    o.observe(doc, {childList: true, subtree: true});

    console.timeEnd('Direct links load');
})();