Remove Yandex Redirect

Remove Yandex redirect in search, news and mail

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            Remove Yandex Redirect
// @name:ru         Удаление редиректов на Яндексе
// @namespace       FIX
// @version         0.4
// @description     Remove Yandex redirect in search, news and mail
// @description:ru  Удаление редиректов на Яндексе в поисковой выдаче, новостях и почте
// @author          raletag
// @include         *://yandex.*/*
// @include         *://*.yandex.*/*
// @grant           unsafeWindow
// ==/UserScript==

(function() {
    'use strict';
    var win = unsafeWindow || window;
    if (win.top !== win.self) return;

    console.time('Remove Yandex Redirect load');

    function remove (e) {
        var links = e.querySelectorAll('a[onmousedown*="/clck/jsredir"]'), i;
        for (i = links.length - 1; i >= 0; --i) {
            links[i].removeAttribute('onmousedown');
        }
        links = e.querySelectorAll('a[data-counter]');
        for (i = links.length - 1; i >= 0; --i) {
            links[i].removeAttribute('data-counter');
            links[i].removeAttribute('data-bem');
        }
        links = e.querySelectorAll('a[data-vdir-href]');
        for (i = links.length - 1; i >= 0; --i) {
            links[i].removeAttribute('data-vdir-href');
            links[i].removeAttribute('data-orig-href');
        }
    }

    remove (document.body);

    var o = new MutationObserver(function(ms){
        ms.forEach(function(m){
            m.addedNodes.forEach(function(n){
                if (n.nodeType !== Node.ELEMENT_NODE) {
                    return;
                }
                remove(n);
            });
        });
    });
    o.observe(document.body, {childList: true, subtree: true});

    console.timeEnd('Remove Yandex Redirect load');
})();