How to disable Developer Tools options in Chrome

Asked

Viewed 6,367 times

6

Supposedly Facebook uses a code similar to the one on the link http://snapbuilder.com/code_snippets/snippet.php?sid=174&printable=1 to disable and put a warning to your users. Since the above link code seems to be half over.

  1. How to proceed to resolve the above question?
  2. It is possible to disable other options such as: Elements and Sources.
  • What options do you want to disable from Developer Tools? Because on Facebook I was able to use DT without problems.

  • In FB the option Console this custom wanted to know if it is easy to modify it? I want to do the same in the Elements and Sources tabs if possible

  • Related: http://answall.com/questions/6035/como_blockr-console-do-browser-usendo-javascript/

3 answers

3


Actually Developer tools is not disabled, but Facebook discourages doing anything there, as many laypeople don’t know what it is.

They went on to display this message because of malicious users who instruct people to execute code in their browsers and who could potentially steal data from users.

I searched here, and the code that displays the message is relatively simple:

var i = "Stop!",
    j = "This is a browser feature intended for developers. If someone told you to copy-paste something here to enable a Facebook feature or \"hack\" someone's account, it is a scam and will give them access to your Facebook account.";

if ((window.chrome || window.safari)) {
    var l = 'font-family:helvetica; font-size:20px;';
    [
       [i, l + 'font-size:50px; font-weight:bold; ' + 'color:red; -webkit-text-stroke:1px black;'],
       [j, l],
       ['', '']
    ].map(function(r) {
        setTimeout(console.log.bind(console, '\n%c' + r[0], r[1]));
    });
}

Basically, what the above code does is display a message on the console when it is detected that it has been opened.

Source: Console.log without Reference to the script

1

There is no way to disable, just display a message on the console that gives the impression of being disabled.

<script type="text/javascript">
            Object.defineProperty(window, "console", {
                value: console,
                writable: false,
                configurable: false
            });

            var i = 0;
            function showWarningAndThrow() {
                if (!i) {
                    setTimeout(function () {
                        console.log("%cWarning message", "font: 2em sans-serif; color: yellow; background-color: red;");
                    }, 1);
                    i = 1;
                }
                throw "Console is disabled";
            }

            var l, n = {
                set: function (o) {
                    l = o;
                },
                get: function () {
                    showWarningAndThrow();
                    return l;
                }
            };
            Object.defineProperty(console, "_commandLineAPI", n);
            Object.defineProperty(console, "__commandLineAPI", n);
            showWarningAndThrow();
        </script>

Source: that question

1

Chrome wraps all console code in:

with ((console && console._commandLineAPI) || {}) {
  <code goes here>
}

... That’s why the site redefines console. _commandLineAPI with:

Object.defineProperty(console, '_commandLineAPI',
   { get : function() { throw 'Nããão!' } })

Any doubt, joke about it:

function escape(s) {


  Object.defineProperty(console, 'foo', 
     { get : function() { throw 'Nãão!' } });

  var code = 'with((window.console && console.foo) || {}) {\n\t'+s+'\n}';
  console.log(code);

  try {
    console.log(eval(code));
  } catch (e) {
    console.log(e);
  }
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.