• Added new CSS option: --random-youtube-colors

• Added new CSS option: --youtube-color
• Added new CSS option: --youtube-custom-sub-icon
This commit is contained in:
nuttylmao
2025-09-22 06:45:07 +10:00
parent 54d7190f40
commit 5bb7686174
5 changed files with 63 additions and 9 deletions
+20
View File
@@ -220,3 +220,23 @@ function TranslateToFurry(sentence) {
function EscapeRegExp(string) {
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
}
// Given a string, return a random hex code. The same input always results in the same output
function StringToHex(str) {
// Simple hash function to convert string to a number
let hash = 0;
for (let i = 0; i < str.length; i++) {
hash = str.charCodeAt(i) + ((hash << 5) - hash);
hash |= 0; // Convert to 32bit integer
}
// Convert hash to a hex color
let color = '#';
for (let i = 0; i < 3; i++) {
// Extract each byte and convert to 2-digit hex
const value = (hash >> (i * 8)) & 0xFF;
color += value.toString(16).padStart(2, '0');
}
return color;
}