-
Notifications
You must be signed in to change notification settings - Fork 0
/
userscript.js
81 lines (73 loc) · 5.1 KB
/
userscript.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// ==UserScript==
// @name GeoFS Information Display
// @version 2.4
// @description Displays Speed/Altitude/Heading/VS on the bottom right of the screen
// @author krunchiekrunch
// @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 GPL-3.0
// ==/UserScript==
// Notes
// Pressing 'i' will hide the display
// The AGL display NO LONGER have a offset that varies from aircraft to aircraft. (Since 2.3) - Fixed by GGamerGGuy on Discord
(function() {
'use strict';
// Update display
function updateFlightDataDisplay() {
// Check if geofs.animation.values is available
if (geofs.animation.values) {
// Retrieve and format the required values
var kias = geofs.animation.values.kias ? geofs.animation.values.kias.toFixed(1) : 'N/A';
var mach = geofs.animation.values.mach ? geofs.animation.values.mach.toFixed(2) : 'N/A';
var groundSpeed = geofs.animation.values.groundSpeed ? geofs.animation.values.groundSpeed.toFixed(1) : 'N/A';
var altitude = geofs.animation.values.altitude ? Math.round(geofs.animation.values.altitude) : 'N/A';
var heading = geofs.animation.values.heading360 ? Math.round(geofs.animation.values.heading360) : 'N/A';
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';
// Display css
var flightDataElement = document.getElementById('flightDataDisplay');
if (!flightDataElement) {
flightDataElement = document.createElement('div');
flightDataElement.id = 'flightDataDisplay';
flightDataElement.style.position = 'fixed';
flightDataElement.style.bottom = '0';
flightDataElement.style.right = 'calc(10px + 48px + 16px)';
flightDataElement.style.height = '36px';
flightDataElement.style.minWidth = '64px';
flightDataElement.style.padding = '0 16px';
flightDataElement.style.display = 'inline-block';
flightDataElement.style.fontFamily = '"Roboto", "Helvetica", "Arial", sans-serif';
flightDataElement.style.fontSize = '14px';
flightDataElement.style.textTransform = 'uppercase';
flightDataElement.style.overflow = 'hidden';
flightDataElement.style.willChange = 'box-shadow';
flightDataElement.style.transition = 'box-shadow .2s cubic-bezier(.4,0,1,1), background-color .2s cubic-bezier(.4,0,.2,1), color .2s cubic-bezier(.4,0,.2,1)';
flightDataElement.style.textAlign = 'center';
flightDataElement.style.lineHeight = '36px';
flightDataElement.style.verticalAlign = 'middle';
flightDataElement.style.zIndex = '9999';
flightDataElement.style.pointerEvents = 'none'; // Make the display clickable through
document.body.appendChild(flightDataElement);
}
// Hide the flight data display if 'i' is pressed
document.addEventListener('keydown', function(event) {
if (event.key === 'i') {
flightDataElement.style.display = flightDataElement.style.display === 'none' ? 'inline-block' : 'none';
}
});
flightDataElement.innerHTML = `
<span style="background: 0 0; border: none; border-radius: 2px; color: #000; display: inline-block; padding: 0 8px;">KIAS ${kias}</span> |
<span style="background: 0 0; border: none; border-radius: 2px; color: #000; display: inline-block; padding: 0 8px;">Mach ${mach}</span> |
<span style="background: 0 0; border: none; border-radius: 2px; color: #000; display: inline-block; padding: 0 8px;">GS ${groundSpeed}</span> |
<span style="background: 0 0; border: none; border-radius: 2px; color: #000; display: inline-block; padding: 0 8px;">ALT ${altitude}</span> |
<span style="background: 0 0; border: none; border-radius: 2px; color: #000; display: inline-block; padding: 0 8px;">AGL ${agl}</span> |
<span style="background: 0 0; border: none; border-radius: 2px; color: #000; display: inline-block; padding: 0 8px;">HDG ${heading}</span> |
<span style="background: 0 0; border: none; border-radius: 2px; color: #000; display: inline-block; padding: 0 8px;">V/S ${verticalSpeed === 'N/A' ? 'N/A' : verticalSpeed}</span>
`;
}
}
// Update flight data display every 100ms
setInterval(updateFlightDataDisplay, 100);
})();