×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: Isaac Dettman
Added: Nov 23, 2016 6:35 PM
Modified: Nov 23, 2016 7:20 PM
Views: 6
Tags: no tags
Simplified version of the chrome console override
  1. /**
  2.  * thanks go to (http://kspace.in/blog/2013/02/22/disable-javascript-execution-from-console/)
  3.  */
  4.  
  5. var _console = console;
  6.  
  7. Object.defineProperty (window, 'console',
  8. {
  9.         get: function ()
  10.         {
  11.                 if (defaultConsole._commandLineAPI)
  12.                 {
  13.                         throw 'cannot exceute scripts';
  14.                 }
  15.                
  16.                 return defaultConsole;
  17.         },
  18.        
  19.         set: function(val)
  20.         {
  21.             defaultConsole = val;
  22.         }
  23. });