psiklop, не совсем верно, replace с флагом g нужен, флаг i не нужен, \x5\xd\ 0 нужен \x05\x0d\:
function decode(string) {
var regexp, result, matches, match, key, value, index;
regexp = /(?=[\x05\x0d\x15\x1d%\-5=EMU\]emu}\x85\x8d\x95\x9d\xa5\xad\xb5\xbd\xc5\xcd\xd5\xdd\xe5\xed\xf5\xfd])([\x80-\xff]*[\0-\x7f])([\s\S]{4})|([\x80-\xff]*[\0-\x7f])([\x80-\xff]*[\0-\x7f])/g;
string = string.replace(/_/g, '/').replace(/-/g, '+');
string = atob(string);
for (result = {}; matches = regexp.exec(string); result[key >> 3] = value) {
if (key = value = 0, matches[1]) {
for (match = matches[1], index = 0; index < match.length; index++)
key += (match[index].charCodeAt(0) & 127) << index * 7;
for (match = matches[2], index = 0; index < match.length; index++)
value += (match[index].charCodeAt(0) * Math.pow(2, index * 8));
} else {
for (match = matches[3], index = 0; index < match.length; index++)
key += (match[index].charCodeAt(0) & 127) << index * 7;
for (match = matches[4], index = 0; index < match.length; index++)
value += (match[index].charCodeAt(0) & 127) * Math.pow(2, index * 7);
}
}
return result;
}