Skip to content

Commit

Permalink
UPD: 4.5 perfect colorization of green svgs
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienMaille authored and actions-user committed Jul 24, 2023
1 parent 625c978 commit 42e44e8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
18 changes: 15 additions & 3 deletions default-dynamic.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
let current = "4.4";
let current = "4.5";

function waitForElement(els, func, timeout = 100) {
const queries = els.map((el) => document.querySelector(el));
Expand Down Expand Up @@ -177,8 +177,20 @@ function updateColors(textColHex) {
setRootColor("highlight", softerHighlightHex);

// compute hue rotation to change spotify green to main color
let hue = 360 * rgbToHsl(hexToRgb(textColHex))[0];
document.documentElement.style.setProperty("--hue-from-green", (hue + 235).toFixed(0) + "deg");
let rgb = hexToRgb(textColHex);
let m = `url('data:image/svg+xml;utf8,
<svg xmlns="http://www.w3.org/2000/svg">
<filter id="recolor" color-interpolation-filters="sRGB">
<feColorMatrix type="matrix" values="
0 0 0 0 ${rgb[0] / 255}
0 0 0 0 ${rgb[1] / 255}
0 0 0 0 ${rgb[2] / 255}
0 0 0 1 0
"/>
</filter>
</svg>
#recolor')`;
document.documentElement.style.setProperty("--colormatrix", encodeURI(m));
}

let nearArtistSpanText = "";
Expand Down
5 changes: 3 additions & 2 deletions user.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ input:focus {
box-shadow: none !important;
}

/* h2-like titles */
/* h1-like titles */
h1,
.main-entityHeader-titleButton,
.main-entityHeader-title,
.main-shelf-title,
Expand Down Expand Up @@ -71,7 +72,7 @@ input:focus {
img.main-devicePicker-nowPlayingActiveIcon,
.main-trackList-playingIcon,
.main-trackList-rowHeartButton svg:not(.Svg-img-16-icon) {
filter: hue-rotate(var(--hue-from-green));
filter: var(--colormatrix);
}

.contentSpacing hr {
Expand Down

0 comments on commit 42e44e8

Please sign in to comment.