1

I am writing a Chrome extension which modifies the body of the HTML.

document.addEventListener('DOMContentLoaded', () =>
{
    const body = document.body.innerHTML;    
    let body_edited = foo();
    document.body.innerHTML = body_edited;
});

I want my code not to modify the document body if the webpage is an SPA kind of website - like written in React, Vue, Angular etc. How do I detect if a webpage is of certain kind ?

anjanesh
  • 3,771
  • 7
  • 44
  • 58
  • 1
    There's no way. Just don't modify html, it's slow and error-prone and breaks all attached event listeners. Instead apply the changes via DOM. Example: [Javascript .replace command replace page text?](https://stackoverflow.com/q/7275650) – wOxxOm Sep 01 '22 at 06:57
  • Thanks for the introduction of TreeWalker – anjanesh Sep 01 '22 at 10:37

0 Answers0