JSFiddle - React, Tailwind, and code Playground
by Glutamat
HTML
<h1>Open your console</h1>
JavaScript
(function () {
function appendExpr (expr) {
var pre = document.createElement ("pre");
var cod = document.createElement ("code");
var result;
cod.appendChild (document.createTextNode ("> " + expr.split ("\n").join ("\n ")));
pre.appendChild (cod);
document.body.appendChild (pre);
result = _eval.call (ish,"with ( console && console._commandLineAPI ) {"+ expr +"}","",true,false,false).toString ();
document.body.appendChild (document.createTextNode (result));
}
var ish, _eval, _cLA,
_call = Function.prototype.call;
console.log("Please try evaluating something from the console");
Function.prototype.call = function asd() {
if (arguments.length > 0 && this.name === "evaluate") {
ish = arguments[0];
_eval = ish.evaluate;
_cLA = ish.evaluate ("console._commandLineAPI","",true,false,false);
Function.prototype.call = _call;
ish.evaluate = function () {
if ("with ((console && console._commandLineAPI) || {}) {" === arguments [0].slice (0,51)) {
var expr = arguments [0].slice (52,-2);
if (expr !== 'this') {
appendExpr(expr);
}
}
_eval.apply(this, arguments);
};
return _call.apply(this, arguments);
}
};
})();