This article mainly introduces the way to disable JavaScript console debugging, the need for friends can refer to the following
Several giant companies, Facebook and Netflix, have decided to prohibit users from executing JavaScript commands in the console (console). Initially this was started by Facebook to prevent malicious users from executing specific command-mongering messages via the JavaScript console (sending a lot of spam to all Facebook users). Of course this is a lot of blame, but before I get involved, the code they use is as follows: The code is as follows://It looks like Netflix is the only Facebook took direction [https://news.ycombinator.com/item?id=7222129]. (function () {try {var $_console$$ = console; Object.defineproperty (window, "console", {get:function () {if ($_CONSOLE$$._COMMANDLINEAPI) throw "Sorry, this site is disabled for user security Console scripting feature "; Return $_console$$}, Set:function ($val $$) {$_console$$ = $val $$}}) \ catch ($ignore $$) {}}) (); Although I am two-bit, in fact I think this practice is legal. From their point of view, if you temporarily disable the console to help prevent a problem, you have to do so. But in the long run it's really not a good idea; The goal may be simply to shield the target users who depend on them. Anyway, if you want to prevent the console from executing the script, the code looks good and it does.