Skip to content

Instantly share code, notes, and snippets.

@arinoki
Created October 1, 2024 20:52
Show Gist options
  • Select an option

  • Save arinoki/6bdb0d1362976e0dac2f48074a793999 to your computer and use it in GitHub Desktop.

Select an option

Save arinoki/6bdb0d1362976e0dac2f48074a793999 to your computer and use it in GitHub Desktop.
script for tampermonkey to disable all website animations
// ==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