(userScript: unknown)
| 428 | |
| 429 | |
| 430 | protected async userScriptDelegator(userScript: unknown) { |
| 431 | switch (typeof userScript) { |
| 432 | case "function": |
| 433 | if (!isUserScriptFunction(userScript)) { |
| 434 | break; |
| 435 | } |
| 436 | if (this.userScriptCommand) { |
| 437 | await this.runScriptWithSettings( |
| 438 | userScript, |
| 439 | this.userScriptCommand |
| 440 | ); |
| 441 | } else { |
| 442 | await this.onExportIsFunction(userScript); |
| 443 | } |
| 444 | break; |
| 445 | case "object": |
| 446 | if (isUserScriptObjectExport(userScript)) { |
| 447 | await this.onExportIsObject(userScript); |
| 448 | } |
| 449 | break; |
| 450 | case "bigint": |
| 451 | case "boolean": |
| 452 | case "number": |
| 453 | case "string": |
| 454 | this.output = userScript.toString(); |
| 455 | break; |
| 456 | default: |
| 457 | log.logError( |
| 458 | `user script in macro for '${this.choice.name}' is invalid` |
| 459 | ); |
| 460 | } |
| 461 | } |
| 462 | |
| 463 | private async onExportIsFunction( |
| 464 | userScript: ( |
no test coverage detected