No Animations

Clear all animations on websites

目前为 2023-10-12 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name No Animations
  3. // @namespace No Animations Script
  4. // @version 2.1
  5. // @description Clear all animations on websites
  6. // @author Nameniok
  7. // @match *://*/*
  8. // @license MIT
  9. // @grant unsafeWindow
  10. // ==/UserScript==
  11.  
  12. const isSameOrigin = (url) => {
  13. const currentOrigin = window.location.origin;
  14. return url.startsWith(currentOrigin);
  15. };
  16.  
  17. const style = document.createElement('style');
  18. style.type = 'text/css';
  19. style.innerHTML = `
  20. * {
  21. transition: none !important;
  22. transition-property: none !important;
  23. transition-duration: 0s !important;
  24. transition-delay: 0s !important;
  25. transition-timing-function: initial !important;
  26. -webkit-transition: none !important;
  27. -moz-transition: none !important;
  28. -o-transition: none !important;
  29. animation-delay: none !important;
  30. animation-duration: none !important;
  31. -webkit-animation-delay: 0 !important;
  32. -webkit-animation-duration: 0 !important;
  33. -moz-animation-delay: 0 !important;
  34. -moz-animation-duration: 0 !important;
  35. -ms-animation-delay: 0 !important;
  36. -ms-animation-duration: 0 !important;
  37. -o-animation-delay: 0 !important;
  38. -o-animation-duration: 0 !important;
  39. scroll-behavior: auto !important;
  40. marquee-style: none !important;
  41. -moz-scroll-behavior: auto !important;
  42. -moz-marquee-style: none !important;
  43. }
  44.  
  45. *::before, *::after, *::hover, *::active {
  46. transition: none !important;
  47. transition-property: none !important;
  48. transition-duration: 0s !important;
  49. transition-timing-function: initial !important;
  50. -webkit-transition: none !important;
  51. animation-delay: none !important;
  52. animation-duration: none !important;
  53. -webkit-animation-delay: 0 !important;
  54. -webkit-animation-duration: 0 !important;
  55. -moz-animation-delay: 0 !important;
  56. -moz-animation-duration: 0 !important;
  57. -ms-animation-delay: 0 !important;
  58. -ms-animation-duration: 0 !important;
  59. box-shadow: none;
  60. }
  61.  
  62. *:before, *:after, *:hover, *:active {
  63. transition: none !important;
  64. transition-property: none !important;
  65. transition-duration: 0s !important;
  66. transition-timing-function: initial !important;
  67. -webkit-transition: none !important;
  68. animation-delay: none !important;
  69. animation-duration: none !important;
  70. -webkit-animation-delay: 0 !important;
  71. -webkit-animation-duration: 0 !important;
  72. -moz-animation-delay: 0 !important;
  73. -moz-animation-duration: 0 !important;
  74. -ms-animation-delay: 0 !important;
  75. -ms-animation-duration: 0 !important;
  76. }
  77.  
  78. @keyframes {
  79. from {
  80.  
  81. }
  82. to {
  83.  
  84. }
  85. }
  86.  
  87. img[src^="https://i.ytimg.com/an_webp/"] {
  88. display: none !important;
  89. }
  90.  
  91. img[src*="/hqdefault.jpg"] {
  92. display: initial !important;
  93. }
  94. `;
  95.  
  96. // Dodaj style do head
  97. document.head.appendChild(style);
  98.  
  99. // Blokowanie animowanych obrazków z YouTube
  100. const blockedUrlPrefix = 'https://i.ytimg.com/an_webp/';
  101. const blockImageLoading = (event) => {
  102. const src = event.target.src || '';
  103. if (src.startsWith(blockedUrlPrefix) || src.endsWith('.webp')) {
  104. event.preventDefault();
  105. event.target.style.display = 'none';
  106. }
  107. };
  108.  
  109. unsafeWindow.addEventListener('beforeload', blockImageLoading, true);
  110.  
  111.  
  112. //Pause all HTML5 videos on load (https://greasyfork.org/en/scripts/6487-pause-all-html5-videos-on-load/code)
  113. var videos = document.getElementsByTagName('video');
  114. window.addEventListener('load', stopVideo, false);
  115.  
  116. function stopVideo() {
  117. for (var i = 0; i < videos.length; i++) {
  118. videos[i].pause();
  119. videos[i].currentTime = 0; // Poprawione odwołanie do currentTime
  120. }
  121. }
  122.  
  123.  
  124. // Funkcja do usuwania animacji z reguł animacji keyframes
  125. function removeAnimations() {
  126. // Funkcja do usuwania animacji z reguł animacji keyframes
  127. let styleSheets = Array.from(document.styleSheets);
  128. styleSheets.forEach((styleSheet) => {
  129. if (!styleSheet.href || isSameOrigin(styleSheet.href)) {
  130. try {
  131. let cssRules = Array.from(styleSheet.cssRules);
  132. cssRules.forEach((rule) => {
  133. if (rule.type === CSSRule.KEYFRAMES_RULE) {
  134. let keyframes = Array.from(rule.cssRules);
  135. keyframes.forEach((keyframe) => {
  136. keyframe.style.animation = "none";
  137. keyframe.style.animationName = "none";
  138. });
  139. }
  140. });
  141. } catch (error) {
  142. console.error("Error accessing CSS rules:", error);
  143. }
  144. }
  145. });
  146. }
  147.  
  148.  
  149. // Znajdź i dezaktywuj animacje fadeIn
  150. function deactivateFadeIn() {
  151. // Znajdź i dezaktywuj animacje fadeIn
  152. let scripts = document.querySelectorAll("script");
  153. scripts.forEach((script) => {
  154. let scriptContent = script.textContent || script.innerText;
  155. if (scriptContent.includes("fadeIn(")) {
  156. script.textContent = scriptContent.replace(/fadeIn\([^)]*\)/g, "fadeIn(0)");
  157. }
  158. });
  159. }
  160.  
  161. // Update specific animations
  162. function updateSpecificAnimations() {
  163. // Update specific animations
  164. let transitionElements = document.querySelectorAll("*");
  165. transitionElements.forEach((element) => {
  166. let computedStyle = window.getComputedStyle(element);
  167. let transition = computedStyle.getPropertyValue("transition");
  168. if (transition.includes("flex") || transition.includes("filter")) {
  169. element.style.transition = transition.replace(/flex[^,]*|filter[^,]*/g, "none");
  170. }
  171. });
  172. }
  173.  
  174. removeAnimations();
  175. deactivateFadeIn();
  176. updateSpecificAnimations();