mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
dev
This commit is contained in:
@@ -31,6 +31,9 @@ class UnicodeArrayNode extends Node_1.Node {
|
||||
this.updateNode();
|
||||
return super.getNode();
|
||||
}
|
||||
updateNodeData(data) {
|
||||
this.unicodeArray.push(data);
|
||||
}
|
||||
getNodeStructure() {
|
||||
return {
|
||||
'type': NodeType_1.NodeType.VariableDeclaration,
|
||||
|
||||
+6
-6
@@ -41,19 +41,19 @@ class NodeObfuscator {
|
||||
return this.replaceLiteralValueByUnicodeArrayCall(value);
|
||||
}
|
||||
replaceLiteralValueByUnicodeArrayCall(value) {
|
||||
let unicodeArray = this.nodes.get('unicodeArrayNode').getNodeData(), sameIndex = unicodeArray.indexOf(value), index, hexadecimalIndex;
|
||||
if (sameIndex < 0) {
|
||||
index = unicodeArray.length;
|
||||
unicodeArray.push(value);
|
||||
let unicodeArrayNode = this.nodes.get('unicodeArrayNode'), unicodeArray = unicodeArrayNode.getNodeData(), sameIndex = unicodeArray.indexOf(value), index, hexadecimalIndex;
|
||||
if (sameIndex >= 0) {
|
||||
index = sameIndex;
|
||||
}
|
||||
else {
|
||||
index = sameIndex;
|
||||
index = unicodeArray.length;
|
||||
unicodeArrayNode.updateNodeData(value);
|
||||
}
|
||||
hexadecimalIndex = this.replaceLiteralNumberByHexadecimalValue(index);
|
||||
if (this.options['wrapUnicodeArrayCalls']) {
|
||||
return `${this.nodes.get('unicodeArrayCallsWrapper').getNodeIdentifier()}('${hexadecimalIndex}')`;
|
||||
}
|
||||
return `${this.nodes.get('unicodeArrayNode').getNodeIdentifier()}[${hexadecimalIndex}]`;
|
||||
return `${unicodeArrayNode.getNodeIdentifier()}[${hexadecimalIndex}]`;
|
||||
}
|
||||
}
|
||||
exports.NodeObfuscator = NodeObfuscator;
|
||||
|
||||
@@ -87,6 +87,13 @@ export class UnicodeArrayNode extends Node {
|
||||
return super.getNode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param data
|
||||
*/
|
||||
public updateNodeData (data: string): void {
|
||||
this.unicodeArray.push(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {INode}
|
||||
*/
|
||||
|
||||
Vendored
+5
@@ -34,4 +34,9 @@ export interface ICustomNode {
|
||||
setNode (node: INode): void;
|
||||
|
||||
updateNode (): void;
|
||||
|
||||
/**
|
||||
* @param data
|
||||
*/
|
||||
updateNodeData ? (data: any): void;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import { JSFuck } from "../enums/JSFuck";
|
||||
|
||||
import { NodeUtils } from "../NodeUtils";
|
||||
import { Utils } from '../Utils';
|
||||
import {UnicodeArrayNode} from "../custom-nodes/unicode-array-nodes/UnicodeArrayNode";
|
||||
|
||||
export abstract class NodeObfuscator implements INodeObfuscator {
|
||||
/**
|
||||
@@ -106,16 +107,17 @@ export abstract class NodeObfuscator implements INodeObfuscator {
|
||||
* @returns {string}
|
||||
*/
|
||||
protected replaceLiteralValueByUnicodeArrayCall (value: string): string {
|
||||
let unicodeArray: string[] = this.nodes.get('unicodeArrayNode').getNodeData(),
|
||||
let unicodeArrayNode: UnicodeArrayNode = <UnicodeArrayNode> this.nodes.get('unicodeArrayNode'),
|
||||
unicodeArray: string[] = unicodeArrayNode.getNodeData(),
|
||||
sameIndex: number = unicodeArray.indexOf(value),
|
||||
index: number,
|
||||
hexadecimalIndex: string;
|
||||
|
||||
if (sameIndex < 0) {
|
||||
index = unicodeArray.length;
|
||||
unicodeArray.push(value);
|
||||
} else {
|
||||
if (sameIndex >= 0) {
|
||||
index = sameIndex;
|
||||
} else {
|
||||
index = unicodeArray.length;
|
||||
unicodeArrayNode.updateNodeData(value);
|
||||
}
|
||||
|
||||
hexadecimalIndex = this.replaceLiteralNumberByHexadecimalValue(index);
|
||||
@@ -124,6 +126,6 @@ export abstract class NodeObfuscator implements INodeObfuscator {
|
||||
return `${this.nodes.get('unicodeArrayCallsWrapper').getNodeIdentifier()}('${hexadecimalIndex}')`;
|
||||
}
|
||||
|
||||
return `${this.nodes.get('unicodeArrayNode').getNodeIdentifier()}[${hexadecimalIndex}]`;
|
||||
return `${unicodeArrayNode.getNodeIdentifier()}[${hexadecimalIndex}]`;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user