Загрузка данных


// ==UserScript==
// @name         GeoFS HD + GPWS Combined
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  HD terrain, ad blocker, and GPWS callouts (Minimums default 350)
// @author       drakeerv + tylerbmusic + ISA1716
// @match        https://www.geo-fs.com/geofs.php?v=*
// @match        https://*.geo-fs.com/geofs.php*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=geo-fs.com
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    "use strict";

    // ==================== HD TERRAIN + AD BLOCK ====================
    const provider = "google";

    window.geofsNewHDState = true;
    window.geofs.geoIpUpdate = function() {
        document.body.classList.add("geofs-hd");

        let ad = document.querySelector('.geofs-adbanner.geofs-adsense-container');
        if (ad) ad.remove();

        switch (provider) {
            case "cache":
                window.geofs.api.imageryProvider = new window.Cesium.UrlTemplateImageryProvider({
                    maximumLevel: 21,
                    hasAlphaChannel: false,
                    url: "http://localhost/map/{z}/{x}/{y}"
                });
                break;
            case "google":
                window.geofs.api.imageryProvider = new window.Cesium.UrlTemplateImageryProvider({
                    maximumLevel: 21,
                    hasAlphaChannel: false,
                    subdomains: ["mt0", "mt1", "mt2", "mt3"],
                    url: "https://{s}.google.com/vt/lyrs=s&x={x}&y={y}&z={z}"
                });
                break;
            case "apple":
                window.geofs.api.imageryProvider = new window.Cesium.UrlTemplateImageryProvider({
                    maximumLevel: 21,
                    hasAlphaChannel: false,
                    subdomains: ["sat-cdn1", "sat-cdn2", "sat-cdn3", "sat-cdn4"],
                    url: "https://{s}.apple-mapkit.com/tile?style=7&size=1&scale=1&z={z}&x={x}&y={y}&v=9651&accessKey=1705988638_4603104305979553294_%2F_Qvq1XXyXG5w0IUYlFOsIQsxLt2ALxm32i%2BAMbLIFD5s%3D"
                });
                break;
            case "bing":
                window.geofs.api.imageryProvider = new window.Cesium.BingMapsImageryProvider({
                    url: "https://dev.virtualearth.net",
                    key: "AjrgR5TNicgFReuFwvNH71v4YeQNkXIB20l63ZMm86mVuBGZPhTHMkdiVq2_9L7x",
                    mapStyle: window.Cesium.BingMapsStyle.AERIAL
                });
                break;
            default: break
        }

        window.geofs.api.setImageryProvider(window.geofs.api.imageryProvider, false);
        window.geofs.api.viewer.terrainProvider = window.geofs.api.flatRunwayTerrainProviderInstance = new window.geofs.api.FlatRunwayTerrainProvider({
            baseProvider: new window.Cesium.CesiumTerrainProvider({
                url: "https://data.geo-fs.com/srtm/",
                requestWaterMask: false,
                requestVertexNormals: true
            }),
            bypass: false,
            maximumLevel: 12
        });
    };

    window.executeOnEventDone("geofsStarted", function() {
        if (window.geofs.api.hdOn === window.geofsNewHDState) return;
        window.jQuery("body").trigger("terrainProviderWillUpdate");
        window.geofs.geoIpUpdate();
        window.geofs.api.hdOn = window.geofsNewHDState;
        window.geofs.api.renderingQuality();
        window.jQuery("body").trigger("terrainProviderUpdate");
    });

    window.executeOnEventDone("afterDeferredload", function() {
        window.geofs.mapXYZ = "https://data.geo-fs.com/osm/{z}/{x}/{y}.png";
    });

    let ad = document.querySelector('.geofs-adbanner.geofs-adsense-container');
    if (ad) ad.remove();


    // ==================== GPWS CALLOUTS (запуск через 8 сек) ====================
    setTimeout(function() {
        window.soundsToggleKey = "u";
        window.soundsOn = true;

        window.a2500 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/2500.wav');
        window.a2000 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/2000.wav');
        window.a1000 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/1000.wav');
        window.a500 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/500.wav');
        window.a400 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/400.wav');
        window.a300 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/300.wav');
        window.a200 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/200.wav');
        window.a100 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/100.wav');
        window.a50 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/50.wav');
        window.a40 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/40.wav');
        window.a30 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/30.wav');
        window.a20 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/20.wav');
        window.a10 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/10.wav');
        window.aRetard = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/retard.wav');
        window.a5 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/5.wav');
        window.stall = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/stall.wav');
        window.glideSlope = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/glideslope.wav');
        window.tooLowFlaps = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/too-low_flaps.wav');
        window.tooLowGear = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/too-low_gear.wav');
        window.apDisconnect = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/ap-disconnect.wav');
        window.minimumBaro = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/minimum.wav');
        window.dontSink = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/dont-sink.wav');
        window.masterA = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/masterAlarm.wav');
        window.bankAngle = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/bank-angle.wav');
        window.overspeed = new Audio('https://github.com/ISA1716/GeoFS-GPWS-Alarms-and-Callouts/raw/refs/heads/main/Overspeed%20Airbus.mp3');
        
        window.justPaused = false;
        window.masterA.loop = true;
        window.bankAngle.loop = true;
        window.overspeed.loop = true;
        window.iminimums = false;
        window.i2500 = false;
        window.i2000 = false;
        window.i1000 = false;
        window.i500 = false;
        window.i400 = false;
        window.i300 = false;
        window.i200 = false;
        window.i100 = false;
        window.i50 = false;
        window.i40 = false;
        window.i30 = false;
        window.i20 = false;
        window.i10 = false;
        window.i7 = false;
        window.i5 = false;
        window.gpwsRefreshRate = 100;
        window.willTheDoorFallOff = false;
        window.didAWheelFall = false;

        function isInRange(i, a, vs) {
            if (i >= 100) {
                if ((i <= a+10) && (i >= a-10)) return true;
            } else if (i >= 10) {
                if ((i < a+4) && (i > a-4)) return true;
            } else {
                if (i <= a+1 && i >= a-1) return true;
            }
            return false;
        }

        window.wasAPOn = false;

        var flightDataElement = document.getElementById('flightDataDisplay1');
        if (!flightDataElement) {
            var bottomDiv = document.getElementsByClassName('geofs-ui-bottom')[0];
            flightDataElement = document.createElement('div');
            flightDataElement.id = 'flightDataDisplay1';
            flightDataElement.classList = 'mdl-button';
            bottomDiv.appendChild(flightDataElement);
        }
        // ⬇️ ЗНАЧЕНИЕ 350 ПО УМОЛЧАНИЮ ⬇️
        flightDataElement.innerHTML = '<input style="background: 0 0; border: none; border-radius: 2px; color: #000; display: inline-block; padding: 0 8px;" placeholder="Minimums (Baro)" id="minimums" value="350">';

        function updateGPWS() {
            if (typeof geofs.animation.values != 'undefined' && !geofs.isPaused()) {
                if (window.justPaused) window.justPaused = false;

                window.willTheDoorFallOff = geofs.aircraft.instance.aircraftRecord.name.includes("Boeing");
                window.isAsOldAsYourMom = geofs.aircraft.instance.aircraftRecord.name.includes("757") || geofs.aircraft.instance.aircraftRecord.name.includes("767");

                if (window.isAsOldAsYourMom && !window.wasAsOldAsYourMom) {
                    window.a2500 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/b2500.wav');
                    window.a2000 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/b2000.wav');
                    window.a1000 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/o1000.wav');
                    window.a500 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/o500.wav');
                    window.a400 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/o400.wav');
                    window.a300 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/o300.wav');
                    window.a200 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/o200.wav');
                    window.a100 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/o100.wav');
                    window.a50 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/o50.wav');
                    window.a40 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/o40.wav');
                    window.a30 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/o30.wav');
                    window.a20 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/o20.wav');
                    window.a10 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/o10.wav');
                    window.a5 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/b5.wav');
                    window.stall = new Audio('https://github.com/ISA1716/GeoFS-GPWS-Alarms-and-Callouts/raw/refs/heads/main/Boeing%20737%20Stall%20Alarm.mp3');
                    window.glideSlope = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/oglideslope.wav');
                    window.tooLowFlaps = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/otoo-low_flaps.wav');
                    window.tooLowGear = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/otoo-low_gear.wav');
                    window.apDisconnect = new Audio('https://github.com/ISA1716/GeoFS-GPWS-Alarms-and-Callouts/raw/refs/heads/main/Boeing%20Autopilot%20Disengage.mp3');
                    window.minimumBaro = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/ominimums.wav');
                    window.dontSink = new Audio('https://github.com/ISA1716/GeoFS-GPWS-Alarms-and-Callouts/raw/refs/heads/main/Sink%20Rate%20Pull%20Up%20Boeing.mp3');
                    window.masterA = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/bmasterAlarm.wav');
                    window.bankAngle = new Audio('https://github.com/ISA1716/GeoFS-GPWS-Alarms-and-Callouts/raw/refs/heads/main/Bank%20Angle%20Boeing.mp3');
                    window.overspeed = new Audio('https://github.com/ISA1716/GeoFS-GPWS-Alarms-and-Callouts/raw/refs/heads/main/Boeing%20Overspeed%20Alarm.mp3');
                    window.masterA.loop = true;
                    window.bankAngle.loop = true;
                    window.overspeed.loop = true;
                } else if (window.willTheDoorFallOff && !window.didAWheelFall && !window.isAsOldAsYourMom) {
                    window.a2500 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/b2500.wav');
                    window.a2000 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/b2000.wav');
                    window.a1000 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/b1000.wav');
                    window.a500 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/b500.wav');
                    window.a400 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/b400.wav');
                    window.a300 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/b300.wav');
                    window.a200 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/b200.wav');
                    window.a100 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/b100.wav');
                    window.a50 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/b50.wav');
                    window.a40 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/b40.wav');
                    window.a30 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/b30.wav');
                    window.a20 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/b20.wav');
                    window.a10 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/b10.wav');
                    window.a5 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/b5.wav');
                    window.stall = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/bstall.wav');
                    window.glideSlope = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/bglideslope.wav');
                    window.tooLowFlaps = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/btoo-low_flaps.wav');
                    window.tooLowGear = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/btoo-low_gear.wav');
                    window.apDisconnect = new Audio('https://github.com/ISA1716/GeoFS-GPWS-Alarms-and-Callouts/raw/refs/heads/main/Boeing%20Autopilot%20Disengage.mp3');
                    window.minimumBaro = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/bminimums.wav');
                    window.dontSink = new Audio('https://github.com/ISA1716/GeoFS-GPWS-Alarms-and-Callouts/raw/refs/heads/main/Sink%20Rate%20Pull%20Up%20Boeing.mp3');
                    window.masterA = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/bmasterAlarm.wav');
                    window.bankAngle = new Audio('https://github.com/ISA1716/GeoFS-GPWS-Alarms-and-Callouts/raw/refs/heads/main/Bank%20Angle%20Boeing.mp3');
                    window.overspeed = new Audio('https://github.com/ISA1716/GeoFS-GPWS-Alarms-and-Callouts/raw/refs/heads/main/Boeing%20Overspeed%20Alarm.mp3');
                    window.masterA.loop = true;
                    window.bankAngle.loop = true;
                    window.overspeed.loop = true;
                } else if (!window.willTheDoorFallOff && window.didAWheelFall) {
                    window.a2500 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/2500.wav');
                    window.a2000 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/2000.wav');
                    window.a1000 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/1000.wav');
                    window.a500 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/500.wav');
                    window.a400 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/400.wav');
                    window.a300 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/300.wav');
                    window.a200 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/200.wav');
                    window.a100 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/100.wav');
                    window.a50 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/50.wav');
                    window.a40 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/40.wav');
                    window.a30 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/30.wav');
                    window.a20 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/20.wav');
                    window.a10 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/10.wav');
                    window.a5 = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/5.wav');
                    window.stall = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/stall.wav');
                    window.glideSlope = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/glideslope.wav');
                    window.tooLowFlaps = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/too-low_flaps.wav');
                    window.tooLowGear = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/too-low_gear.wav');
                    window.apDisconnect = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/ap-disconnect.wav');
                    window.minimumBaro = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/minimum.wav');
                    window.dontSink = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/dont-sink.wav');
                    window.masterA = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/masterAlarm.wav');
                    window.bankAngle = new Audio('https://tylerbmusic.github.io/GPWS-files_geofs/bank-angle.wav');
                    window.overspeed = new Audio('https://github.com/ISA1716/GeoFS-GPWS-Alarms-and-Callouts/raw/refs/heads/main/Overspeed%20Airbus.mp3');
                    window.masterA.loop = true;
                    window.bankAngle.loop = true;
                    window.overspeed.loop = true;
                }

                var minimum = ((document.getElementById("minimums") !== null) && document.getElementById("minimums").value !== undefined) ? Number(document.getElementById("minimums").value) : undefined;
                var agl = (geofs.animation.values.altitude !== undefined && geofs.animation.values.groundElevationFeet !== undefined) ? Math.round((geofs.animation.values.altitude - geofs.animation.values.groundElevationFeet) + (geofs.aircraft.instance.collisionPoints[geofs.aircraft.instance.collisionPoints.length - 2].worldPosition[2]*3.2808399)) : 'N/A';
                var verticalSpeed = geofs.animation.values.verticalSpeed !== undefined ? Math.round(geofs.animation.values.verticalSpeed) : 'N/A';

                var glideslope;
                if (geofs.animation.getValue("NAV1Direction") && (geofs.animation.getValue("NAV1Distance") !== geofs.runways.getNearestRunway([geofs.nav.units.NAV1.navaid.lat,geofs.nav.units.NAV1.navaid.lon,0]).lengthMeters*0.185)) {
                    glideslope = (geofs.animation.getValue("NAV1Direction") === "to") ? Number((Math.atan(((geofs.animation.values.altitude/3.2808399+(geofs.aircraft.instance.collisionPoints[geofs.aircraft.instance.collisionPoints.length - 2].worldPosition[2]+0.1))-geofs.nav.units.NAV1.navaid.elevation) / (geofs.animation.getValue("NAV1Distance")+geofs.runways.getNearestRunway([geofs.nav.units.NAV1.navaid.lat,geofs.nav.units.NAV1.navaid.lon,0]).lengthMeters*0.185))*RAD_TO_DEGREES).toFixed(1)) : Number((Math.atan(((geofs.animation.values.altitude/3.2808399+(geofs.aircraft.instance.collisionPoints[geofs.aircraft.instance.collisionPoints.length - 2].worldPosition[2]+0.1))-geofs.nav.units.NAV1.navaid.elevation) / Math.abs(geofs.animation.getValue("NAV1Distance")-geofs.runways.getNearestRunway([geofs.nav.units.NAV1.navaid.lat,geofs.nav.units.NAV1.navaid.lon,0]).lengthMeters*0.185))*RAD_TO_DEGREES).toFixed(1));
                } else {
                    glideslope = undefined;
                }

                if (window.soundsOn) {
                    if (((geofs.aircraft.instance.stalling && !geofs.aircraft.instance.groundContact) || (geofs.nav.units.NAV1.navaid !== null && (agl > 100 && (glideslope < (geofs.nav.units.NAV1.navaid.slope - 1.5) || (glideslope > geofs.nav.units.NAV1.navaid.slope + 2)))) || (!geofs.aircraft.instance.groundContact && agl < 300 &