April Fools CSS

Some CSS april fools

当前为 2014-02-22 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name April Fools CSS
  3. // @description Some CSS april fools
  4. // @author jerone
  5. // @namespace https://github.com/jerone/AprilFoolsCSS
  6. // @include *
  7. // @version 1.1
  8. // ==/UserScript==
  9.  
  10.  
  11. if(window.top===window){
  12.  
  13. var duration = 2000, // [Integer, positive, miliseconds] This controls the duration of an april fool item;
  14. interval = 8000; // [Integer, positive, miliseconds] This controls the interval of the next april fool;
  15.  
  16. var aprilFools = [ // [String] April fools in CSS; Use {duration} for a dynamic duration;
  17. "img { \
  18. -webkit-transform: rotate(180deg); \
  19. -moz-transform: rotate(180deg); \
  20. -ms-transform: rotate(180deg); \
  21. -o-transform: rotate(180deg); \
  22. transform: rotate(180deg); \
  23. }",
  24. "body { \
  25. -webkit-transform: rotate(1deg); \
  26. -moz-transform: rotate(1deg); \
  27. -ms-transform: rotate(1deg); \
  28. -o-transform: rotate(1deg); \
  29. transform: rotate(1deg); \
  30. }",
  31. "body { \
  32. -webkit-perspective: 300px; \
  33. -moz-perspective: 300px; \
  34. -ms-perspective: 300px; \
  35. perspective: 300px; \
  36. -webkit-transform: rotateY(180deg); \
  37. -moz-transform: rotateY(180deg); \
  38. -ms-transform: rotateY(180deg); \
  39. transform: rotateY(180deg); \
  40. -webkit-transform-style: preserve-3d; \
  41. -moz-transform-style: preserve-3d; \
  42. -ms-transform-style: preserve-3d; \
  43. transform-style: preserve-3d; \
  44. }",
  45. "img { \
  46. -webkit-transform: scale(0.8); \
  47. -moz-transform: scale(0.8); \
  48. -ms-transform: scale(0.8); \
  49. -o-transform: scale(0.8); \
  50. transform: scale(0.8); \
  51. }",
  52. "img { -webkit-animation: spin {duration}s linear infinite; } \
  53. @-webkit-keyframes spin { \
  54. 0% { -webkit-transform: rotate(0deg); } \
  55. 100% { -webkit-transform: rotate(360deg); } \
  56. }",
  57. "body { -webkit-animation: rainbow {duration}s infinite; } \
  58. @-webkit-keyframes rainbow { \
  59. 100% { -webkit-filter: hue-rotate(360deg); } \
  60. }",
  61. ],
  62. aprilFool = 0, aprilFooled = 0;
  63.  
  64. interval = Math.abs(interval);
  65. duration = Math.max(1000, Math.abs(duration));
  66.  
  67. window.setInterval(function(){
  68. do { aprilFool = Math.floor(Math.random() * aprilFools.length);
  69. } while(aprilFool === aprilFooled);
  70. document.documentElement.classList.add("aprilfool" + (aprilFooled = aprilFool));
  71. window.console&&console.log("added aprilfool" + aprilFool);
  72. window.setTimeout(function(){
  73. document.documentElement.classList.remove("aprilfool" + aprilFooled);
  74. window.console&&console.log("removed aprilfool" + aprilFool);
  75. }, duration);
  76. }, interval + duration + 10);
  77.  
  78. for(var aprilFool in aprilFools){
  79. GM_addStyle(".aprilfool" + aprilFool + " " + aprilFools[aprilFool].replace("{duration}", duration/1000));
  80. }
  81. }

QingJ © 2025

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