AnimeStars — блокировка PiP кнопок Opera GX

Блокирует кнопки "Окно в окне" (PiP) у фоновых видео на AnimeStars в браузере Opera GX

// ==UserScript==
// @name         AnimeStars — блокировка PiP кнопок Opera GX
// @namespace    https://animestars.org/
// @version      1.3
// @description  Блокирует кнопки "Окно в окне" (PiP) у фоновых видео на AnimeStars в браузере Opera GX
// @author       Sandr
// @match        *://animestars.org/*
// @match        *://asstars.tv/*
// @match        *://astars.club/*
// @match        *://as1.astars.club/*
// @match        *://as1.asstars.tv/*
// @match        *://as2.asstars.tv/*
// @match        *://asstars.club/*
// @match        *://asstars.online/*
// @license MIT
// @grant        none
// @run-at       document-idle
// ==/UserScript==

(function () {
    "use strict";

    // Список селекторов кнопок Opera GX
    const BAD_SELECTORS = `
        #detach-button-host,
        #video-detach-button,
        #skip-button,
        #send-by-qrcode-button,
        #lucid-mode-button,
        .button-container,
        .custom-button,
        .rgx-button-wrapper
    `;

    // Добавляем CSS, чтобы скрывать кнопки даже если они появились
    const style = document.createElement("style");
    style.textContent = `
        ${BAD_SELECTORS} {
            display: none !important;
            opacity: 0 !important;
            visibility: hidden !important;
            pointer-events: none !important;
        }
    `;
    document.head.appendChild(style);

    // Функция для запрета PiP на видео
    function disablePiP(video) {
        if (!video) return;
        if (video.dataset._pip_disabled === "1") return;
        video.dataset._pip_disabled = "1";

        video.setAttribute("disablePictureInPicture", ""); // стандартный способ
        video.setAttribute("pip", "false"); // кастомный флаг Opera GX
    }

    // Применяем сразу ко всем видео
    document.querySelectorAll("video").forEach(disablePiP);

    // Следим за новыми видео
    const videoObserver = new MutationObserver(mutations => {
        mutations.forEach(m => {
            m.addedNodes.forEach(node => {
                if (node instanceof HTMLVideoElement) {
                    disablePiP(node);
                }
                if (node.querySelectorAll) {
                    node.querySelectorAll("video").forEach(disablePiP);
                }
            });
        });
    });
    videoObserver.observe(document.body, { childList: true, subtree: true });

})();