Skip to content

Instantly share code, notes, and snippets.

@everget
Last active October 12, 2024 17:31
Show Gist options
  • Save everget/f3341e51a1176f152c66c926e31308ee to your computer and use it in GitHub Desktop.
Save everget/f3341e51a1176f152c66c926e31308ee to your computer and use it in GitHub Desktop.
The new look at scripting process...
// ArrayScript...or as I would have nothing to do
let testSuite = [
'Awesome',
'epic fail',
'remember,remember',
'to be or not to be...',
'DealerPoint is awesome...',
'The best code is the one that doesn`t exist...',
'Whatever the mind can conceive and believe, the mind can achieve. — Napoleon Hill',
'The difference between stupidity and genius is that genius has its limits. — Albert Einstein',
'If we don`t end war, war will end us. — Herbert Wells',
'That which does not kill us makes us stronger. - Friedrich Nietzsche',
];
const ASCompiler = (function(global) {
/**
** TODO letters
* g
* h
* k
* q
* x
* y
* z
*/
let dict = {
'a': '((+[][[]]+[]+[])[+!+[]])', //or ([]/[]+[])[+!+[]];
'b': '(([]+{})[+!+[]+!+[]])',
'c': '(([]+{})[+[+!+[]+[+[]]]/[!+[]+!+[]]])',
'd': '(([][[]]+[])[!+[]+!+[]])',
'e': '(([]+{})[!+[]+!+[]<<+!+[]])',
'f': '((![]+[])[+[]])',
'i': '(([![]]+[][[]])[+!+[]+[+[]]])', //or ((+!+[]/+![])+[])[+!+[]+!+[]+!+[]]
'j': '(([]+{})[+!+[]+!+[]+!+[]])',
'l': '((![]+[])[!+[]+!+[]])',
'm': '(((+[][[]]).constructor+([]+[]))[[([]+[])+(+!+[])+(+!+[])]])',
'n': '(((!+[])[+[]]+[])[+!+[]])',
'o': '(([]+{})[+!+[]])',
'p': '((prompt+([]+[]))[+[+!+[]+[+[]]]-+!+[]])',
'r': '(((!+[])+[])[+!+[]])',
's': '((![]+[])[+!+[]+!+[]+!+[]])',
't': '((!![]+[])[+[]])',
'u': '(([][[]]+([]+[]))[+![]])',
'v': '((eval+[])[+[+!+[]+[+[]]]])',
'w': '((this+([]+[]))[[+!+[]+[+[]]]/[!+[]+!+[]]+(!+[]+!+[]<<!+[]+!+[])])',
'A': '([].constructor+[])[+[+!+[]+[+[]]]-+!+[]]',
'B': '(((![]).constructor+[]+[])[+[+!+[]+[+[]]]-+!+[]])',
'D': '(document+[])[[]+(+!+[])+(+!+[]+!+[])]',
'I': '(((+(+!+[]+[+[]])/+![])+[])[+![]])',
'P': '(isPrototypeOf+[])[+[[]+(+!+[])+(+!+[])]]',
'W': '((constructor+([]+[]))[+[+!+[]+[+[]]]-+!+[]])',
'.': '((+![]).toFixed(+!+[])[+!+[]])',
',': '([]+[,,])',
' ': '(([]+{})[7])',
'0': '(+[])', // {} + [] /or/ +![]
'1': '(+!+[])',
'2': '(!+[]+!+[])',
'3': '(+!+[]+!+[]+!+[])',
'4': '(!+[]+!+[]<<+!+[])',
'5': '([+!+[]+[+[]]]/[!+[]+!+[]])',
'6': '(+!+[]+!+[]+!+[]<<+!+[])',
'7': '((+!+[]+!+[]+!+[]<<+!+[])+!+[])',
'8': '(!+[]+!+[]<<!+[]+!+[])',
'9': '(+[+!+[]+[+[]]]-+!+[])'
};
let dict2 = {
'a': '([]+![])[1]', // Coerced from '!false' into the string 'false' -> 'a' at index 1
'b': '([]+{})[2]', // Coerced from empty array + empty object -> 'object' -> 'b' at index 2
'c': '([]+{})[5]', // Same string 'object' -> 'c' at index 5
'd': '([]+([]/[]))[3]', // Coerced from NaN -> 'NaN' -> 'd' at index 3
'e': '(![]+[])[3]', // Coerced from 'false' -> 'e' at index 3
'f': '(![]+[])[0]', // Coerced from 'false' -> 'f' at index 0
'g': '([]+({}+[]))[14]', // Coerced from '[object Object]' -> 'g' at index 14
'h': '([]+([]+[]))[1]', // Coerced from empty string concatenation -> 'undefined' -> 'h' at index 1
'i': '([![]]+[][[]])[3]', // Coerced from 'falseundefined' -> 'i' at index 3
'j': '([]+({}+[]))[13]', // Coerced from '[object Object]' -> 'j' at index 13
'k': '([]+([]+{}))[12]', // Coerced from '[object Object]' -> 'k' at index 12
'l': '(![]+[])[2]', // Coerced from 'false' -> 'l' at index 2
'm': '([]+Math)[11]', // Coerced from '[object Math]' -> 'm' at index 11
'n': '([]+([]/[]))[1]', // Coerced from 'NaN' -> 'n' at index 1
'o': '([]+{})[1]', // Coerced from 'object' -> 'o' at index 1
'p': '(+(1e100)).toString(36)[1]', // Coerced large number into base 36 -> 'p' at index 1
'q': '([]+({}+[]))[15]', // Coerced from '[object Object]' -> 'q' at index 15
'r': '(!![]+[])[1]', // Coerced from 'true' -> 'r' at index 1
's': '(![]+[])[3]', // Coerced from 'false' -> 's' at index 3
't': '(!![]+[])[0]', // Coerced from 'true' -> 't' at index 0
'u': '(!![]+[])[2]', // Coerced from 'true' -> 'u' at index 2
'v': '(+(1e9)).toString(36)[2]', // Coerced large number into base 36 -> 'v' at index 2
'w': '([]+globalThis)[3]', // Coerced from 'globalThis' -> 'w' at index 3
'x': '([]+([]+[]))[11]', // Coerced from 'undefined' -> 'x' at index 11
'y': '([]+([]+[]))[10]', // Coerced from 'undefined' -> 'y' at index 10
'z': '([]+([]+{}))[19]', // Coerced from '[object Object]' -> 'z' at index 19
'0': '(+[]+[])', // Coerced from '0'
'1': '(+!+[]+[])', // Coerced from '1'
'2': '(!+[]+!+[]+[])', // Coerced from '2'
'3': '(+!+[]+!+[]+!+[]+[])', // Coerced from '3'
'4': '(!+[]+!+[]<<+!+[]+[])', // Coerced from '4'
'5': '([+!+[]+[+[]]]/[!+[]+!+[]]+[])', // Coerced from '5'
'6': '((+!+[]+!+[]+!+[]<<+!+[])+[])', // Coerced from '6'
'7': '((+!+[]+!+[]+!+[]<<+!+[])+!+[]+[])', // Coerced from '7'
'8': '(!+[]+!+[]<<!+[]+!+[]+[])', // Coerced from '8'
'9': '(+[+!+[]+[+[]]]-+!+[]+[])' // Coerced from '9'
};
return function ASCompiler(text) {
let len = text.length;
let i = -1;
let result = '';
while (++i < len) {
if (dict.hasOwnProperty(text[i])) {
result += dict[text[i]];
result += '+';
}
}
let bracketPos = result.lastIndexOf(')');
return result.slice(0, bracketPos + 1);
}
})(window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment