Browse Source

小红书养号

yichael 2 months ago
parent
commit
47c3c39c6f

+ 4 - 3
nodejs/ef-compiler/actions/delay-parser.js

@@ -1,4 +1,4 @@
-/** 语句:delay 延迟(value 支持变量如 "{{stay-duration}}s";格式:数字+单位 s/m/h) */
+/** 语句:delay 延迟(value 支持变量如 "{{stay-duration}}s";单位 ms/s/m/h/d/w/mon/月/y,可组合,纯数字按秒) */
 const types = ['delay']
 
 function parse(action, parseContext) {
@@ -11,8 +11,9 @@ async function execute(action, ctx) {
   const resolved = ctx.replaceVariablesInString && ctx.variableContext
     ? ctx.replaceVariablesInString(String(raw), ctx.variableContext)
     : raw
-  const delayMs = ctx.parseDelayString(resolved)
-  if (delayMs > 0) await new Promise(r => setTimeout(r, delayMs))
+  const delayMs = ctx.parseDelayString ? ctx.parseDelayString(resolved) : 0
+  const waitMs = typeof delayMs === 'number' && delayMs > 0 ? delayMs : 0
+  if (waitMs > 0) await new Promise(r => setTimeout(r, waitMs))
   return { success: true }
 }
 

+ 16 - 7
nodejs/ef-compiler/actions/set-parser.js

@@ -76,6 +76,7 @@ function parseTimeString(timeStr) {
   }
 }
 
+// 时长单位(毫秒):ms/s/m/h/d/w/mon/月/y;组合如 1y3mon、1h30m、2d
 const DELAY_UNIT_MS = {
   ms: 1,
   s: 1000,
@@ -83,29 +84,37 @@ const DELAY_UNIT_MS = {
   h: 60 * 60 * 1000,
   d: 24 * 60 * 60 * 1000,
   w: 7 * 24 * 60 * 60 * 1000,
+  mon: 30 * 24 * 60 * 60 * 1000,
   '月': 30 * 24 * 60 * 60 * 1000,
   y: 365 * 24 * 60 * 60 * 1000,
 }
 
-/** 解析时长字符串,支持单位 ms/s/m/h/d/w/月,支持组合如 1h3m48s、2d30m */
+/** 解析时长字符串。单位:ms(毫秒) s(秒) m(分) h(时) d(天) w(周) mon/月(月) y(年),可组合如 1y3mon、7s、1h30m。纯数字按秒处理。 */
 function parseDelayString(delayStr) {
-  if (!delayStr || typeof delayStr !== 'string' || delayStr.trim() === '') return 0
+  if (delayStr == null) return 0
+  if (typeof delayStr === 'number' && !Number.isNaN(delayStr) && delayStr >= 0) return Math.round(delayStr * 1000)
+  if (typeof delayStr !== 'string' || delayStr.trim() === '') return 0
   try {
-    const trimmed = delayStr.trim()
-    const re = /(\d+)\s*(ms|s|m|h|d|w|月|y)/g
+    const trimmed = String(delayStr).trim()
+    // 单位顺序:ms、mon 必须在 m、s 前,避免被拆成 m+s
+    const re = /(\d+)\s*(ms|mon|s|m|h|d|w|月|y)/gi
     let total = 0
     let hadMatch = false
     let match
     while ((match = re.exec(trimmed)) !== null) {
       const value = parseInt(match[1], 10)
-      const unit = match[2]
+      const unit = match[2].toLowerCase()
       if (value < 0 || !DELAY_UNIT_MS[unit]) continue
       total += value * DELAY_UNIT_MS[unit]
       hadMatch = true
     }
-    return hadMatch ? total : null
+    if (hadMatch) return total
+    // 纯数字视为秒(如 "15" 或变量解析后只剩数字)
+    const bare = /^\d+$/.test(trimmed)
+    if (bare) return parseInt(trimmed, 10) * 1000
+    return 0
   } catch (e) {
-    return null
+    return 0
   }
 }
 

+ 18 - 17
static/process/RedNoteBrowsingAndThumbsUp/process.json

@@ -2,14 +2,15 @@
 	"name": "RedNoteBrowsingAndThumbsUp",
         "description": "小红书随机浏览和点赞",
 	"variables": {
-		"page-index":0,
-		"up-or-down":0,
-		"swipe-count":0,
-		"click-x":0,
-		"click-y":0,
-		"random-click-pos":"",
-		"stay-duration":0,
-		"send-btn-pos": ""
+		"page-index": 0,
+		"up-or-down": 0,
+		"swipe-count": 0,
+		"click-x": 0,
+		"click-y": 0,
+		"random-click-pos": "",
+		"stay-duration": 0,
+		"send-btn-pos": "",
+		"b-like-click": 0
 	},
 	"execute": 
 	[
@@ -21,14 +22,14 @@
 				{
 					"type": "random",
 					"inVars": ["1", "3"],
-					"outVars": ["{swipeCount}"]
+					"outVars": ["{swipe-count}"]
 				},
 				{
 					"type": "schedule",
 					"condition": 
 					{
 						"interval": "7s",
-						"repeat": "{swipeCount}"
+						"repeat": "{swipe-count}"
 					},
 					"interval": 
 					[
@@ -43,17 +44,17 @@
 				{
 					"type": "random",
 					"inVars": ["200", "780"],
-					"outVars": ["{clickX}"]
+					"outVars": ["{click-x}"]
 				},
 				{
 					"type": "random",
-					"inVars": ["400", "2000"],
-					"outVars": ["{clickY}"]
+					"inVars": ["400", "1500"],
+					"outVars": ["{click-y}"]
 				},
 				{
 					"type": "set",
 					"variable": "{random-click-pos}",
-					"value": "{clickX},{clickY}"
+					"value": "{click-x},{click-y}"
 				},
 				{
 					
@@ -72,7 +73,7 @@
 					[
 						{
 							"type": "img-center-point-location",
-							"inVars": ["视频点赞.png"],
+							"inVars": ["视频点赞.png", [0.2, 1.6]],
 							"outVars": ["{send-btn-pos}"]
 						}
 					],
@@ -81,11 +82,11 @@
 						{
 							"type": "random",
 							"inVars": ["2", "10"],
-							"outVars": ["{swipeCount}"]
+							"outVars": ["{swipe-count}"]
 						},
 						{
 							"type": "for",
-							"times": "{swipeCount}",
+							"times": "{swipe-count}",
 							"variable": "{i}",
 							"body": 
 							[