TesterTV_Let_It_Snow

Make it snow on the webpage

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         TesterTV_Let_It_Snow
// @namespace    https://greasyfork.org/ru/scripts/482343-testertv-let-it-snow/code
// @version      2023.12.16
// @description  Make it snow on the webpage
// @license      GPL version 3 or any later version
// @author       TesterTV
// @match        https://*/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Create a snowflake element
    function createSnowflake() {
        const snowflake = document.createElement('div');
        snowflake.innerHTML = '❄️';
        snowflake.style.position = 'fixed';
        snowflake.style.top = '0';
        snowflake.style.left = Math.random() * window.innerWidth + 'px';
        snowflake.style.fontSize = Math.random() * 10 + 5 + 'px';
        snowflake.style.opacity = Math.random();
        snowflake.style.userSelect = 'none';
        snowflake.style.pointerEvents = 'none';
        document.body.appendChild(snowflake);
        return snowflake;
    }

    // Move the snowflake down the page
    function moveSnowflake(snowflake) {
        const speed = Math.random() * 5 + 1;
        const interval = setInterval(() => {
            const currentTop = parseFloat(snowflake.style.top);
            if (currentTop < window.innerHeight) {
                snowflake.style.top = currentTop + speed + 'px';
            } else {
                snowflake.style.top = '0';
            }
        }, 50);
    }

    // Create and move snowflakes
    for (let i = 0; i < 100; i++) {
        const snowflake = createSnowflake();
        moveSnowflake(snowflake);
    }
})();