Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function injectStyles(backgroundColor, textColor) {
- function hexToRgba(hex, alpha = 1) {
- const [r, g, b] = [
- parseInt(hex.slice(1, 3), 16),
- parseInt(hex.slice(3, 5), 16),
- parseInt(hex.slice(5, 7), 16)
- ];
- return `rgba(${r}, ${g}, ${b}, ${alpha})`;
- }
- const bgColor = (backgroundColor[0] === '#') ? hexToRgba(backgroundColor, 0.95) : backgroundColor;
- const styleEl = document.createElement('style');
- document.head.appendChild(styleEl);
- const styles = `
- .caption p {
- background-color: ${bgColor};
- color: ${textColor};
- text-shadow: none;
- }
- `;
- styleEl.appendChild(document.createTextNode(styles));
- }
- let player = GetPlayer();
- var background = player.GetVar("BackgroundColor");
- var color = player.GetVar("TextColor");
- injectStyles(background, color);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement