0

I'm trying to remove a element from dom in an online IDE using a simple chrome extension manifest_version : 2

content.js

function removeWatermark() {
    try {
        let watermark = document.getElementById("watermark");
        watermark.innerHTML = "";
    }
    catch (error) {
        console.log(error);
    }
}
removeWatermark();

This is working fine when I open page for first time but when I change language its making a post request and the text is returning how to make the removeWatermark function to run on every httpresponse.

THUNDER 07
  • 521
  • 5
  • 21
  • 2
    I have an idea, you can inject this css to the page when it loads: `#watermark{display:none !important;}` – Gerrnperl Jul 10 '22 at 09:23
  • Tq!!!! it working could you post it as answer – THUNDER 07 Jul 10 '22 at 09:34
  • 1
    No need, it solves your needs, but it doesn't actually answer the question: trigger the function on every request @THUNDER 07 – Gerrnperl Jul 10 '22 at 10:03
  • Does it make sense to phrase it like this? You would like to remove it whenever it is added to the DOM. If so, I suggest you have a look at the MutationObserver class – axelduch Jul 11 '22 at 15:57
  • I'm gonna close this question with a canonical duplicate along the lines of what axelduch said. – Xan Jul 12 '22 at 12:58

0 Answers0