Skip to content

Instantly share code, notes, and snippets.

@camtheman256
Last active July 7, 2020 02:17
Show Gist options
  • Save camtheman256/0eedb1630559ade51f1fbb88760ec51b to your computer and use it in GitHub Desktop.
Save camtheman256/0eedb1630559ade51f1fbb88760ec51b to your computer and use it in GitHub Desktop.
Change Color to Music for Spicetify
// @ts-check
// NAME: Change Color to Music
// AUTHOR: camtheman256
// DESCRIPTION: Changes accent color to album art
/// <reference path="../globals.d.ts" />
(function ChangeColorToMusic() {
function applyStyles(styleMap, documentEl) {
for(style of Object.keys(styleMap)) {
documentEl.style.setProperty(style, styleMap[style])
}
}
Spicetify.Player.addEventListener('songchange', (event) => {
Spicetify.getAblumArtColors().then((value) => {
let styleMap = {
"--modspotify_rgb_sidebar_indicator_and_hover_button_bg": [parseInt(value.DESATURATED.substr(1, 2), 16), parseInt(value.DESATURATED.substr(3, 2), 16), parseInt(value.DESATURATED.substr(5, 2), 16)].join(", "),
"--modspotify_main_fg": value.VIBRANT,
"--modspotify_sidebar_indicator_and_hover_button_bg": value.DESATURATED,
};
applyStyles(styleMap, document.documentElement);
iframes = document.getElementsByTagName("iframe");
for(iframe of iframes) {
applyStyles(styleMap, iframe.contentDocument.documentElement);
}
console.log(value);
});
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment