Compresjs
Port of u/_DaCoolOne_'s python compressor to js by u/L4sgc
JavaScript
// Port of u/_DaCoolOne_'s python compressor to js by u/L4sgc
// Code 2 char - Encode arbitrary code into a magic character
function C2c(c) {
return new Function('c',((new TextEncoder().encode("E̴͔͔̝͎͔̥͎͌̀͗̀̓͘ͅͅͅ͏̝͔͎̈́͒̈̉̌͂̎̓ͅͅ͏̻̼͎̼͇̈́̈̓̎͒͐͌́̓̈̏͒̽̏̌̇̇̉̉̌ͅͅͅ͏̝͔͎̎̓ͅ͏̛̥͕̝̝̞͔̝̝̈́̈̇̇̉̌̈͐̌̎̎̎͒̉͛͌̀͌̐̌̈́̐͆ͅͅ͏͔͒̈͌̀͑̀ͅ͏̛̛̝͎͇͔͈͔̝͎͆̀͒̉͌̋͑̎͌͌̀͆͗̀͐̈͌̉͆ͅͅͅ͏͔͒̈͌̀͑̀ͅ͏̛̛͓͔̝͎͇͔͈͔͕͎͆̀͒̉͛͆̎̈͑̌̈́̉̈́̋͑̎͌͒͒̀͆͆͝͝ͅͅͅ͏͔͒̈͌̀́̀ͅ͏͉̝̝͆̀͂̉͛͆̈́̑̓̉̀̓͏̛̛͎͔͉͎͕͔͖̝͌̀̈́̍̑̑̉̅̑̓̓̍̒̑ͅͅ͏̵̡̝͕͉͎͔̘͙̈͒͒́̌͏̵̡͉͎͔̘͙̌͒͒́̎͏̵̡͖̞̞̖͉͎͔̘͙͆̈̈̈̉̆̑̐͂̑̑̐̐̑̑̐̐̉̉̌͒͒́̎͜͏̴͖̖͔͍̝͎͔̤͆̈̈̈̆̓̉̐͂̑̐̐̐̐̐̐̐̉̉̉͌̀͗̀̓͘͜͝ͅͅͅͅ͏̈́͒̈̉̎̈́̓ͅͅ͏̈́̈ͅ͏̛̉̓͏͎͓͏͌̎͌ͅ͏̛̛͇͍͔͕͎͍̈̉͒͒̀ͅ").reduce((e,x,i,t)=>{if(i&&i%2)e.push(t.slice(i,i+2));return e;},[]).map(x=>String.fromCharCode(((x[0]<<6&64|x[1]&63)+22)%133+10))).join('')))(c);
}
//char 2 Code - Decode and execute code from magic character
function c2C(c) {
eval((new TextEncoder().encode(c).reduce((e,x,i,t)=>{if(i&&i%2)e.push(t.slice(i,i+2));return e;},[]).map(x=>String.fromCharCode(((x[0]<<6&64|x[1]&63)+22)%133+10))).join(''));
}
// Test Encode and Decode
let test = C2c(`
console.log('Hello');
console.log('World!');
`);
c2C(test);
// Note the Encode function is itself encoded to save space, this prints the actual encoding code
c2C("É͖̝͓͔̩͎͔͖̝̞͉͒̀́͒́͌̈̈̉͛͆̈̈́ͅͅ͏͕͍͎͔͙̳͔͔̝̓̎͒́̈́́́̇̓ͅͅͅ͏̛̛͍͔͔͕͎̩͎͔͖͖̝͐͌̇̉͒͒̓͌́͒͒́͌̈́̉́͒̀̈́ͅͅͅͅͅͅ͏̡̛͕͍͎͔͔̥͍͎͔͉͍͓͔͔͔͉͕͔͓͔͙̓̎̓͒́͌̈̇͆͒́̇̉̎͒͂̈̇͌̇̌̇͐ͅͅͅͅͅͅͅͅͅͅ͏͓͉͔͉͏̛͎͉͔͆̈́̚͘ͅ͏̛̛̛̛̛͔͉͔͈͈͉͇͈͔͚͉͎̙̙̙͐̐͌͆̐͗̈́̑̐̐̅̑̐̐̅̍̈́͐̚̚̚̚͘̚ͅͅͅ͏͉͎͔͖͎͔͓͎͒̍̚ͅͅͅ͏̛͎͕͓͓͔͎͒̍͌̓̚ͅͅͅͅ͏̡̛̛͎͓͔͔͔͉͕͔͓͈͔͔͓͙̇̉̎͒͂̈̇͒̓̇̌̇͐̏̏͗͗͗̎̚ͅͅͅͅ͏͕͔͕͂̎̓ͅ͏̷̸͍͍̱̙͇̱̟̏͂̈́̏̈́͗̔͗̓̓ͅͅ͏͎͔͒͏͓̝͕͔͌̐̆́͏͙̝͐͌́̑̆͌͏͏̛̝͐̑̇̉̈́͏͕͍͎͔̓̎͂ͅ͏̛̛͙͎̣͈͉̈́̎́͐͐̈́͌̈́̈̉̌̑̐̐̉͝ͅͅ");