April Fools CSS

Some CSS april fools

目前为 2016-02-20 提交的版本。查看 最新版本

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

QingJ © 2025

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