0

Self-XSS - History and mitigation states that

Facebook and others now display a warning message when users open the web developer console

What is the HTML/Javascript code to display a warning message when the console is activated?

CW Holeman II
  • 4,661
  • 7
  • 41
  • 72
  • They just add console.log lines with styles. There is nothing special going on. I am sure if you use your favorite search engine with "facebook console.log stop message" you will get examples on how they do it. – epascarello Mar 07 '22 at 18:46
  • What about https://stackoverflow.com/questions/42165204/how-can-i-display-a-warning-to-users-who-open-the-chrome-console-like-facebook? – Nico Haase Mar 07 '22 at 18:52

1 Answers1

1

Devtools Detect is a library that tells you if the console is open. After linking it in your html file, you could use the following code to print something when the console is open:

window.addEventListener('devtoolschange', event => {
   if(event.detail.isOpen){
       console.log("Warning: Console is open");
   }
});
Justiniscoding
  • 441
  • 5
  • 19