对于选中文字,进行百度翻译,第二次选中并执行动作后,可以在同一标签页翻译,不用新增标签页。
逻辑流程图(如下):
下面是导出的动作库:
{
"LimitSingleInstance": true,
"SummaryExpression": "",
"SubPrograms": [],
"Variables": [
{
"Key": "context",
"IsLocked": false,
"Type": 0,
"Desc": "默认的文本变量",
"DefaultValue": "",
"SaveState": false,
"IsInput": false,
"IsOutput": false,
"ParamName": null,
"InputParamInfo": null,
"OutputParamInfo": null,
"TableDef": null,
"CustomType": null,
"Group": null
},
{
"Key": "img",
"IsLocked": false,
"Type": 3,
"Desc": "默认的图片变量",
"DefaultValue": "",
"SaveState": false,
"IsInput": false,
"IsOutput": false,
"ParamName": null,
"InputParamInfo": null,
"OutputParamInfo": null,
"TableDef": null,
"CustomType": null,
"Group": null
},
{
"Key": "tabId_Baidu_fanyi",
"IsLocked": false,
"Type": 12,
"Desc": "",
"DefaultValue": "",
"SaveState": true,
"IsInput": false,
"IsOutput": false,
"ParamName": "",
"InputParamInfo": null,
"OutputParamInfo": null,
"TableDef": null,
"CustomType": null,
"Group": ""
},
{
"Key": "isSuccess",
"IsLocked": false,
"Type": 2,
"Desc": "",
"DefaultValue": "",
"SaveState": false,
"IsInput": false,
"IsOutput": false,
"ParamName": "",
"InputParamInfo": null,
"OutputParamInfo": null,
"TableDef": null,
"CustomType": null,
"Group": ""
}
],
"Steps": [
{
"StepRunnerKey": "sys:getSelectedText",
"InputParams": {
"format": {
"VarKey": null,
"Value": "UnicodeText"
},
"repeat": {
"VarKey": null,
"Value": "0"
},
"useActionParam": {
"VarKey": null,
"Value": "0"
},
"stopIfFail": {
"VarKey": null,
"Value": "1"
}
},
"OutputParams": {
"output": "context",
"outputEncoded": null,
"url": null,
"isSuccess": null
},
"IfSteps": null,
"ElseSteps": null,
"Note": "",
"Disabled": false,
"Collapsed": false,
"DelayMs": 0
},
{
"StepRunnerKey": "sys:assign",
"InputParams": {
"input": {
"VarKey": null,
"Value": "$= Uri.EscapeDataString({context})"
},
"stopIfFail": {
"VarKey": null,
"Value": "1"
}
},
"OutputParams": {
"isSuccess": null,
"output": "context"
},
"IfSteps": null,
"ElseSteps": null,
"Note": "",
"Disabled": false,
"Collapsed": false,
"DelayMs": 0
},
{
"StepRunnerKey": "sys:chromecontrol",
"InputParams": {
"operation": {
"VarKey": null,
"Value": "ActivateTab"
},
"tabId": {
"VarKey": null,
"Value": "$${tabId_Baidu_fanyi}"
},
"url": {
"VarKey": null,
"Value": "$$https://fanyi.baidu.com/#auto/zh/*"
},
"stopIfFail": {
"VarKey": null,
"Value": "0"
}
},
"OutputParams": {
"isSuccess": "isSuccess",
"tabId": null,
"windowId": null,
"groupId": null,
"url": null,
"title": null,
"favicon": null,
"rawResponse": null,
"errMessage": null
},
"IfSteps": null,
"ElseSteps": null,
"Note": "",
"Disabled": false,
"Collapsed": false,
"DelayMs": 0
},
{
"StepRunnerKey": "sys:if",
"InputParams": {
"condition": {
"VarKey": null,
"Value": "$={isSuccess}"
}
},
"OutputParams": {},
"IfSteps": [
{
"StepRunnerKey": "sys:chromecontrol",
"InputParams": {
"operation": {
"VarKey": null,
"Value": "RunScript"
},
"tabId": {
"VarKey": null,
"Value": "$${tabId_Baidu_fanyi}"
},
"script": {
"VarKey": null,
"Value": "$$window.location.href = \"https://fanyi.baidu.com/#auto/zh/{context}\";"
},
"timeoutMs": {
"VarKey": null,
"Value": "3000"
},
"frame": {
"VarKey": null,
"Value": "all"
},
"executionWorld": {
"VarKey": null,
"Value": ""
},
"waitManualReturn": {
"VarKey": null,
"Value": "0"
},
"stopIfFail": {
"VarKey": null,
"Value": "1"
}
},
"OutputParams": {
"isSuccess": null,
"rawResponse": null,
"errMessage": null
},
"IfSteps": null,
"ElseSteps": null,
"Note": "",
"Disabled": false,
"Collapsed": false,
"DelayMs": 0
}
],
"ElseSteps": [
{
"StepRunnerKey": "sys:chromecontrol",
"InputParams": {
"operation": {
"VarKey": null,
"Value": "OpenUrl"
},
"windowId": {
"VarKey": null,
"Value": ""
},
"url": {
"VarKey": null,
"Value": "$$https://fanyi.baidu.com/#auto/zh/{context}"
},
"windowInfo": {
"VarKey": null,
"Value": ""
},
"waitComplete": {
"VarKey": null,
"Value": "0"
},
"timeoutMs": {
"VarKey": null,
"Value": "3000"
},
"stopIfFail": {
"VarKey": null,
"Value": "1"
}
},
"OutputParams": {
"isSuccess": null,
"tabId": "tabId_Baidu_fanyi",
"windowId": null,
"rawResponse": null,
"errMessage": null
},
"IfSteps": null,
"ElseSteps": null,
"Note": "",
"Disabled": false,
"Collapsed": false,
"DelayMs": 0
}
],
"Note": "",
"Disabled": false,
"Collapsed": false,
"DelayMs": 0
}
]
}