const STEP = 15; const SPEED = 200; function rgbToHsl(r, g, b) { r /= 255; g /= 255; b /= 255; let max = Math.max(r, g, b), min = Math.min(r, g, b); let h, s, l = (max + min) / 2; if (max === min) { h = s = 0; } else { let d = max - min; s = l > 0.5 ? d / (2 - max - min) : d / (max + min); switch (max) { case r: h = (g - b) / d + (g < b ? 6 : 0); break; case g: h = (b - r) / d + 2; break; case b: h = (r - g) / d + 4; break; } h *= 60; } return [h, s * 100, l * 100]; } function shiftColorSafely(color, shift) { if (!color || color === "transparent") return color; let match = color.match(/\d+/g); if (!match) return color; let [r, g, b] = match.map(Number); // игнорируем абсолютно чёрные системные элементы if (r === 0 && g === 0 && b === 0) return color; let hsl = rgbToHsl(r, g, b); hsl[0] = (hsl[0] + shift) % 360; return `hsl(${hsl[0]}, ${hsl[1]}%, ${hsl[2]}%)`; } function updateColors() { document.querySelectorAll("*").forEach(el => { const style = getComputedStyle(el); ["color", "backgroundColor", "borderColor"].forEach(prop => { const val = style[prop]; if (!val || val.includes("url") || val.includes("rgba(0, 0, 0, 0)")) return; el.style[prop] = shiftColorSafely(val, STEP); }); }); } setInterval(updateColors, SPEED); console.log("h.");
ENG: Check it out, my scratch color is constantly changing. (This project is just a demo, this is different!!!!) The code isn't mine. RU: Проверьте, у меня скретч цвета вечно стал менять. (в проекте лишь демонстрация, это по другому!!!!) код не мой.