MichaelXF / js-confuser

JS-Confuser is a JavaScript obfuscation tool to make your programs *impossible* to read.
https://js-confuser.com
MIT License
168 stars 28 forks source link

SyntaxError: 'return' outside of function (3:4) #121

Open batongprodt opened 6 months ago

batongprodt commented 6 months ago

SyntaxError: 'return' outside of function (3:4)

var base_url = window.location.host; if (base_url != "example.com") return; Why did the error occur?

Le0Developer commented 3 months ago

you can only return inside a function, which you do not have.

use an IIFE:

(() => {
  var base_url = window.location.host;
  if (base_url != "example.com")
    return;
})();
younes-zeboudj commented 2 months ago

js-obfuscator supports return outside a function, it should be possible to do it, and it is useful, I am dealing with a use case where I need it

Le0Developer commented 2 months ago

Parse the AST yourself with acorn and add the allowReturnOutsideFunction like described in https://github.com/acornjs/acorn/issues/86