Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

114
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!