Waze Editor Clock with Local Time

Display a stylish clock at the bottom center of Waze Editor page synchronized with local time

当前为 2024-05-06 提交的版本,查看 最新版本

// ==UserScript==
// @name         Waze Editor Clock with Local Time
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Display a stylish clock at the bottom center of Waze Editor page synchronized with local time
// @author       Your Name
// @match        https://www.waze.com/*/editor/*
// @include      https://www.waze.com/editor*
// @include      https://www.waze.com/*/editor*
// @include      https://beta.waze.com/editor*
// @include      https://beta.waze.com/*/editor*
// @exclude      https://www.waze.com/user/*
// @exclude      https://www.waze.com/*/user/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Function to create and style clock element
    function createClock() {
        var clock = document.createElement('div');
        clock.style.position = 'fixed';
        clock.style.bottom = '20px'; // Adjust the position as needed
        clock.style.left = '50%';
        clock.style.transform = 'translateX(-50%)';
        clock.style.color = 'white';
        clock.style.fontSize = '20px';
        clock.style.fontFamily = 'Arial, sans-serif';
        clock.style.zIndex = '9999';
        clock.style.padding = '10px 15px'; // Add padding for decoration
        clock.style.borderRadius = '10px'; // Add border radius for decoration
        clock.style.backgroundColor = 'rgba(0, 0, 0, 0.5)'; // Add background color for decoration
        clock.style.boxShadow = '0 2px 5px rgba(0, 0, 0, 0.5)'; // Add shadow for decoration
        return clock;
    }

    // Function to update the clock with local time
    function updateClockWithLocalTime(clock) {
        var now = new Date();
        var hours = now.getHours();
        var minutes = now.getMinutes();
        var timeString = ('0' + hours).slice(-2) + ':' + ('0' + minutes).slice(-2);
        clock.textContent = timeString;
    }

    // Initial setup
    var clock = createClock();
    updateClockWithLocalTime(clock);
    document.body.appendChild(clock);

    // Update the clock every minute
    setInterval(function() {
        updateClockWithLocalTime(clock);
    }, 60000);

})();