magic firefly event time thing

every 10 secs it tells you, visually

目前為 2024-12-07 提交的版本,檢視 最新版本

// ==UserScript==
// @name         magic firefly event time thing
// @namespace    http://tampermonkey.net/
// @version      2.0.5
// @description  every 10 secs it tells you, visually
// @author       Kosuken
// @match        https://florr.io/*
// @grant        none
// @license      MIT
// ==/UserScript==


(function () {
    'use strict';

    // Add a draggable timer display to the screen
    const timerBox = document.createElement('div');
    timerBox.id = 'mff-timer';
    timerBox.style.position = 'fixed';
    timerBox.style.top = '20px';
    timerBox.style.left = '20px';
    timerBox.style.padding = '10px';
    timerBox.style.backgroundColor = 'rgba(30, 30, 30, 0.8)';
    timerBox.style.color = 'white';
    timerBox.style.fontFamily = '"Ubuntu", sans-serif';
    timerBox.style.fontWeight = 'bold';
    timerBox.style.border = '5px solid rgba(40, 40, 40, 0.8)';
    timerBox.style.borderRadius = '8px';
    timerBox.style.zIndex = '10000';
    timerBox.style.cursor = 'move';
    document.body.appendChild(timerBox);

    function updateTimer() {
        const intv = 4732;
        const startT = 1733449900;

        // next
        const Tnow = Math.floor(Date.now() / 1000);
        const nextT = startT + (Math.floor((Tnow - startT) / intv) + 1) * intv;

        // left
        const secsLeft = nextT - Tnow;
        const hours = Math.floor(secsLeft / 3600);
        const minutes = Math.floor((secsLeft % 3600) / 60);
        const seconds = secsLeft % 60;

        // text
        timerBox.innerHTML = `
            <div>next magic fireflies: <br><strong>${new Date(nextT * 1000).toLocaleTimeString()}</strong></div>
            <div>time left: <br><strong>${hours}h ${minutes}m ${seconds}s</strong></div>
        `;
    }

    // update every sex
    setInterval(updateTimer, 1000);
    updateTimer(); // init

    // drag coz no drag gay
    timerBox.onmousedown = function (event) {
        event.preventDefault();
        let shiftX = event.clientX - timerBox.getBoundingClientRect().left;
        let shiftY = event.clientY - timerBox.getBoundingClientRect().top;

        function moveAt(pageX, pageY) {
            timerBox.style.left = pageX - shiftX + 'px';
            timerBox.style.top = pageY - shiftY + 'px';
        }

        function onMouseMove(event) {
            moveAt(event.pageX, event.pageY);
        }

        document.addEventListener('mousemove', onMouseMove);

        timerBox.onmouseup = function () {
            document.removeEventListener('mousemove', onMouseMove);
            timerBox.onmouseup = null;
        };
    };

    timerBox.ondragstart = function () {
        return false;
    };
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址