js-confuser
js-confuser copied to clipboard
SyntaxError: 'return' outside of function (3:4)
SyntaxError: 'return' outside of function (3:4)
var base_url = window.location.host; if (base_url != "example.com") return; Why did the error occur?
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;
})();
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
Parse the AST yourself with acorn and add the allowReturnOutsideFunction like described in https://github.com/acornjs/acorn/issues/86