Blocking Grammarly Icon - Javascript - Chrome Extension

140 views Asked by At

Does anyone know how to block GrammarlyGo icon in the text area and anywhere else with javascript? I am making a Chrome extension and need to place an icon in the same place that GrammarlyGo places their icon and therefore need to stop GrammarlyGo's icon from appearing.

enter image description here

The problem is it isn't always in appearance it only appears when there is active selected text especially amongst multiple lines. I have this code but it has no effect:

const elementToBlock = document.querySelector('[data-grammarly-part="cheetah-entry-button"]');
const hideElement = (element) => {
  element.style.display = "none";
};

const observerConfig = { childList: true, subtree: true };
const observerCallback = (mutationsList, observer) => {
  for (const mutation of mutationsList) {
    if (mutation.addedNodes.length > 0 && mutation.addedNodes[0] === elementToBlock) {
      hideElement(elementToBlock);
    }
  }
};

const observer = new MutationObserver(observerCallback);
observer.observe(document.documentElement, observerConfig);
0

There are 0 answers