This commit is contained in:
naibo 2023-07-23 19:17:33 +08:00
parent c9eb5b0932
commit 09ccb5d56f
5 changed files with 22 additions and 25 deletions

View File

@ -636,7 +636,7 @@ If the expression returns a value greater than 0 or evaluates to True, the opera
<input onkeydown="inputDelete(event)" id="serviceDescription" name="serviceDescription" class="form-control"></input> <input onkeydown="inputDelete(event)" id="serviceDescription" name="serviceDescription" class="form-control"></input>
<label>Export Data Format (Excel/CSV/TXT/Database):</label> <label>Export Data Format (Excel/CSV/TXT/Database):</label>
<select id="outputFormat" class="form-control"> <select id="outputFormat" class="form-control">
<option value = "xlsx">XLSX (EXCEL)</option> <option value = "xlsx">XLSX (EXCEL, note that a single Excel cell can accommodate up to 32767 characters)</option>
<option value = "csv">CSV</option> <option value = "csv">CSV</option>
<option value = "txt">TXT</option> <option value = "txt">TXT</option>
<option value = "mysql">MySQL Database</option> <option value = "mysql">MySQL Database</option>

View File

@ -637,7 +637,7 @@ print(emotlib.emoji()) # 使用其中的函数。
<input onkeydown="inputDelete(event)" id="serviceDescription" name="serviceDescription" class="form-control"></input> <input onkeydown="inputDelete(event)" id="serviceDescription" name="serviceDescription" class="form-control"></input>
<label>导出数据格式Excel/CSV/TXT/数据库,<a href="https://www.bilibili.com/video/BV1os4y1679S/" target="_blank">查看MySQL操作教程</a></label> <label>导出数据格式Excel/CSV/TXT/数据库,<a href="https://www.bilibili.com/video/BV1os4y1679S/" target="_blank">查看MySQL操作教程</a></label>
<select id="outputFormat" class="form-control"> <select id="outputFormat" class="form-control">
<option value = "xlsx">XLSXEXCEL</option> <option value = "xlsx">XLSXEXCEL文件注意Excel单个单元格最多可容纳32767字符</option>
<option value = "csv">CSV</option> <option value = "csv">CSV</option>
<option value = "txt">TXT</option> <option value = "txt">TXT</option>
<option value = "mysql">MySQL数据库</option> <option value = "mysql">MySQL数据库</option>

File diff suppressed because one or more lines are too long

View File

@ -12,7 +12,7 @@
"justMyCode": false, "justMyCode": false,
// "args": ["--id", "[7]", "--read_type", "remote", "--headless", "0"] // "args": ["--id", "[7]", "--read_type", "remote", "--headless", "0"]
// "args": ["--id", "[9]", "--read_type", "remote", "--headless", "0", "--saved_file_name", "YOUTUBE"] // "args": ["--id", "[9]", "--read_type", "remote", "--headless", "0", "--saved_file_name", "YOUTUBE"]
"args": ["--id", "[84]", "--headless", "0", "--user_data", "1", "--keyboard", "0"] "args": ["--id", "[98]", "--headless", "0", "--user_data", "1", "--keyboard", "0"]
} }
] ]
} }

View File

@ -240,7 +240,6 @@ export function handleElement() {
generateMultiParameters(); generateMultiParameters();
} else { } else {
generateParameters(0); generateParameters(0);
console.log("HandleElement generate parameters");
} }
} else if (global.nodeList.length == 1) { } else if (global.nodeList.length == 1) {
findRelated(); //寻找和元素相关的元素 findRelated(); //寻找和元素相关的元素
@ -311,11 +310,9 @@ function parameterName(value){
export function generateParameters(type, linktext = true, linkhref = true) { export function generateParameters(type, linktext = true, linkhref = true) {
clearParameters(false); clearParameters(false);
let n = 1; let n = 1;
console.log("generateParameters for " + global.nodeList.length + " nodes");
chrome.storage.local.get('parameterNum', function(items) { chrome.storage.local.get('parameterNum', function(items) {
let at = parseInt(new Date().getTime()); // let at = parseInt(new Date().getTime());
n = items.parameterNum; n = items.parameterNum;
console.log("Storage get parameterNum: ", items , n);
let ndPath = ""; let ndPath = "";
let ndAllXPaths = []; let ndAllXPaths = [];
for (let num = 0; num < global.nodeList.length; num++) { for (let num = 0; num < global.nodeList.length; num++) {
@ -467,8 +464,8 @@ export function generateParameters(type, linktext = true, linkhref = true) {
} }
} }
} }
let at2 = parseInt(new Date().getTime()); // let at2 = parseInt(new Date().getTime());
console.log("generateParameters:", at2, at, at2 - at); // console.log("generateParameters:", at2, at, at2 - at);
generateValTable(); generateValTable();
console.log(global.outputParameters); console.log(global.outputParameters);
}); });
@ -480,7 +477,7 @@ export function generateMultiParameters() {
clearParameters(false); clearParameters(false);
let n = 1; let n = 1;
chrome.storage.local.get({ parameterNum: 1 }, function(items) { chrome.storage.local.get({ parameterNum: 1 }, function(items) {
let at = parseInt(new Date().getTime()); // let at = parseInt(new Date().getTime());
n = items.parameterNum; n = items.parameterNum;
let nd, ndText, ndPath, pname, ndAllXPaths; let nd, ndText, ndPath, pname, ndAllXPaths;
for (let num = 0; num < global.nodeList.length; num++) { for (let num = 0; num < global.nodeList.length; num++) {
@ -559,8 +556,8 @@ export function generateMultiParameters() {
} }
} }
// console.log(global.outputParameters); // console.log(global.outputParameters);
let at2 = parseInt(new Date().getTime()); // let at2 = parseInt(new Date().getTime());
console.log("generateMultiParameters", at2, at, at2 - at); // console.log("generateMultiParameters", at2, at, at2 - at);
generateValTable(false); generateValTable(false);
}); });
@ -570,7 +567,7 @@ export function generateMultiParameters() {
export function handleDescendents(mode = 0) { export function handleDescendents(mode = 0) {
let n = 1; let n = 1;
chrome.storage.local.get({ parameterNum: 1 }, function(items) { chrome.storage.local.get({ parameterNum: 1 }, function(items) {
let at = parseInt(new Date().getTime()); // let at = parseInt(new Date().getTime());
n = items.parameterNum; n = items.parameterNum;
clearParameters(); //清除原来的参数列表 clearParameters(); //清除原来的参数列表
global.app._data.selectedDescendents = true; global.app._data.selectedDescendents = true;
@ -606,7 +603,7 @@ export function handleDescendents(mode = 0) {
} }
// 将共有元素集合转换为数组 // 将共有元素集合转换为数组
let commonXPathList = Array.from(commonXPaths); let commonXPathList = Array.from(commonXPaths);
console.log(commonXPathList); // console.log(commonXPathList);
let hash = {}; //记录index和数组位置的对应关系 let hash = {}; //记录index和数组位置的对应关系
for (let num = 0; num < global.nodeList.length; num++) { for (let num = 0; num < global.nodeList.length; num++) {
let tnode = global.nodeList[num]["node"]; let tnode = global.nodeList[num]["node"];
@ -645,7 +642,7 @@ export function handleDescendents(mode = 0) {
}); });
nd.style.boxShadow = global.boxShadowColor; nd.style.boxShadow = global.boxShadowColor;
} }
console.log("Hash", hash); // console.log("Hash", hash);
if (num == 0) { //从第二个节点开始只插入那些不在参数列表中的元素根据xpath进行寻址 if (num == 0) { //从第二个节点开始只插入那些不在参数列表中的元素根据xpath进行寻址
//如果当前节点除了子元素外仍然有其他文字或者该元素是图片/表单项,加入子元素节点 //如果当前节点除了子元素外仍然有其他文字或者该元素是图片/表单项,加入子元素节点
if (ndText != "" || nd.tagName == "IMG" || nd.tagName == "INPUT" || nd.tagName == "A") { if (ndText != "" || nd.tagName == "IMG" || nd.tagName == "INPUT" || nd.tagName == "A") {
@ -915,8 +912,8 @@ export function handleDescendents(mode = 0) {
} }
} }
} }
let at2 = parseInt(new Date().getTime()); // let at2 = parseInt(new Date().getTime());
console.log("选中子元素", at2, at, at2 - at); // console.log("选中子元素", at2, at, at2 - at);
generateValTable(); generateValTable();
}); });
@ -942,7 +939,7 @@ export function generateValTable(multiline = true) {
paraValues.push(tValues); paraValues.push(tValues);
} }
global.app._data.valTable = paraValues; global.app._data.valTable = paraValues;
console.log("生成参数表格", paraValues); // console.log("生成参数表格", paraValues);
} }
// 选中第一个节点,自动寻找同类节点 // 选中第一个节点,自动寻找同类节点
@ -951,7 +948,7 @@ export function generateValTable(multiline = true) {
// 如果没有,则恢复原状,然后试试倒数第二个:/div[1]/div[2]/div/a[1] // 如果没有,则恢复原状,然后试试倒数第二个:/div[1]/div[2]/div/a[1]
// 直到找到第一个变多的节点或者追溯到根节点为止 // 直到找到第一个变多的节点或者追溯到根节点为止
export function findRelated() { export function findRelated() {
let at = parseInt(new Date().getTime()); // let at = parseInt(new Date().getTime());
let testPath = global.nodeList[0]["xpath"].replace("//iframe","").split("/").splice(1); //分离xpath成 ["html","body","div[0]"]这样子 let testPath = global.nodeList[0]["xpath"].replace("//iframe","").split("/").splice(1); //分离xpath成 ["html","body","div[0]"]这样子
let nodeNameList = []; let nodeNameList = [];
let nodeIndexList = []; let nodeIndexList = [];
@ -982,8 +979,8 @@ export function findRelated() {
break; break;
} }
} }
let at2 = parseInt(new Date().getTime()); // let at2 = parseInt(new Date().getTime());
console.log("findRelated", at2, at, at2 - at); // console.log("findRelated", at2, at, at2 - at);
} }
@ -1016,7 +1013,6 @@ export function readyToList(step, dealparameters = true) {
clearReady(); clearReady();
if (dealparameters) { //防止出现先选中子元素再选中全部失效的问题 if (dealparameters) { //防止出现先选中子元素再选中全部失效的问题
generateParameters(0); //根据nodelist列表内的元素生成参数列表0代表纯文本 generateParameters(0); //根据nodelist列表内的元素生成参数列表0代表纯文本
console.log("Deal Parameters");
} }
} }
@ -1041,7 +1037,7 @@ export function combineXpath(nameList, indexList) {
// 最终转换为: // 最终转换为:
// /html/body/div[3]/div[1]/div[1]/div[1]/div[3]/div/div[3]/a // /html/body/div[3]/div[1]/div[1]/div[1]/div[3]/div/div[3]/a
export function relatedTest() { export function relatedTest() {
let at = new Date().getTime() // let at = new Date().getTime()
let testList = []; let testList = [];
let testpath = ""; let testpath = "";
for (let i = 0; i < global.nodeList.length; i++) { for (let i = 0; i < global.nodeList.length; i++) {
@ -1081,7 +1077,7 @@ export function relatedTest() {
console.log("finalPath:", finalPath, "element:", element); console.log("finalPath:", finalPath, "element:", element);
global.app.$data.nowPath = finalPath; //标记此元素xpath global.app.$data.nowPath = finalPath; //标记此元素xpath
pushToReadyList(finalPath); pushToReadyList(finalPath);
let at2 = parseInt(new Date().getTime()); // let at2 = parseInt(new Date().getTime());
console.log("手动:", at2, at, at2 - at); // console.log("手动:", at2, at, at2 - at);
return 50; //先返回给默认码 return 50; //先返回给默认码
} }