Facebook Console Warning

Console warning similar to FB, and some console features disabled

by Justin Hyland

HTML

<h1>
Open the browsers JS console to see the results
</h1>

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);

console._commandLineAPI()
console.__commandLineAPI()

console.log('log')
console.error('error')
console.debug('debug')
console.warn('warn')
console.info('info')