[Flightradar24] Combo FlightRadar24 Script

Changes: Removes ad container on the bottom right, Refreshes every 30 minutes to bypass 30 minute timeout, Adds the aircraft count on the title (you need the statistic widget enabled!)

< 脚本 [Flightradar24] Combo FlightRadar24 Script 的反馈

评价:好评 - 脚本运行良好

§
发布于:2025-07-24
编辑于:2025-07-24

Thank you for this! I've modified it to remove the new horrid sidebar and adjusted the the sidebar spacing at the top:

// ==UserScript==
// @name         [Flightradar24] Combo Utility Script (Final)
// @namespace    HKR
// @match        https://www.flightradar24.com/*
// @grant        none
// @version      1.4.5
// @license      MIT
// @author       Modified by user
// @description  Removes ads/sidebar, adjusts layout, updates title with aircraft count, and auto-refreshes
// @run-at       document-idle
// ==/UserScript==

// ✅ Remove ad and sidebar elements when they appear
function removeElements() {
    const ad = document.getElementById("primisAdContainer");
    const sidebar = document.querySelector('[data-testid="sidebar__container"]');

    if (ad) {
        ad.remove();
        console.log("✅ Ad container removed");
    }

    if (sidebar) {
        sidebar.remove();
        console.log("✅ Sidebar removed");
    }
}

// ✅ Observe DOM for late-added elements
const observer = new MutationObserver(removeElements);
observer.observe(document.body, { childList: true, subtree: true });

// ✅ Inject CSS to eliminate spacing from .right-sidebar and restore layout
function overrideSidebarCSS() {
    const style = document.createElement("style");
    style.textContent = `
        .right-sidebar {
            right: 0 !important;
        }

        .main-container,
        .mapView--content,
        .leaflet-container {
            right: 0 !important;
            margin-right: 0 !important;
            padding-right: 0 !important;
        }

        body {
            overflow-x: hidden !important;
        }
    `;
    document.head.appendChild(style);
    console.log("✅ CSS overrides applied to remove sidebar spacing");
}

// ✅ Aircraft count → document.title
function updateDocumentTitle() {
    const statisticsWidget = document.querySelector('[data-widget-type="statistics"]');
    if (statisticsWidget) {
        const textElement = statisticsWidget.querySelector('.font-normal');
        if (textElement) {
            const parts = textElement.textContent.trim().split('/');
            const firstNumber = parts[0]?.replace(',', '').trim();
            if (firstNumber) {
                document.title = `[${firstNumber}] Flightradar24`;
                return;
            }
        }
    }
    document.title = '[Error] Flightradar24';
}

// ✅ Run cleanup and CSS injection after slight delay for stability
setTimeout(() => {
    removeElements();
    overrideSidebarCSS();
}, 1000);

// ✅ Keep title updated every second
setInterval(updateDocumentTitle, 1000);
updateDocumentTitle();

// ✅ Refresh after ~30 minutes
setTimeout(() => {
    console.log("🔁 Refreshing page after 30 minutes...");
    location.reload();
}, 1798000);

发布留言

登录(不可用)以发布留言。

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址