Created
October 1, 2024 20:52
-
-
Save arinoki/6bdb0d1362976e0dac2f48074a793999 to your computer and use it in GitHub Desktop.
script for tampermonkey to disable all website animations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Disable all animations | |
| // @version 1.0 | |
| // @author mortenmoulder | |
| // @include * | |
| // @grant GM_addStyle | |
| // @grant GM_addElement | |
| // @description Animation Remover | |
| // ==/UserScript== | |
| //remove animations globally | |
| GM_addStyle("* { animation-duration: 0s !important; animation-play-state: paused; }"); | |
| var ignoreElements = []; | |
| //remove animations inside shadow DOM elements | |
| function findShadowRoots(elements) { | |
| for (var i = 0; i < elements.length; i++) { | |
| if(elements[i].shadowRoot) { | |
| if(ignoreElements.includes(elements[i].shadowRoot) == false) { | |
| GM_addElement(elements[i].shadowRoot, 'style', { textContent: '* { animation-duration: 0s !important; animation-play-state: paused;' }); | |
| ignoreElements.push(elements[i].shadowRoot); | |
| } | |
| findShadowRoots(elements[i].shadowRoot.querySelectorAll("*")); | |
| } | |
| } | |
| } | |
| //remove animations every 1 second | |
| setInterval(() => { | |
| var allNodes = document.querySelectorAll('*'); | |
| findShadowRoots(allNodes); | |
| }, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment