mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
81 lines
2.6 KiB
TypeScript
81 lines
2.6 KiB
TypeScript
import { IExpressionStatementNode } from "../../interfaces/nodes/IExpressionStatementNode";
|
|
|
|
import { TBlockScopeNode } from "../../types/TBlockScopeNode";
|
|
|
|
import { NodeType } from '../../enums/NodeType';
|
|
|
|
import { Node } from '../Node';
|
|
import { NodeUtils } from '../../NodeUtils';
|
|
|
|
export class DebugProtectionFunctionIntervalNode extends Node {
|
|
/**
|
|
* @type {string}
|
|
*/
|
|
private debugProtectionFunctionName: string;
|
|
|
|
/**
|
|
* @param debugProtectionFunctionName
|
|
*/
|
|
constructor (debugProtectionFunctionName: string) {
|
|
super();
|
|
|
|
this.debugProtectionFunctionName = debugProtectionFunctionName;
|
|
|
|
this.node = this.getNodeStructure();
|
|
}
|
|
|
|
/**
|
|
* @param blockScopeNode
|
|
*/
|
|
public appendNode (blockScopeNode: TBlockScopeNode): void {
|
|
NodeUtils.appendNode(blockScopeNode.body, this.getNode());
|
|
}
|
|
|
|
/**
|
|
* @returns {IExpressionStatementNode}
|
|
*/
|
|
protected getNodeStructure (): IExpressionStatementNode {
|
|
return {
|
|
'type': NodeType.ExpressionStatement,
|
|
'expression': {
|
|
'type': NodeType.CallExpression,
|
|
'callee': {
|
|
'type': NodeType.Identifier,
|
|
'name': 'setInterval'
|
|
},
|
|
'arguments': [
|
|
{
|
|
'type': NodeType.FunctionExpression,
|
|
'id': null,
|
|
'params': [],
|
|
'defaults': [],
|
|
'body': {
|
|
'type': NodeType.BlockStatement,
|
|
'body': [
|
|
{
|
|
'type': NodeType.ExpressionStatement,
|
|
'expression': {
|
|
'type': NodeType.CallExpression,
|
|
'callee': {
|
|
'type': NodeType.Identifier,
|
|
'name': this.debugProtectionFunctionName
|
|
},
|
|
'arguments': []
|
|
}
|
|
}
|
|
]
|
|
},
|
|
'generator': false,
|
|
'expression': false
|
|
},
|
|
{
|
|
'type': NodeType.Literal,
|
|
'value': 4000,
|
|
'raw': '4000'
|
|
}
|
|
]
|
|
}
|
|
};
|
|
}
|
|
}
|