Preventing User Code Execution

So, I am writing a game with JavaScript, and the biggest problem is that the one who plays it, who can have a decent knowledge of JS, can open my source code, find out how it works, and then plug it game.score = 100000000000000;into the console. However, it seems that besides obfuscating the script, wrapping everything in an anonymous function does the trick.

(function() {
    game_start = function() {
        //etc
    }
    //etc
 })();

When I try to run any code from the Chrome console, it has undefined. This is the desired result, but is there a way around my method that will make it useless? Or even the best way to prevent applications from launching from the console?

+5
source share
2 answers

, . ( , H5b(b){if(b.pd()&&b.Ca&&b.gKa){var a=b.ra(RT.Nwa)) .

AJAX , . , /, AJAX , back-end. , , , , .

script, ajax, .

tl; dr: , , .

+4

, - , . , , . , , , - , , , .

+3

All Articles