Skip to content

Instantly share code, notes, and snippets.

@tilap
Last active October 2, 2024 14:24
Show Gist options
  • Save tilap/543f077b75760fc775c50bcb730e92e2 to your computer and use it in GitHub Desktop.
Save tilap/543f077b75760fc775c50bcb730e92e2 to your computer and use it in GitHub Desktop.
How to avoid user to open devtools to watch your sources

Block console usage

Just against ~~~newbies~~~ 95% of humanity :P

<script type="text/javascript" defer>
function devtoolIsOpening() {
  console.clear();
  let before = new Date().getTime();
  debugger;
  let after = new Date().getTime();
  if (after - before > 200) {
    document.write("Dont open Developer Tools.");
    window.location.replace("https://www.google.fr");
  }
  setTimeout(devtoolIsOpening, 100);
}
devtoolIsOpening();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment