Flight Simulator Chart Downloader

Adds a download button for flight simulator charts

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         Flight Simulator Chart Downloader
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Adds a download button for flight simulator charts
// @author       jtpotato
// @match        https://planner.flightsimulator.com/*
// @grant        none
// @license      GNU GPLv3
// ==/UserScript==

(function() {
    'use strict';

    // Create and style the download button
    const downloadBtn = document.createElement('button');
    downloadBtn.innerHTML = 'Download Chart';
    downloadBtn.style.position = 'fixed';
    downloadBtn.style.top = '80px';
    downloadBtn.style.right = '80px';
    downloadBtn.style.zIndex = '9999';
    downloadBtn.style.padding = '10px 20px';
    downloadBtn.style.backgroundColor = '#0078d4';
    downloadBtn.style.color = 'white';
    downloadBtn.style.border = 'none';
    downloadBtn.style.borderRadius = '5px';
    downloadBtn.style.cursor = 'pointer';
    downloadBtn.addEventListener('mouseover', () => downloadBtn.style.backgroundColor = '#006cbd');
    downloadBtn.addEventListener('mouseout', () => downloadBtn.style.backgroundColor = '#0078d4');

    // Add click handler
    downloadBtn.addEventListener('click', () => {
        const chartImage = document.getElementById('chart-preview-image');

        if (chartImage && chartImage.src) {
            // Create temporary link to trigger download
            const link = document.createElement('a');
            link.href = chartImage.src;
            link.download = `flight_chart_${Date.now()}.png`;  // Generates unique filename
            document.body.appendChild(link);
            link.click();
            document.body.removeChild(link);
        } else {
            alert('Chart image not found!');
        }
    });

    // Add button to the page when DOM is loaded
    // window.addEventListener('DOMContentLoaded', () => {
      console.log("Inserted Button!")
        document.body.appendChild(downloadBtn);
    // });
})();