feat: 步骤新增剪贴板注入(可注入+粘贴,批量发链接场景)+ adb终端快捷命令 tcpip 5555 转网络调试

This commit is contained in:
2026-08-15 15:53:31 +08:00
parent 17f849f723
commit a51857d143
3 changed files with 34 additions and 0 deletions
+9
View File
@@ -8,6 +8,7 @@ var STEP_LIB=[
{type:'swipe',label:'滑动',icon:'↕',cat:'interact',params:{direction:'up',duration_min:0.25,duration_max:0.50}},
{type:'swipe_until',label:'滑动直到元素',icon:'🔍',cat:'interact',params:{selector_type:'xpath',selector_value:'',direction:'up',max_swipes:8,click_when_found:true}},
{type:'input_text',label:'输入文字',icon:'⌨',cat:'interact',params:{mode:'random',texts:'你好\n有趣\n支持',fixed_text:'',clear_first:true}},
{type:'clipboard',label:'剪贴板注入',icon:'📋',cat:'interact',params:{text:'',paste:true}},
{type:'key_event',label:'按键',icon:'⌨️',cat:'interact',params:{key:'back'}},
{type:'open_app',label:'打开App',icon:'▶',cat:'screen',params:{package:'',wait_home:false,home_feature:''}},
{type:'stop_app',label:'结束App',icon:'⏹',cat:'screen',params:{package:''}},
@@ -326,6 +327,10 @@ var _stepEditor={
}else if(step.type==='wait'){
h+='<div class="form-row"><div class="form-group"><label>最短(秒)</label><input type="number" class="form-control" data-key="min" value="'+(p.min||1.0)+'" step="0.5" min="0.1"></div>';
h+='<div class="form-group"><label>最长(秒)</label><input type="number" class="form-control" data-key="max" value="'+(p.max||3.0)+'" step="0.5" min="0.1"></div></div>';
}else if(step.type==='clipboard'){
h+='<div class="form-group"><label>注入内容</label><textarea class="form-control" data-key="text" rows="3" style="font-family:monospace;min-height:70px">'+esc(p.text||'')+'</textarea></div>';
h+='<div class="form-group form-check"><input type="checkbox" data-key="paste" '+(p.paste!==false?'checked':'')+'><label>注入后立即粘贴(需输入框已聚焦)</label></div>';
h+='<div class="help">批量发链接场景:先"点击元素"聚焦评论区输入框,再执行本步骤注入+粘贴;循环里依次更换注入内容即可逐个发</div>';
}else if(step.type==='input_text'){
const im=p.mode==='fixed'?'fixed':'random';
h+='<div class="form-group"><label>输入模式</label><select class="form-control" data-key="mode" onchange="_stepEditor._toggleInputMode(this)">'+
@@ -715,6 +720,10 @@ var _stepEditor={
}else if(s.params.mode==='random'&&!s.params.texts){
warnings.push(name+' "'+label+'": 候选文字为空');
}
}else if(s.type==='clipboard'){
if(!s.params.text){
warnings.push(name+' "'+label+'": 注入内容为空,步骤会跳过。');
}
}else if(s.type==='if_el'){
if(!s.params.selector_value){
warnings.push(name+' "'+label+'": 条件判断的选择器为空,会直接走"未找到"分支。');
+24
View File
@@ -69,6 +69,8 @@ STEP_TYPES = [
"params": {"selector_type": "xpath", "selector_value": "", "timeout": 10}},
{"type": "input_text", "label": "输入文字", "icon": "⌨",
"params": {"mode": "random", "texts": "你好\n有趣\n支持", "fixed_text": "", "clear_first": True}},
{"type": "clipboard", "label": "剪贴板注入", "icon": "📋",
"params": {"text": "", "paste": True}},
{"type": "wait", "label": "等待", "icon": "⏱",
"params": {"min": 1.0, "max": 3.0}},
{"type": "loop", "label": "循环块", "icon": "↻",
@@ -475,6 +477,28 @@ class GenericStepsWorker(BaseWorker):
_log.warning(f"[{self.serial}] click 异常: {e}")
return found # 命中结果,"测试此步骤"用
def _exec_clipboard(self, d, params, depth=0):
"""剪贴板注入:写入指定内容到剪贴板,可选立即粘贴到当前聚焦的输入框。
批量发链接场景:先聚焦评论区输入框 → 注入+粘贴链接1 → 换链接 → 注入+粘贴链接2……
粘贴模式复用 u2 send_keys(内部 setClipboard + pasteClipboard,与"输入文字"同机制)。
"""
text = str(params.get("text", "") or "")
if not text:
_log.warning(f"[{self.serial}] clipboard 内容为空,跳过")
return False
try:
if params.get("paste"):
d.send_keys(text) # setClipboard + pasteClipboard
_log.info(f"[{self.serial}] 剪贴板注入并粘贴: {text[:60]}")
else:
d.set_clipboard(text)
_log.info(f"[{self.serial}] 剪贴板注入(不粘贴): {text[:60]}")
return True
except Exception as e:
_log.warning(f"[{self.serial}] 剪贴板注入异常: {e}")
return False
def _exec_wait(self, d, params, depth=0):
min_s = float(params.get("min", 1.0))
max_s = float(params.get("max", 3.0))
+1
View File
@@ -543,6 +543,7 @@ select.form-control{cursor:pointer}
<button class="btn btn-xs" onclick="fillAdbCmd('shell ls /sdcard')">列文件</button>
<button class="btn btn-xs" onclick="fillAdbCmd('shell screencap -p /sdcard/shot.png')">截屏</button>
<button class="btn btn-xs" onclick="fillAdbCmd('shell pm list packages -3')">已装应用</button>
<button class="btn btn-xs" onclick="fillAdbCmd('tcpip 5555')" title="USB 设备开启网络调试(重启设备后失效,需重新执行)">tcpip 5555 转网络调试</button>
</div>
<div style="display:flex;gap:6px;margin-bottom:8px;flex-wrap:wrap">
<button class="btn btn-xs btn-danger" onclick="uninstallStfAgent()" title="卸载 jp.co.cyberagent.stf,STF 会在设备重连时重新推送">卸载 STF agent(卡死时用)</button>