I'm making a JavaScript game, and I don't want anyone to cheat. Is there any way that I can detect, and possibly log, commands issue in the JavaScript console? The skeleton of what I'd be looking for is something like:
consoleCommands = "";
window.console.command = function ( thiscmd )
{
consoleCommands += thiscmd;
}
window.onbeforeunload = function ( )
{
// send log of commands to server
$.ajax({url:'recordNewCommandLog',method:'POST',data:{cmdlog:consoleCommands}});
};
Of course, an attacker could overwrite that, but I'll try to obfuscate it enough to make it difficult for him to figure out that his commands are getting logged in the first place.