Internet Speed Monitor

Monitors your internet speed in Mbps and displays it in a movable panel at the top of the page. The panel can be toggled to show or hide by clicking anywhere on the page. The speed is updated every second. Ideal for tracking internet performance in real-time while browsing.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το 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         Internet Speed Monitor
// @namespace    http://tampermonkey.net/
// @version      1.10
// @description  Monitors your internet speed in Mbps and displays it in a movable panel at the top of the page. The panel can be toggled to show or hide by clicking anywhere on the page. The speed is updated every second. Ideal for tracking internet performance in real-time while browsing.
// @author       Your Name
// @match        *://*/*
// @grant        none
// @license      MIT
// @supportURL   https://github.com/yourusername/your-repository/issues
// ==/UserScript==


(function() {
    'use strict';

    // Create the speed display panel
    const speedPanel = document.createElement('div');
    speedPanel.style.position = 'fixed';
    speedPanel.style.top = '10px';  // Position at top
    speedPanel.style.right = '10px';  // Position at right
    speedPanel.style.zIndex = '9999';
    speedPanel.style.backgroundColor = 'rgba(0, 0, 0, 0.5)'; // Semi-transparent background
    speedPanel.style.color = '#ffffff';
    speedPanel.style.padding = '5px 10px';
    speedPanel.style.borderRadius = '5px';
    speedPanel.style.fontFamily = 'Arial, sans-serif';
    speedPanel.style.fontSize = '12px'; // Smaller font size
    speedPanel.style.boxShadow = '0 0 5px rgba(0, 0, 0, 0.5)'; // Slight shadow for better visibility
    speedPanel.style.cursor = 'pointer'; // Pointer cursor to indicate it can be interacted with
    speedPanel.style.display = 'block'; // Ensure panel is visible initially
    document.body.appendChild(speedPanel);

    // Toggle visibility when clicking anywhere on the page
    document.addEventListener('click', () => {
        if (speedPanel.style.display === 'none') {
            speedPanel.style.display = 'block';
        } else {
            speedPanel.style.display = 'none';
        }
    });

    async function calculateSpeed() {
        const startTime = Date.now();
        try {
            // Test file with known size (adjust URL as needed)
            const response = await fetch('https://httpbin.org/bytes/1000000'); // 1MB file
            const endTime = Date.now();
            const duration = (endTime - startTime) / 1000; // duration in seconds
            const fileSize = 1 * 1024 * 1024 * 8; // 1MB in bits
            const speed = fileSize / duration; // speed in bps
            const speedMbps = speed / (1024 * 1024); // convert to Mbps
            const speedMbpsFormatted = speedMbps.toFixed(2); // format to 2 decimal places
            speedPanel.textContent = `${speedMbpsFormatted} Mbps`;
        } catch (error) {
            speedPanel.textContent = 'Error calculating speed';
            console.error('Error calculating speed:', error);
        }
    }

    // Update speed every 1 second
    setInterval(calculateSpeed, 1000);
})();