Last active
April 17, 2016 23:05
-
-
Save noromanba/2fc4c8dc496dbe8d2050e42484bd9b40 to your computer and use it in GitHub Desktop.
slowdown overdo animation on Amazon (Prime) Music CloudPlayer for UserScript
This file contains 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 AMCP calm down | |
// @namespace http://noromanba.flavors.me | |
// @description slowdown overdo animation on Amazon (Prime) Music CloudPlayer for UserScript | |
// @include https://www.amazon.tld/gp/dmusic/cloudplayer/* | |
// @include https://music.amazon.tld/* | |
// @grant none | |
// @noframes | |
// @run-at document-start | |
// @version 2016.04.17.3 | |
// @homepage https://gist.github.com/noromanba/2fc4c8dc496dbe8d2050e42484bd9b40 | |
// @downloadURL https://gist.github.com/noromanba/2fc4c8dc496dbe8d2050e42484bd9b40/raw/amcp-calmdown.user.js | |
// @license MIT License http://nrm.mit-license.org/2016 | |
// @author noromanba http://noromanba.flavors.me | |
// @icon https://upload.wikimedia.org/wikipedia/commons/thumb/a/ab/United_States_sign_-_Slow.svg/32px-United_States_sign_-_Slow.svg.png | |
// @icon64 https://upload.wikimedia.org/wikipedia/commons/thumb/a/ab/United_States_sign_-_Slow.svg/64px-United_States_sign_-_Slow.svg.png | |
// ==/UserScript== | |
// Icon (PD by Fry1989) | |
// https://commons.wikimedia.org/wiki/File%3AUnited_States_sign_-_Slow.svg | |
// Devel | |
// https://gist.github.com/noromanba/2fc4c8dc496dbe8d2050e42484bd9b40 | |
// related: window.amznMusic | |
(() => { | |
'use strict'; | |
const addStyle = (() => { | |
const parent = document.head || document.body || document.documentElement; | |
const style = document.createElement('style'); | |
style.type = 'text/css'; | |
parent.appendChild(style); | |
return (css) => { | |
style.appendChild(document.createTextNode(css + '\n')); | |
}; | |
})(); | |
// TODO | |
// - pause or slowdown transition | |
// - svg | |
//*/ | |
addStyle(` | |
.mainContentLoadingSpinnerHighlight { | |
animation-duration: 0s !important; | |
animation-play-state: paused !important; | |
} | |
`); | |
/*/ | |
addStyle(` | |
body *:not(.mainContentLoadingSpinnerHighlight) { | |
animation-duration: 1s !important; | |
transition-duration: 1s !important; | |
} | |
`); | |
/*//* | |
Array.from(document.body.querySelectorAll([ | |
'body', | |
'*:not(.mainContentLoadingSpinnerHighlight)' | |
].join(' ')), node => { | |
const style = getComputedStyle(node); | |
if (style.animationDuration && | |
Number(style.animationDuration.replace(/[^\d\.]/g, '')) < 1) { | |
style.animationDuration = '1s'; | |
} else if (style.transitionDuration && | |
Number(style.transitionDuration.replace(/[^\d\.]/g, '')) < 1) { | |
style.transitionDuration = '1s'; | |
} | |
}); | |
//*/ | |
})(); | |
// DBG | |
/*/ | |
// detector | |
Array.from(document.body.querySelectorAll('*'), node => { | |
const style = getComputedStyle(node); | |
if (style.animationDuration && style.animationDuration !== '0s') { | |
console.log('*animation', style.animationDuration, node); | |
return node; | |
} else if (style.transitionDuration && style.transitionDuration !== '0s') { | |
console.log('*transitionDuration', style.transitionDuration, node); | |
return node; | |
} | |
}).filter(n => !!n); | |
// calm down | |
//const FPS = (1/1) + 's'; | |
Array.from(document.body.querySelectorAll('*'), node => { | |
const style = getComputedStyle(node); | |
if (style.animationDuration && style.animationDuration !== '0s') { | |
style.animationDuration = '1s'; | |
} else if (style.transitionDuration && style.transitionDuration !== '0s') { | |
style.transitionDuration = '1s'; | |
} | |
}); | |
//*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment