Neopets Mortog Challenge

It's always raining Mortogs

目前為 2024-10-05 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Neopets Mortog Challenge
// @version      2024.10.05
// @description  It's always raining Mortogs
// @match        *://*.neopets.com/*
// @icon         https://images.neopets.com/new_shopkeepers/t_1900.gif
// @author       Posterboy
// @namespace    https://gf.qytechs.cn/users/1277376
// @run-at       document-end
// ==/UserScript==

(function() {
    'use strict';

    // Adjustable falling speed (in seconds).
    const fallingSpeed = 0.3; // Falling speed in seconds
    const maxVisibleMortogs = 10; // Limit the number of visible Mortogs
    const centralPercentage = 0.9; // Central 90% of the window

    // Preload Mortog images
    const mortogImage = new Image();
    mortogImage.src = 'https://images.neopets.com/randomevents/rain/mortog.png';

    // Create a container for Mortogs
    const mortogContainer = document.createElement('div');
    mortogContainer.style.position = 'fixed';
    mortogContainer.style.top = '0'; // Start from the top
    mortogContainer.style.left = '0';
    mortogContainer.style.width = '100%';
    mortogContainer.style.pointerEvents = 'none';
    mortogContainer.style.zIndex = '9999'; 
    document.body.appendChild(mortogContainer);

    function createFallingMortog() {
        if (mortogContainer.childElementCount >= maxVisibleMortogs) {
            return;
        }

        const img = document.createElement('img');
        img.src = mortogImage.src;
        img.classList.add('falling-mortog'); 
        img.style.position = 'absolute';
        img.style.top = '-100px'; 
        img.style.width = '100px';
        img.style.height = 'auto';

        // Calculate the central position for horizontal spawning
        const viewportWidth = window.innerWidth;
        const centralWidth = viewportWidth * centralPercentage;
        const leftOffset = (viewportWidth - centralWidth) / 2; 
        const randomLeft = Math.floor(Math.random() * (centralWidth - 100)) + leftOffset; 
        img.style.left = `${randomLeft}px`;

        mortogContainer.appendChild(img);

        // Animate falling
        let startTime;
        function animate(time) {
            if (!startTime) startTime = time;
            const elapsed = time - startTime;

            const topPosition = Math.min((elapsed / (fallingSpeed * 1000)) * window.innerHeight, window.innerHeight);
            img.style.top = `${topPosition}px`;

            if (topPosition < window.innerHeight) {
                requestAnimationFrame(animate);
            } else {
                // Instead of removing immediately, fade out
                img.style.transition = 'opacity 0.5s';
                img.style.opacity = '0';
                setTimeout(() => img.remove(), 500); // Remove after fade-out
            }
        }

        requestAnimationFrame(animate);
    }

    // Create X Mortogs per second for Y seconds
    const mortogsPerSecond = 9; // Mortogs per second
    const duration = 60; // How many seconds should this script continue generating Mortogs
    const interval = 1000 / mortogsPerSecond;

    let totalMortogs = mortogsPerSecond * duration;
    const intervalId = setInterval(() => {
        if (totalMortogs <= 0) {
            clearInterval(intervalId);
            return;
        }
        createFallingMortog();
        totalMortogs--;
    }, interval);
})();

QingJ © 2025

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