diff --git a/src/api/utils.js b/src/api/utils.js index 68ce69c..308302b 100644 --- a/src/api/utils.js +++ b/src/api/utils.js @@ -59,3 +59,25 @@ export const parseManifest = (manifest) => { export const getMediaURLFromID = (id, path = "/1280x1280.jpg") => "https://resources.tidal.com/images/" + id.split("-").join("/") + path; + + +export function convertHexToRGB(h) { + let r = 0; + let g = 0; + let b = 0; + + // 3 digits + if (h.length === 4) { + r = Number('0x' + h[1] + h[1]); + g = Number('0x' + h[2] + h[2]); + b = Number('0x' + h[3] + h[3]); + + // 6 digits + } else if (h.length === 7) { + r = Number('0x' + h[1] + h[2]); + g = Number('0x' + h[3] + h[4]); + b = Number('0x' + h[5] + h[6]); + } + + return `${r}, ${g}, ${b}` +} diff --git a/src/windowObject.js b/src/windowObject.js index d0d72e4..5e1668c 100644 --- a/src/windowObject.js +++ b/src/windowObject.js @@ -27,7 +27,7 @@ try { if (!vibrantColor) return; - vibrantColorStyle(`:root{--track-vibrant-color:${vibrantColor}}`); + vibrantColorStyle(`:root{--track-vibrant-color:${vibrantColor};--track-vibrant-color-rgb:${utils.convertHexToRGB(vibrantColor)}}`); }); } catch {}