Thanks for the reply AndrewMast.
Your one suggestion (
http://www.danstools.com/javascript-obfuscate/index.php) does a good job at making the code unreadable, however:
1) The process is reversible, so the code being obscured can be made fully readable again with a little work.
2) It seems to break my game and I get this error message:
Uncaught SyntaxError: Unexpected token ILLEGAL
Your other suggestion (
http://esprima.org/demo/minify.html), with all the options checked, results in obfuscated code that looks like this:
9 years ago
by lTyl
It looks like Agar is using the ADVANCED_OPTIMIZATIONS setting in Google Closure Compiler:
Normal:
function unusedFunction(note) {
alert(note['text']);
}
function displayNoteTitle(note) {
alert(note['title']);
}
var flowerNote = {};
flowerNote['title'] = "Flowers";
displayNoteTitle(flowerNote);
SIMPLE_OPTIMIZATIONS in Google Closure Compiler:
function unusedFunction(a){alert(a.text)}function displayNoteTitle(a){alert(a.title)}var flowerNote={};flowerNote.title="Flowers";displayNoteTitle(flowerNote);
ADVANCED_OPTIMIZATIONS with Google Closure Compiler:
var a={};a.title="Flowers";alert(a.title);
Here is an example of the method I use:
http://labs.tderen.com/javascript/bundles/
I want to reduce the amount of HTTP requests instead of having code obfuscation. As such, this method lets me bundle all of the assets of a level from source files to media files (Or even the entire game!) into a single file. Then we use our loader, which in this case is our game.min.js file that appears in "View Page Source...". Interestingly enough, this method prevents any game or Impact source from being visible in the View page Source option.
9 years ago
by Joncom
Quote from lTyl
It looks like Agar is using the ADVANCED_OPTIMIZATIONS setting in Google Closure Compiler
Looks that way! Thank you. Going to play with this...
Quote from Joncom
Looks that way! Thank you. Going to play with this...
Have you made your code unreadable? Please post any successes you have. I tried it with the Google Closure Complier, but I kept getting errors when linking the the compiled code with my index.html
-Andrew
9 years ago
by Joncom
So far I've managed to get it working on a fresh copy of Impact via this patch:
diff --git a/lib/impact/game.js b/lib/impact/game.js
index 29f3cea..9c3d24f 100644
--- a/lib/impact/game.js
+++ b/lib/impact/game.js
@@ -186,7 +186,7 @@ ig.Game = ig.Class.extend({
// remove all killed entities
for( var i = 0; i < this._deferredKill.length; i++ ) {
this._deferredKill[i].erase();
- this.entities.erase( this._deferredKill[i] );
+ this.entities['erase']( this._deferredKill[i] );
}
this._deferredKill = [];
diff --git a/lib/impact/impact.js b/lib/impact/impact.js
index e65346a..f6ea29b 100644
--- a/lib/impact/impact.js
+++ b/lib/impact/impact.js
@@ -415,6 +415,9 @@ window.ig = {
}
};
+// Fix closure compiler not renaming `ig` properly
+var ig = window.ig;
+
// -----------------------------------------------------------------------------
// Provide ig.setAnimation and ig.clearAnimation as a compatible way to use
@@ -559,6 +562,9 @@ if( window.ImpactMixin ) {
})(window);
+// Fix closure compiler not renaming `ig` properly
+var ig = window.ig;
+
// -----------------------------------------------------------------------------
// The main() function creates the system, input, sound and game objects,
diff --git a/lib/impact/loader.js b/lib/impact/loader.js
index b792ddd..3c90e26 100644
--- a/lib/impact/loader.js
+++ b/lib/impact/loader.js
@@ -85,7 +85,7 @@ ig.Loader = ig.Class.extend({
_loadCallback: function( path, status ) {
if( status ) {
- this._unloaded.erase( path );
+ this._unloaded['erase']( path );
}
else {
throw( 'Failed to load resource: ' + path );
diff --git a/lib/impact/sound.js b/lib/impact/sound.js
index 2d12e77..548baf4 100644
--- a/lib/impact/sound.js
+++ b/lib/impact/sound.js
@@ -464,7 +464,7 @@ ig.Sound.WebAudioSource = ig.Class.extend({
// later when it has finished playing.
var that = this;
this.sources.push(source);
- source.onended = function(){ that.sources.erase(source); }
+ source.onended = function(){ that.sources['erase'](source); }
source.start(0);
},
Edit: Most things obfuscated nicely, but a few things didn't. Not sure why yet...
Thanks! I will try it out
Is there a way to request Dominic to add that?
-Andrew
Page 1 of 1
« first
« previous
next ›
last »