DLE links decoder

Прямые ссылки на сайтах с движком DataLife Engine (DLE)

اعتبارا من 18-08-2016. شاهد أحدث إصدار.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name         DLE links decoder
// @namespace    lainscripts_dle_links_decoder
// @version      0.5
// @description  Прямые ссылки на сайтах с движком DataLife Engine (DLE)
// @author       lainverse
// @match        *://*/*
// @grant        none
// ==/UserScript==
// Script based on a similar script by raletag:
// https://greasyfork.org/en/scripts/22290-Прямые-ссылки-в-dle

(function() {
    'use strict';

    var win = window;

    function isBase64(str) {
        try {
            return !!str && !!win.atob(str);
        } catch (ignore) {
            return false;
        }
    }

    function linkHandler(e){
        var link = e.target, url = link.href, url64;
        if (!url) {
            return true;
        }
        url64 = decodeURIComponent((url.match(/[?&]url=([^&]*)(&|$)/i)||
                                    url.match(/\/leech_out\.php\?.:(.+)$/i)||
                                    [])[1]);
        if (!url64) {
            return true;
        }
        if (isBase64(url64)) {
            url = win.atob(url64);
            console.log('Replaced ' + link.href + ' with ' + url);
            link.href = url;
        }
        return true;
    }

    document.addEventListener('mouseover', linkHandler, false);
})();