DigDig.io Snowfall

Add a snowfall effect to DigDig.io

  1. // ==UserScript==
  2. // @name DigDig.io Snowfall
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Add a snowfall effect to DigDig.io
  6. // @author Elmero me ro meron
  7. // @match *://digdig.io/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. 'use strict';
  14.  
  15. const snowflakeStyle = `
  16. .snowflake {
  17. position: absolute;
  18. width: 10px;
  19. height: 10px;
  20. background-color: #fff;
  21. border-radius: 50%;
  22. pointer-events: none;
  23. opacity: 0.8;
  24. animation: fall linear infinite;
  25. }
  26.  
  27. @keyframes fall {
  28. from {
  29. transform: translateY(-10px) rotate(0deg);
  30. }
  31. to {
  32. transform: translateY(${window.innerHeight}px) rotate(360deg);
  33. }
  34. }
  35. `;
  36.  
  37. const styleElement = document.createElement('style');
  38. styleElement.type = 'text/css';
  39. styleElement.appendChild(document.createTextNode(snowflakeStyle));
  40. document.head.appendChild(styleElement);
  41.  
  42. function createSnowflake() {
  43. const snowflake = document.createElement('div');
  44. snowflake.classList.add('snowflake');
  45. snowflake.style.left = Math.random() * window.innerWidth + 'px';
  46. snowflake.style.animationDuration = Math.random() * 5 + 2 + 's';
  47. document.body.appendChild(snowflake);
  48.  
  49. snowflake.addEventListener('animationiteration', () => {
  50. snowflake.remove();
  51. });
  52. }
  53.  
  54. function createSnowfall() {
  55. setInterval(createSnowflake, 500);
  56. }
  57.  
  58. createSnowfall();
  59. })();

QingJ © 2025

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