Skip to content

Commit a629da1

Browse files
committed
Added const prefix replacer
1 parent 73b7cfb commit a629da1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

functions/xDecoder.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module.exports = function () {
44
const Decoder = {};
55

66
Decoder.decode = function decode(type, targetName, code) {
7+
code = this.replaceConstant(targetName, code);
78
switch (type) {
89
case 0:
910
return Decoder.decodeType0(targetName, code);
@@ -25,6 +26,11 @@ module.exports = function () {
2526
return code;
2627
}
2728

29+
Decoder.replaceConstant = function (targetName, code) {
30+
// replace const to var if target func is constant
31+
return code.replace(new RegExp(`const ${targetName}\\s*=`), `var ${targetName}=`);
32+
}
33+
2834
Decoder.decodeType0 = function (targetName, code) { // array like _0xf13b[274] not func
2935
eval(`var ${targetName} = null`);
3036
try {

0 commit comments

Comments
 (0)