0

So, i am building a game with html5 and javascript and I want to prevent cheating by calling some of my functions(for example saveScore(100000)) from the console in web browser.

Any ideas how can i prevent this?

2
  • 3
    Scope them so they're not available globally using closures? Commented Jan 22, 2013 at 9:58
  • 1
    What prevents me from modifying the code? JS, after all, runs openly. Any injection method, be it the console, a the url bar or via an extension can aid me. Commented Jan 22, 2013 at 10:01

1 Answer 1

2

console are execute by the function eval() so override the eval function by:

window.eval=function(){};

Now console is disabled
But this is also not good idea because it cannot prevent the execution of bookmarklet so use @Anthony's idea.

Sign up to request clarification or add additional context in comments.

1 Comment

No longer works. Tested with Firefox + Firebug.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.