禁用动画

禁用网页上的动画效果

目前为 2019-10-12 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name DisableAnimation
  3. // @name:zh-CN 禁用动画
  4. // @description Disable animation on page
  5. // @description:zh-CN 禁用网页上的动画效果
  6. // @namespace https://greasyfork.org/users/197529
  7. // @version 0.7.2
  8. // @author kkocdko
  9. // @license Unlicense
  10. // @match *://*/*
  11. // @run-at document-start
  12. // ==/UserScript==
  13. 'use strict'
  14.  
  15. runInGrobal(() => {
  16. window.requestAnimationFrame = callback => setTimeout(callback, 200)
  17. })
  18.  
  19. document.head.insertAdjacentHTML('beforeend', `<style>
  20.  
  21. *,
  22. *::before,
  23. *::after {
  24. animation: none !important;
  25. transition: none !important;
  26. }
  27.  
  28. </style>`)
  29.  
  30. function runInGrobal (callback) {
  31. const scriptEl = document.createElement('script')
  32. scriptEl.textContent = callback.toString()
  33. document.head.appendChild(scriptEl)
  34. }