Open baboures opened 2 years ago
@baboures what are advantages of using <
instead !
?
For instance - for generate some letters JSFuck use deprecated methods like italics
(which can be avoid but produce extremely long code) - are <
is free of this?
https://stackoverflow.com/questions/63673610/alternative-way-to-get-c-letter-in-jsfuck
@kamil-kielczewski <
also serves as a bitwise left shift operator <<. See this example: https://github.com/aemkei/jsfuck#numbers
However, I don't think using a left shift operator to generate numbers will lead to a shorter outcome for this specific charset.
4 = ([]<[+[]])<<([]<[+[]])<<([]<[+[]])
(34 chars)
4 = !+[]+!+[]+!+[]+!+[]
(19 chars)
8 = ([]<[+[]])<<([]<[+[]])<<([]<[+[]])<<([]<[+[]])
(46 chars)
8 = !+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]
(39 chars)
PD: I also considered using the charset [(+=)]
:
'false': '[]==[]',
'true': '[]==+[]',
'undefined': '[][[]]',
'NaN': '+[][[]]',
which is much worse than in the original JSFuck:
'false': '![]',
'true': '!![]',
'undefined': '[][[]]',
'NaN': '+[![]]',
so, all in all, []()!+
is the optimal charset.
Ultimately, my goal wasn't to beat the original JSFuck charset, but to find new exotic ways of writing JavaScript.
I decided to make a compiler for the charset ([+<])
just because it looks really cool 😎
@baboures new exotic way is ok. However - can you show here how to produce letter C
using ([+<])
? (show intermediate steps and final form which use only ([+<])
)
@kamil-kielczewski The process is exactly the same as the original JSFuck. In fact, I just made a few changes to aemkei's compiler in order to switch to the ([+<])
charset. I will show step-by-step how to manually produce the letter C
for educational purposes, although this is one of the hardest chars.
I hope this is helpful for somebody trying to build their own JSFuck variant or understanding how this variant works... 😅
@baboures thanks for your effort. However may be there is a way to avoid deprecated methods (italics) in shorter way than in js fuck https://stackoverflow.com/a/63850312/860099 (which has ~16kb)
To keep backward compatibility with older code, I don't think browsers will remove the String#italics
in a near future.
@kamil-kielczewski If the decoding is 16k characters long, what is the benefit of your solution over using italics()
?
@baboures - safety - if in future they remove this deprecated method - jsf will stop works (that 16kb alternative solve this - however I hope there is better solution)
@kamil-kielczewski do you consider solutions using escape
/unescape
? Those functions are not strictly deprecated as per the docs.
I hope there is better solution
I found an approach using Function('return this')()['btoa']('p+m')[1]
to produce letter C
. The compiler spits out about 9kb when given that string, but when I found it I did it in ~4kb. Would that be a viable alternative? Or is there some reason for avoiding btoa
that I'm missing?
([][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+![]]])[([][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]]+[])[!+[]+!+[]+!+[]]+(([![]]+[])[+[]]+(+[![]]+([][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]]+[])))[+[+!+[]+[+[]]]]+(+[![]]+([][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]]+[]))[+[+!+[]+[+[]]]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+![]]+(!![]+[])[+!+[]]+(!![]+[])[!+[]+!+[]]+([][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+![]]+(([![]]+[])[+[]]+(+[![]]+([][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]]+[])))[+[+!+[]+[+[]]]]+(!![]+[])[+!+[]]]((!![]+[])[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+!+[]]+(+[![]]+[][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]])[+!+[]+[+!+[]]]+(!![]+[])[+[]]+(+(+!+[]+[+[]]+[+!+[]]))[(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]])[+!+[]+[+[]]]+([]+[])[([][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]][([][[]]+[])[+!+[]]+(![]+[])[+!+[]]+((+[])[([][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]+[])[+!+[]+[+!+[]]]+(!![]+[])[!+[]+!+[]+!+[]]]](!+[]+!+[]+[+!+[]])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]+!+[]])()[([][(!![]+[])[!+[]+!+[]+!+[]]+([][[]]+[])[+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(!![]+[])[!+[]+!+[]+!+[]]+(![]+[])[!+[]+!+[]+!+[]]]()+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]])[+!+[]+[+[]]]+(![]+[])[+!+[]]]((+(!+[]+!+[]+[+!+[]]+[+!+[]]))[(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]])[+!+[]+[+[]]]+([]+[])[([][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]][([][[]]+[])[+!+[]]+(![]+[])[+!+[]]+((+[])[([][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]+[])[+!+[]+[+!+[]]]+(!![]+[])[!+[]+!+[]+!+[]]]](!+[]+!+[]+!+[]+[+!+[]])[+!+[]]+(+(+!+[]+(!+[]+[])[!+[]+!+[]+!+[]]+[+!+[]]+[+[]]+[+[]])+[])[!+[]+!+[]]+((+[])[([][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]+[])[+!+[]+[+!+[]]])[+!+[]]
@wakfi as it was written in this question https://stackoverflow.com/questions/63673610/alternative-way-to-get-c-letter-in-jsfuck - btoa
not works on node.js (solution provided there has <1.5kb). @baboures escape/unescape solutions are also discussed in answers in that link
@wakfi as it was written in this question https://stackoverflow.com/questions/63673610/alternative-way-to-get-c-letter-in-jsfuck -
btoa
not works on node.js
@kamil-kielczewski btoa
is supported in nodejs under legacy stability level support. Apparently it was only added (as a global) in nodejs v16 though, I hadn't realized that. It was added (and will be kept) as a measure to improve interoperability between browser JavaScript and NodeJS JavaScript
@wakfi thank you for that info - I will check it
I tried making a version called JSFourk, where instead, you only get the characters []+!
. Obviously you can't get as far with it as you can't call methods, but it had some interesting challenges to overcome with it:
In JSFuck you can use parentheses for the order of operations which is very useful. For example if I wanted to get the character f
in JSFuck, I could just do this:
(![]+[])[+[]] // f
but without the use of parentheses, it adds a whole new aspect. The way to get around this is to simply put your expression into an array and select the first item from that array, like this:
[ /* expression */ ][+[]]
so the letter f
in JSFourk would be this:
[![]+[]][+[]][+[]] // f
I don't know if anybody has ever done this before. I made a JSFuck variant using
<
instead of!
.JSFuckr: An esoteric language based on JSFuck
Try it!
Is this a novel idea, or I am reinventing the wheel? 😅