I have a javascript game that people have started hacking by changing the score variable from the console in the inspect element, is there a way to make it so that code from the inspect element console will not be run?
Block code run from the inspect element in JS?
422 Views Asked by LlamaButt At
2
I would use scoped variables, so the attacker can't access them from the console.
Another option would be to wrap all of your code in an Immediately Invoking Function Expression (IIFE):
EDIT: that last one requires you to use strict mode (type
"use strict";
at the beginning of the file)