de4js works as a web application, so its integration into a B4J project depends on what you want to do with it.
If you simply want to display the de4js interface in your B4J application, you can use a WebView component.
This allows you to use the tool as is, directly in your B4J app
Example:
[CODE lang="b4x" title="WebView"]Dim WebView1 As WebView
WebView1.Initialize("")
MainForm.RootPane.AddNode(WebView1, 10, 10, 800, 600)
WebView1.LoadUrl("https://lelinhtinh.github.io/de4js/")[/CODE]
If you want to deobfuscate automatically, you can download the de4js source code, extract the useful JavaScript functions (like those for decompression or deobfuscation),
and use a JavaScript engine in B4J like Nashorn, via JavaObject.
You must include the necessary JS functions in your eval call.
Simplified example Nashorn
[CODE lang="b4x" title="JavaObject"]Dim engine As JavaObject
engine = engine.InitializeStatic("javax.script.ScriptEngineManager").RunMethod("getEngineByName", Array("nashorn"))
engine.RunMethod("eval", Array("var code = 'obfuscated...'; var result = deobfuscate(code);"))
Dim result As String = engine.RunMethod("get", Array("result"))[/CODE]
If you prefer to run the deobfuscator externally, create a Node.js script with de4js functions
Call this script from B4J with Shell
[CODE lang="b4x" title="jshell"]Dim sh As Shell
sh.Initialize("sh", "node", Array("deobfuscate.js", "code.js"))
sh.Run(10000)[/CODE]
These are just examples. It's up to you to explore the subject further