Last active
August 12, 2019 16:22
-
-
Save alexisdiel/4c59ff65800e14f895d8f33f92f5fb26 to your computer and use it in GitHub Desktop.
Console Log override with Ctrl+ F12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// <footer class="black"> | |
// <div id="consoleLog" class="hide black darken-1 orange-text" /> | |
// </footer> | |
(function () { | |
var old = console.log; | |
console.log = function () { | |
for (var i = 0; i < arguments.length; i++) { | |
if (document.getElementById("consoleLog")) { | |
if (typeof arguments[i] == "object") { | |
document.getElementById("consoleLog").innerHTML += (JSON && JSON.stringify ? JSON.stringify(arguments[i], undefined, 2) : arguments[i]) + "<br />"; | |
} else { | |
document.getElementById("consoleLog").innerHTML += arguments[i] + "<br />"; | |
} | |
} | |
old(arguments[i]); | |
} | |
}; | |
})(); | |
document.addEventListener("keydown", (e) => { | |
if (!e.altKey && e.ctrlKey && !e.shiftKey) { | |
if (e.code === "F12") { | |
if (document.querySelector("#consoleLog.hide") === null) { | |
document.getElementById("consoleLog").classList.add("hide"); | |
} else { | |
document.getElementById("consoleLog").classList.remove("hide"); | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment