Closed nblog closed 1 week ago
At the moment, import/export is not supported. Two JavaScript scripts cannot directly reference each other. That said, they can reference each other through the data model either indirectly (preferred) or directly (less preferred).
Take the following script example (executed as a saved "console.js"):
"use strict";
function log(...args)
{
host.diagnostics.debugLog(`${args}\n`);
}
class __Console
{
log(...args)
{
host.diagnostics.debugLog(`${args}\n`);
}
}
class __ScriptUtility
{
get Console()
{
return new __Console();
}
}
function initializeScript()
{
return [new host.apiVersionSupport(1, 9),
new host.namespacePropertyParent(__ScriptUtility, "Debugger.Models.Utility", "Debugger.Models.Utility.Script", "Script")];
}
This exposes the functionality of log in two ways:
Now it's usage from another script:
"use strict";
function getConsole1()
{
return host.namespace.Debugger.State.Scripts.console.Contents;
}
function getConsole2()
{
return host.namespace.Debugger.Utility.Script.Console;
}
function invokeScript()
{
getConsole1().log("Hello World #1");
getConsole2().log("Hello World #2");
}
function initializeScript()
{
return [new host.apiVersionSupport(1, 9)];
}
You can see both ways that the underlying functionality of the other script is used.
There are other similar mechanisms that can be used:
Hope that clarifies a bit...
console.js
test.js
How can multiple JavaScript scripts be used in combination, or is there a similar compiler (merge)?
Something like frida-compile?