Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

139
Visualizações
JS not updating css on website chrome extension

I am making a chrome extension with a popup, that also changes the css of that website. There is a color input that the popup receives, and the background should change colors based on that. I am using a css variable in websiteCss.css, which changes the website once.

:root{
    --bg: #ff00ff;
}
body.replit-ui-theme.light{
    --replitVariableThing: var(--bg);
}

I know that the body.replit-ui-theme.light works because I have done it before, with a constant. My JS looks like:

document.addEventListener('DOMContentLoaded', documentEvents  , false);

document.getElementById('background').value = "#1BFFFF"

function documentEvents(){
  var r = document.querySelector(':root');
  
  function reload(){
    var color = document.getElementById('background').value
    r.style.setProperty('--bg', color);

    document.body.style.backgroundImage = "linear-gradient(to right, #2E3192,  " + color + ")"
    
    if(Math.random(0,1) < .1){
      console.log(color)
    }
    window.requestAnimationFrame(reload)
  }
  
  window.requestAnimationFrame(reload)
}

Where the background is the color picker, and the --bg is variable.

The website's color changes, but the input will not change it afterwards. Any help?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda