diff --git a/.vscode/launch.json b/.vscode/launch.json index 0979faa..f390264 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -10,7 +10,7 @@ "request": "launch", "reAttach": true, "addonPath": "${workspaceFolder}//src", - "url": "file://${workspaceFolder}/deepseek_html_20250425_ef9a56.html", + "url": "file://${workspaceFolder}/deepseek_html_20250427_d3f472.html", "firefoxExecutable": "D:\\Program Files\\Mozilla Firefox\\firefox.exe" } // { diff --git a/src/content/content.js b/src/content/content.js index 77f5d73..3bd1508 100644 --- a/src/content/content.js +++ b/src/content/content.js @@ -606,6 +606,8 @@ function getParent(element, tagName) { var parentId = null; var parentClass = null; var parentName = null; + var parentRobotIdXPath = null; + var parentRobotId = null; var others = null; Array.prototype.slice.call(attributeElement).forEach(function (item) { if (!(filterAttributesFromElement(item))) { @@ -613,6 +615,10 @@ function getParent(element, tagName) { case "id": parentId = getParentId(parent, tag) break; + case "robotid": + parentRobotIdXPath = getParentRobotId(item, tag) + parentRobotId = item.value + break; case "class": parentClass = getParentClassName(parent, tag) break; @@ -631,6 +637,10 @@ function getParent(element, tagName) { if (parentId != null && parentId != undefined) { getParentXp(parentId, tagName, 'id', element); } + if (parentRobotIdXPath != null && parentRobotIdXPath != undefined) { + getParentXp(parentRobotIdXPath, tagName, 'robotid', element); + xpathArray.push([1, 'Parent based RobotId is unique:', parentRobotId]) + } if (parentClass != null && parentClass != undefined) { getParentXp(parentClass, tagName, 'class', element); } @@ -1205,6 +1215,17 @@ function getParentId(element, tagName) { } else return null; +} +function getParentRobotId(element, tagName) { + let clicketItemId = element.value; + let re = new RegExp('\\d{' + maxId + ',}', '\g'); + let matches = re.test(clicketItemId); + if ((clicketItemId != null) && (clicketItemId.length > 0) && matches == false) { + let temp = `//${tagName}[@robotid='${clicketItemId}']`; + return temp; + } + else return null; + } function getParentName(element, tagName) { let clickedItemName = element.name;