shawenguan пре 1 година
родитељ
комит
ee951b1bcc
1 измењених фајлова са 17 додато и 16 уклоњено
  1. 17 16
      Scripts/unicom/unicomRechargeDisc.js

+ 17 - 16
Scripts/unicom/unicomRechargeDisc.js

@@ -372,29 +372,30 @@ async function getTaskMapData(activityId) {
         }
         return null;
     } else {
-        const regex = /([a-zA-Z_]\w*)\s*\(/g; // 匹配函数名称,后接左右括号
-        const matches = [];
+        let regex = /([a-zA-Z_]\w*)\s*\(/g; // 匹配函数名称,后接左右括号
+        let matches = [];
         let match;
-        while ((match = regex.exec(codeString)) !== null) {
+        while ((match = regex.exec(codeDataStr)) !== null) {
             matches.push(match[1]); // 将匹配的函数名称添加到数组中
         }
         magicJS.logger.info(`matches=${JSON.stringify(matches)}`);
         // 去重
         const uniqueMatches = [...new Set(matches)];
-        let taskMapObject = null;
+        let funcName = null;
         if (uniqueMatches.length == 1) {
-            taskMapObject = {};
-            let funcName = uniqueMatches[0];
-            const regex = new RegExp(`${funcName}\\("([^"]+)",\\s*({.*?})\\);`, 'g');
-            let match;
-            while ((match = regex.exec(codeDataStr)) !== null) {
-                try {
-                    const id = match[1];
-                    const urlObject = JSON.parse(match[2]);
-                    taskMapObject[id] = urlObject;
-                } catch (error) {
-
-                }
+            funcName = uniqueMatches[0];
+        } else {
+            funcName = matches[matches.length - 1];
+        }
+        let taskMapObject = {};
+        regex = new RegExp(`${funcName}\\("([^"]+)",\\s*({.*?})\\);`, 'g');
+        while ((match = regex.exec(codeDataStr)) !== null) {
+            try {
+                const id = match[1];
+                const urlObject = JSON.parse(match[2]);
+                taskMapObject[id] = urlObject;
+            } catch (error) {
+
             }
         }
         return taskMapObject;