Automa自动填表记录
网友找我说需要自动化填表,不知道怎么实现,就帮他搞了一个,顺便记录一下过程。利用Chrome插件Automa来进行自动化处理
需求:随机名字首字母,年龄在50-90之间,随机性别,随机单选,随机多选。
实现代码如下,重点在于Automa支持{{$randint(min, max)}} 可以直接生成随机数字,随机名字利用JavaScript随机组合。
{
"extVersion": "1.28.25",
"name": "填表-完整填写",
"icon": "riGlobalLine",
"table": [],
"version": "1.28.23",
"drawflow": {
"edges": [{
"data": {},
"events": {},
"id": "vueflow__edge-5w2JcfM4TBz5SSv5ZycW65w2JcfM4TBz5SSv5ZycW6-output-1-80xttn480xttn4-input-1",
"markerEnd": "arrowclosed",
"selectable": true,
"source": "5w2JcfM4TBz5SSv5ZycW6",
"sourceHandle": "5w2JcfM4TBz5SSv5ZycW6-output-1",
"sourceX": 289.628160070651,
"sourceY": 327.38476387328063,
"target": "80xttn4",
"targetHandle": "80xttn4-input-1",
"targetX": 322.043827195547,
"targetY": 326.44276504160104,
"type": "custom",
"updatable": true
}, {
"data": {},
"events": {},
"id": "vueflow__edge-til2oe8til2oe8-output-1-fraiswkfraiswk-input-1",
"markerEnd": "arrowclosed",
"selectable": true,
"source": "til2oe8",
"sourceHandle": "til2oe8-output-1",
"sourceX": 830.1832024787284,
"sourceY": 324.18785557014036,
"target": "fraiswk",
"targetHandle": "fraiswk-input-1",
"targetX": 879.3117315301369,
"targetY": 326.3033133006178,
"type": "custom",
"updatable": true
}, {
"data": {},
"events": {},
"id": "vueflow__edge-80xttn480xttn4-output-1-til2oe8til2oe8-input-1",
"markerEnd": "arrowclosed",
"selectable": true,
"source": "80xttn4",
"sourceHandle": "80xttn4-output-1",
"sourceX": 554.0435727001013,
"sourceY": 326.44276504160104,
"target": "til2oe8",
"targetHandle": "til2oe8-input-1",
"targetX": 598.1833392254744,
"targetY": 324.18785557014036,
"type": "custom",
"updatable": true
}, {
"data": {},
"events": {},
"id": "vueflow__edge-fraiswkfraiswk-output-1-l96qhs2l96qhs2-input-1",
"markerEnd": "arrowclosed",
"selectable": true,
"source": "fraiswk",
"sourceHandle": "fraiswk-output-1",
"sourceX": 1111.3113592859916,
"sourceY": 326.3033133006178,
"target": "l96qhs2",
"targetHandle": "l96qhs2-input-1",
"targetX": 124.49541026529062,
"targetY": 498.5635199833134,
"type": "custom",
"updatable": true
}, {
"data": {},
"events": {},
"id": "vueflow__edge-l96qhs2l96qhs2-output-1-4vhllhn4vhllhn-input-1",
"markerEnd": "arrowclosed",
"selectable": true,
"source": "l96qhs2",
"sourceHandle": "l96qhs2-output-1",
"sourceX": 356.49527351854465,
"sourceY": 498.5635199833134,
"target": "4vhllhn",
"targetHandle": "4vhllhn-input-1",
"targetX": 418.4052103369596,
"targetY": 497.790754078487,
"type": "custom",
"updatable": true
}, {
"data": {},
"events": {},
"id": "vueflow__edge-4vhllhn4vhllhn-output-1-hyl42jnhyl42jn-input-1",
"markerEnd": "arrowclosed",
"selectable": true,
"source": "4vhllhn",
"sourceHandle": "4vhllhn-output-1",
"sourceX": 650.4050735902136,
"sourceY": 497.790754078487,
"target": "hyl42jn",
"targetHandle": "hyl42jn-input-1",
"targetX": 684.1058152418105,
"targetY": 497.72593517906694,
"type": "custom",
"updatable": true
}, {
"data": {},
"events": {},
"id": "vueflow__edge-hyl42jnhyl42jn-output-1-30hs0cr30hs0cr-input-1",
"markerEnd": "arrowclosed",
"selectable": true,
"source": "hyl42jn",
"sourceHandle": "hyl42jn-output-1",
"sourceX": 916.1055607463649,
"sourceY": 497.72593517906694,
"target": "30hs0cr",
"targetHandle": "30hs0cr-input-1",
"targetX": 955.6967202123523,
"targetY": 497.96919733911557,
"type": "custom",
"updatable": true
}, {
"data": {},
"events": {},
"id": "vueflow__edge-30hs0cr30hs0cr-output-1-5f7q3yd5f7q3yd-input-1",
"markerEnd": "arrowclosed",
"selectable": true,
"source": "30hs0cr",
"sourceHandle": "30hs0cr-output-1",
"sourceX": 1187.6964657169067,
"sourceY": 497.96919733911557,
"target": "5f7q3yd",
"targetHandle": "5f7q3yd-input-1",
"targetX": 122.5107710200831,
"targetY": 653.2831872769548,
"type": "custom",
"updatable": true
}, {
"data": {},
"events": {},
"id": "vueflow__edge-5f7q3yd5f7q3yd-output-1-fvvvn6jfvvvn6j-input-1",
"markerEnd": "arrowclosed",
"selectable": true,
"source": "5f7q3yd",
"sourceHandle": "5f7q3yd-output-1",
"sourceX": 354.51063427333713,
"sourceY": 653.2831872769548,
"target": "fvvvn6j",
"targetHandle": "fvvvn6j-input-1",
"targetX": 485.16302385295364,
"targetY": 655.4106725073152,
"type": "custom",
"updatable": true
}, {
"data": {},
"events": {},
"id": "vueflow__edge-fvvvn6jfvvvn6j-output-2-5f7q3yd5f7q3yd-input-1",
"markerEnd": "arrowclosed",
"selectable": true,
"source": "fvvvn6j",
"sourceHandle": "fvvvn6j-output-2",
"sourceX": 781.1628378665275,
"sourceY": 698.0043806528334,
"target": "5f7q3yd",
"targetHandle": "5f7q3yd-input-1",
"targetX": 122.5107710200831,
"targetY": 653.2831872769548,
"type": "custom",
"updatable": true
}, {
"class": "connected-edges",
"data": {},
"events": {},
"id": "vueflow__edge-fvvvn6jfvvvn6j-output-1-5dqfs9h5dqfs9h-input-1",
"markerEnd": "arrowclosed",
"selectable": true,
"source": "fvvvn6j",
"sourceHandle": "fvvvn6j-output-1",
"sourceX": 781.1628378665275,
"sourceY": 655.4106725073152,
"target": "5dqfs9h",
"targetHandle": "5dqfs9h-input-1",
"targetX": 929.2000941276498,
"targetY": 654.4788281137922,
"type": "custom",
"updatable": true
}],
"nodes": [{
"data": {
"activeInInput": false,
"contextMenuName": "",
"contextTypes": [],
"date": "",
"days": [],
"delay": 5,
"description": "",
"disableBlock": false,
"interval": 60,
"isUrlRegex": false,
"observeElement": {
"baseElOptions": {
"attributeFilter": [],
"attributes": false,
"characterData": false,
"childList": true,
"subtree": false
},
"baseSelector": "",
"matchPattern": "",
"selector": "",
"targetOptions": {
"attributeFilter": [],
"attributes": false,
"characterData": false,
"childList": true,
"subtree": false
}
},
"parameters": [],
"preferParamsInTab": false,
"shortcut": "",
"time": "00:00",
"type": "manual",
"url": ""
},
"events": {},
"id": "5w2JcfM4TBz5SSv5ZycW6",
"label": "trigger",
"position": {
"x": 77.62826671140942,
"y": 291.3848001342282
},
"type": "BlockBasic"
}, {
"data": {
"assignVariable": false,
"clearValue": true,
"dataColumn": "",
"delay": 0,
"description": "年龄",
"disableBlock": false,
"events": [],
"findBy": "cssSelector",
"getValue": false,
"markEl": false,
"multiple": false,
"optionPosition": "1",
"saveData": false,
"selectOptionBy": "value",
"selected": true,
"selector": "input#TextInputfield_2",
"type": "text-field",
"value": "{{$randint(5, 8)}}{{$randint(0, 9)}}",
"variableName": "",
"waitForSelector": false,
"waitSelectorTimeout": 5000
},
"events": {},
"id": "l96qhs2",
"label": "forms",
"position": {
"x": 144.4954979080028,
"y": 462.563556244261
},
"type": "BlockBasic"
}, {
"data": {
"active": true,
"customUserAgent": false,
"description": "",
"disableBlock": false,
"inGroup": false,
"tabZoom": 1,
"updatePrevTab": false,
"url": "https://jinshuju.net/f/cG6C5v",
"userAgent": "",
"waitTabLoaded": true
},
"events": {},
"id": "80xttn4",
"label": "new-tab",
"position": {
"x": 342.04379708955946,
"y": 290.4428013025486
},
"type": "BlockBasic"
}, {
"data": {
"assignVariable": false,
"clearValue": true,
"dataColumn": "",
"delay": 0,
"description": "姓名",
"disableBlock": false,
"events": [],
"findBy": "cssSelector",
"getValue": false,
"markEl": false,
"multiple": false,
"optionPosition": "1",
"saveData": false,
"selectOptionBy": "value",
"selected": true,
"selector": "input#TextInputfield_1",
"type": "text-field",
"value": "{{variables.name}}",
"variableName": "",
"waitForSelector": true,
"waitSelectorTimeout": 5000
},
"events": {},
"id": "fraiswk",
"label": "forms",
"position": {
"x": 899.3117014241493,
"y": 290.30334956156537
},
"type": "BlockBasic"
}, {
"data": {
"code": "// 预定义的汉字集\nconst surnames = [\"W\", \"L\", \"Z\", \"L\", \"C\"];\nconst names = [\"W\", \"F\", \"N\", \"Q\", \"L\", \"J\", \"Y\", \"J\", \"Z\"];\n\n// 从数组中随机选择一个元素的函数\nfunction randomChoice(array) {\nreturn array;\n}\n\n// 生成名字\nconst surname = randomChoice(surnames);\nconst namePart = randomChoice(names);\nconst fullName = surname + namePart;\n\n// 使用automaSetVariable函数将生成的名字存储在变量name中\nautomaSetVariable('name', fullName);\n",
"context": "website",
"description": "",
"disableBlock": false,
"everyNewTab": false,
"preloadScripts": [],
"runBeforeLoad": false,
"timeout": 20000
},
"events": {},
"id": "til2oe8",
"label": "javascript-code",
"position": {
"x": 618.1833091194868,
"y": 288.187862393913
},
"type": "BlockBasic"
}, {
"data": {
"description": "男女",
"disableBlock": false,
"findBy": "cssSelector",
"markEl": false,
"multiple": false,
"selector": ".field-input-render:nth-child(1) .choice-wrapper:nth-child({{$randint(1, 2)}}) .ant-radio-input:nth-child(1)",
"waitForSelector": false,
"waitSelectorTimeout": 5000
},
"events": {},
"id": "4vhllhn",
"label": "event-click",
"position": {
"x": 438.40518023097206,
"y": 461.7907903394346
},
"type": "BlockBasic"
}, {
"data": {
"description": "测试一",
"disableBlock": false,
"findBy": "cssSelector",
"markEl": false,
"multiple": false,
"selector": ".ant-col:nth-child(8) .choice-wrapper:nth-child({{$randint(1, 2)}}) .ant-radio-input:nth-child(1)",
"waitForSelector": false,
"waitSelectorTimeout": 5000
},
"events": {},
"id": "hyl42jn",
"label": "event-click",
"position": {
"x": 704.105785135823,
"y": 461.7259714400145
},
"type": "BlockBasic"
}, {
"data": {
"description": "测试二",
"disableBlock": false,
"findBy": "cssSelector",
"markEl": false,
"multiple": false,
"selector": ".ant-col:nth-child(10) .choice-wrapper:nth-child({{$randint(1, 2)}}) .ant-radio-input:nth-child(1)",
"waitForSelector": false,
"waitSelectorTimeout": 5000
},
"events": {},
"id": "30hs0cr",
"label": "event-click",
"position": {
"x": 975.6966901063647,
"y": 461.9692041628882
},
"type": "BlockBasic"
}, {
"data": {
"description": "多选测试",
"disableBlock": false,
"findBy": "cssSelector",
"markEl": false,
"multiple": false,
"selector": ".choice-wrapper:nth-child({{$randint(1, 5)}}) .ant-checkbox-input",
"waitForSelector": true,
"waitSelectorTimeout": 5000
},
"events": {},
"id": "5f7q3yd",
"label": "event-click",
"position": {
"x": 142.51074091409555,
"y": 617.2831941007274
},
"type": "BlockBasic"
}, {
"data": {
"disableBlock": false,
"repeatFor": "{{$randint(2, 5)}}"
},
"events": {},
"id": "fvvvn6j",
"label": "repeat-task",
"position": {
"x": 505.1629937469661,
"y": 584.8247658819663
},
"type": "BlockRepeatTask"
}, {
"data": {
"description": "提交",
"disableBlock": true,
"findBy": "cssSelector",
"markEl": false,
"multiple": false,
"selector": "button.ant-btn-two-chinese-chars",
"waitForSelector": false,
"waitSelectorTimeout": 5000
},
"events": {},
"id": "5dqfs9h",
"label": "event-click",
"position": {
"x": 949.2000640216622,
"y": 618.4788349375649
},
"type": "BlockBasic"
}],
"position": ,
"viewport": {
"x": 12.42295660049507,
"y": -81.8840976771013,
"zoom": 0.7290046894082918
},
"zoom": 0.7290046894082918
},
"settings": {
"blockDelay": 0,
"debugMode": false,
"defaultColumnName": "column",
"execContext": "popup",
"executedBlockOnWeb": false,
"inputAutocomplete": true,
"insertDefaultColumn": false,
"notification": true,
"onError": "stop-workflow",
"publicId": "",
"restartTimes": 3,
"reuseLastState": false,
"saveLog": true
},
"globalData": "{\n\t\"key\": \"value\"\n}",
"description": "",
"includedWorkflows": {}
}
页:
[1]