How to restore obfuscated property names?

A simple regex replace will do:

var _$_21e2 = ["jQuery", "userAgent", "test", "onmouseup", "onmousemove", "pink", "greenyellow", "gold"];
return code.replace(/\[_\$_21e2\[(\d+)\]\]/g, function(_, i) {
    return "."+_$_21e2[i];
}).replace(/_\$_21e2\[(\d+)\]/g, function(_, i) {
    return JSON.stringify(_$_21e2[i]);
});

Given the code as a string, this will yield a code string with human-readable property names and literals.

Leave a Comment