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

122
Visualizações
Changing DOM in Chrome Extension gets removed at the end of website loading

I am new to chrome extension.

I have built something that changes the display of the page (I am inserting a small "div").

It works fine at first, I can see my div being added, but then more javascript of the target website loads and my addition disappears!

Any idea what could be the reason?

These are the tests I have done so far:

  • No difference of error messages in javascript with or without the extension
  • The extension works fine on another website

EDIT: I am trying to add something on https://www.sainsburys.co.uk/shop/gb/groceries/*

using the following script:

function insertAfter(referenceNode, newNode) {
    referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
}

let itemClassName = "productInfo";
let itemList = document.getElementsByClassName(itemClassName);

for (let i = 0; i < itemList.length; i++) {

    let divList = itemList[i].getElementsByTagName('div')
    
    const indicDiv = document.createElement('div')
    indicDiv.style.color = '#018A76'
    indicDiv.style.fontSize = '18px'
    indicDiv.style.fontWeight = 'bold'
    indicDiv.style.textAlign = 'center'
    indicDiv.innerText = 'BUY'

    insertAfter(divList[0], indicDiv);
}
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