Yandex, I'm taken!

Убирает назойливый баннер «Сделать Яндекс поиском по умолчанию?»

// ==UserScript==
// @name         Yandex, I'm taken!
// @namespace    http://tampermonkey.net/
// @version      1.4
// @description  Убирает назойливый баннер «Сделать Яндекс поиском по умолчанию?»
// @author       Echo91
// @match        *://ya.ru/*
// @match        *://yandex.ru/*
// @license      MIT
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const unwantedTexts = [
        /Сделать Яндекс основным поиском/i,
        /Яндекс Браузер/i,
        /Я\.Браузер/i
    ];

    function shouldRunHere() {
        const url = location.href;
        if (url.startsWith("https://ya.ru/")) return true;
        if (url.startsWith("https://yandex.ru/") && (
            url === "https://yandex.ru/" ||
            url.includes("/search")
        )) return true;
        return false;
    }

    function showNotification(text) {
        const note = document.createElement("div");
        note.textContent = text;
        Object.assign(note.style, {
            position: "fixed",
            bottom: "20px",
            right: "20px",
            background: "rgba(0,0,0,0.75)",
            color: "#fff",
            padding: "10px 15px",
            borderRadius: "8px",
            fontSize: "14px",
            zIndex: "99999",
            fontFamily: "sans-serif",
            boxShadow: "0 2px 6px rgba(0,0,0,0.3)",
            transition: "opacity 0.5s ease"
        });
        document.body.appendChild(note);

        // Убираем через 3 секунды
        setTimeout(() => {
            note.style.opacity = "0";
            setTimeout(() => note.remove(), 500);
        }, 3000);
    }

    function removeBanner() {
        if (!shouldRunHere()) return;

        document.querySelectorAll('.Distribution-Popup, .Distribution-Actions, [class*="Distribution"]').forEach(el => {
            if (el.innerText && unwantedTexts.some(rx => rx.test(el.innerText))) {
                console.log("Удалён баннер Яндекса:", el.innerText.trim());
                el.remove();
                showNotification("😤Yandex, I'm taken!😤");
            }
        });

        const denyBtn = [...document.querySelectorAll('button, a')]
            .find(el => el.innerText && el.innerText.match(/Нет/i));
        if (denyBtn) {
            denyBtn.click();
            console.log("Автоматически нажата кнопка 'Нет'");
            showNotification("😤Yandex, I'm taken!😤");
        }
    }

    removeBanner();
    const observer = new MutationObserver(removeBanner);
    observer.observe(document.body, { childList: true, subtree: true });
})();