Convert JSF**k to normal JS

Javascript - 68 55 51

alert(/\n(.+)/.exec(eval(prompt().slice(0,-2)))[1])

Alternatively: (same length)

alert(/.+(?=\n})/.exec(eval(prompt().slice(0,-2))))

Runs in the console of your browser. Only guaranteed to work with code generated by jsfuck.com with the 'Eval Source' option ticked.

Ungolfed:

alert(
    /\n(.+)/.exec(                 // regex to extract code from inside outer function braces {}
        eval(prompt().slice(0,-2)) // remove the final set of parens () and evaluate the code
                                   // this results in a function, which will be converted to a string as 'exec' expects a string
    )[1]                           // get the first capture group
)

JavaScript, 122, works with any input

s=prompt().slice(0,-2)
i=s.length
while(i--){if((l=s.slice(i)).split(')').length==l.split('(').length)break}alert(eval(l))

Pretty simple; it just goes back in the string until the parentheses (( and )) are balanced. The last three characters of the JSF output are always )(), so slicing off the last 2 parens and then finding the matching paren for the other will always work. (It works with input with [] too.)

Tags:

Code Golf