Remove yandex mail ads

Removes add from yandex mail

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.

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.

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

// ==UserScript==
// @name         Remove yandex mail ads
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Removes add from yandex mail
// @author       Can Kurt
// @match        https://mail.yandex.ru/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=yandex.ru<
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    var nonAddKeys = ["box=fake-head-background-box", "box=toolbar-box", "box=infoline-box", "box=right-box", "box=toolbar-box", "box=advanced-search-box"]

    setInterval(function () {
        var element;
        element = document.querySelector(".ns-view-react-left-column");
        if(element) {
            element.nextElementSibling.remove()
        }

        element = document.querySelector(".mail-Layout-Content");
        if(element) {
            for (const elm of element.children) {
                var data_key = elm.getAttribute("data-key");
                if(data_key && !nonAddKeys.includes(data_key)) {
                    elm.remove()
                }
            }
        }
    }, 100);
})();