Hide User Snap Button

435 Views Asked by At

I have a button:

  const script = document.createElement('script');
  script.type = 'text/javascript';
  script.async = true;
  script.src ="my user snap api key";
  const firstScript = document.getElementsByTagName('script')[0];
  firstScript.parentNode.insertBefore(script, firstScript);
  script.id = "userSnap";

I want to hide it when a certain event is called: I have tried this but it doesnt disappear document.getElementById('userSnap').remove() the button is still there... There is no css for it in it or anything so i cant adjust a css file it is just dont through user snap

2

There are 2 best solutions below

1
On

Please try this

<div id="userSnap">
    just testing
</div>
<a href="javascript://" onClick="remove_();">remove</a>
<script>
    function remove_(){
        document.getElementById('userSnap').remove();
    }
</script>

Fiddle

0
On

The UserSnap script adds a button to the DOM. You can't hide the effects a script has had on the DOM by removing the script after it has run, instead you need to manipulate the DOM to hide or remove the button itself.

Use your browser's developer tools to figure out if the button has some kind of unique identifying attribute like an ID or class name, and use that to select and remove the button.