Flightradar24 Remove YouTube Ad Panel

Automatically remove the YouTube ad panel on the right side of Flightradar24

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Flightradar24 Remove YouTube Ad Panel
// @name:zh-CN   Flightradar24 移除右侧 YouTube 广告面板
// @namespace    https://www.xuxuclassmate.com/
// @author       XuXuClassMate
// @version      1.0
// @description  Automatically remove the YouTube ad panel on the right side of Flightradar24
// @description:zh-CN 自动移除 Flightradar24 右侧的 YouTube 广告视频面板
// @match        https://www.flightradar24.com/*
// @icon         https://cdn.brandfetch.io/id4dL2JtAC/w/400/h/400/theme/dark/icon.jpeg?c=1dxbfHSJFAPEGdCLU4o5B
// @grant        none
// @license      MIT
// ==/UserScript==


(function () {
    'use strict';

    /**
     * 移除 Flightradar24 右侧广告面板
     * Remove the right-side advertisement panel on Flightradar24
     */
    function removeSidebar() {
        const sidebar = document.querySelector('aside[data-testid="sidebar__container"]');
        if (sidebar) {
            sidebar.remove();
            console.log('✅ Flightradar24 右侧广告面板已移除 / Ad panel removed');
        }
    }

    // 页面加载完成后执行一次
    // Run once after the page is fully loaded
    window.addEventListener('load', () => {
        removeSidebar();

        // 监听 DOM 变化,防止广告面板重新插入
        // Observe DOM changes to prevent the ad panel from reappearing
        const observer = new MutationObserver(removeSidebar);
        observer.observe(document.body, { childList: true, subtree: true });
    });
})();