diff --git a/src/chrome/background.js b/src/chrome/background.js index e2d60b4..28327bd 100644 --- a/src/chrome/background.js +++ b/src/chrome/background.js @@ -1,10 +1,10 @@ /********************************************************************** - @see https://www.testleaf.com + @see https://gitea.kiki.kim/HA/rutoxpath @since - 2019 ***********************************************************************/ -let installURL = "https://sites.google.com/testleaf.com/ruto/"; -let updateURL = "https://sites.google.com/testleaf.com/ruto/videos" -let uninstallURL = "https://sites.google.com/testleaf.com/ruto/download/uninstall"; +let installURL = "https://gitea.kiki.kim/HA/rutoxpath"; +let updateURL = "https://gitea.kiki.kim/HA/rutoxpath" +let uninstallURL = "https://gitea.kiki.kim/HA/rutoxpath"; const manifest = chrome.runtime.getManifest(); //TODO: Enable it before release @@ -23,7 +23,7 @@ const installedListener = (details) => { function onClickNoti() { chrome.tabs.create({ url: updateURL }) } const updateNotification = () => { chrome.notifications.create({ - title: `Ruto`, + title: `RXPath`, message: `Click here to see the changelog of version ${manifest.version}`, type: 'basic', iconUrl: 'logo/128.png' @@ -31,8 +31,8 @@ const updateNotification = () => { } const installNotification = () => { chrome.notifications.create('onInstalled', { - title: `Ruto`, - message: `Please restart your browser to use Ruto`, + title: `RXPath`, + message: `Please restart your browser to use RXPath`, type: 'basic', iconUrl: 'logo/128.png' }); diff --git a/src/chrome/content/content.js b/src/chrome/content/content.js index 24e315b..9f25e8a 100644 --- a/src/chrome/content/content.js +++ b/src/chrome/content/content.js @@ -1,6 +1,6 @@ // version 3.1.0 id = ilcoelkkcokgeeijnopjnolmmighnppp /*** - * @see https://www.testleaf.com + * @see https://gitea.kiki.kim/HA/rutoxpath * @since - 2019 - Feb */ "use strict"; @@ -402,12 +402,17 @@ rutoX.buildXpath = (element, boolAnchor) => { hasFrame = frameElement != null ? frameElement : null; let attributeElement = element.attributes; let preiousSiblingElement = element.previousElementSibling; + let childrenElement = element.childNodes; try { xpathAttributes(attributeElement, tagName, element); } catch (e) { } try { - xpathFollowingSibling(preiousSiblingElement, tagName); + xpathFollowingSibling(preiousSiblingElement, tagName); //获取前一个兄弟节点的元素,然后定位当前的位置 + } catch (e) { } + + try { + xpathChildren(childrenElement, tagName); //获取子节点 } catch (e) { } try { @@ -1067,6 +1072,11 @@ function xpathFollowingSibling(preiousSiblingElement, tagName) { addPreviousSibling(preiousSiblingElement, tagName); } } +function xpathChildren(childrenElement, tagName) { + if (childrenElement != null || childrenElement != undefined) { + addChildren(childrenElement, tagName); + } +} function removeTunaXpath(element) { element.removeAttribute('rutoxpath', 'ruto'); } @@ -1178,6 +1188,35 @@ function getLabel(node, tagName) { } } } + +function addChildren(preSib, tagName) { + try { + Object.values(preSib).forEach(value => { + console.log(value); + if (!(filterAttributesFromElement(item))) { + let tempvalue = null; + switch (item.name) { + case 'id': + if (preSib.hasAttribute('id')) { + let id = preSib.id; + let re = new RegExp('\\d{' + maxId + ',}', '\g'); + let matches = re.test(id); + if ((id != null) && (id.length > 0) && matches == false) { + tempvalue = id; + } + } + xpathArray.push([2, 'Children based XPath', tempvalue]); + break; + case 'robotid': + tempvalue = item.value + xpathArray.push([2, 'Children based XPath', tempvalue]); + break; + } + } + }); + } + catch (error) { } +} function addPreviousSibling(preSib, tagName) { try { let classHasSpace = false; @@ -1197,6 +1236,9 @@ function addPreviousSibling(preSib, tagName) { } } break; + case 'robotid': + tempvalue = item.value + break; case 'class': if (preSib.hasAttribute('class')) { tempvalue = preSib.className; diff --git a/src/chrome/logo/128.png b/src/chrome/logo/128.png index 122af9a..28942e8 100644 Binary files a/src/chrome/logo/128.png and b/src/chrome/logo/128.png differ diff --git a/src/chrome/logo/16.png b/src/chrome/logo/16.png index 22a408b..ca64b83 100644 Binary files a/src/chrome/logo/16.png and b/src/chrome/logo/16.png differ diff --git a/src/chrome/logo/48.png b/src/chrome/logo/48.png index 8341afb..1d2f152 100644 Binary files a/src/chrome/logo/48.png and b/src/chrome/logo/48.png differ diff --git a/src/chrome/logo/ruto.webp b/src/chrome/logo/ruto.webp index f9afa09..47f85fd 100644 Binary files a/src/chrome/logo/ruto.webp and b/src/chrome/logo/ruto.webp differ diff --git a/src/chrome/logo/tl.webp b/src/chrome/logo/tl.webp index 8338054..1dc19ca 100644 Binary files a/src/chrome/logo/tl.webp and b/src/chrome/logo/tl.webp differ diff --git a/src/chrome/manifest.json b/src/chrome/manifest.json index ac4cd35..760f149 100644 --- a/src/chrome/manifest.json +++ b/src/chrome/manifest.json @@ -1,13 +1,13 @@ { -"update_url": "https://clients2.google.com/service/update2/crx", +"update_url": "https://gitea.kiki.kim/HA/rutoxpath/release", - "name": "Ruto - XPath Finder", - "short_name": "Ruto", + "name": "RXPath Finder", + "short_name": "RXPath", "manifest_version": 2, - "version": "7.0.1", + "version": "1.0.1", "content_security_policy": "script-src 'self'; object-src 'self'", - "description": "Ruto brings the best XPath to you. We are striving hard to improve better performance and more new features", - "homepage_url": "https://sites.google.com/testleaf.com/ruto/", + "description": "基于Rūto-XPath Finder 7.0.1版本的二次开发,仅个人学习使用。", + "homepage_url": "https://gitea.kiki.kim/HA/rutoxpath", "commands": { "_execute_browser_action": { "suggested_key": { @@ -59,7 +59,7 @@ "128": "logo/128.png" }, "browser_action": { - "default_title": "Ruto offered by TestLeaf", + "default_title": "RXPath", "default_popup": "popup.html" }, "options_page": "option.html", diff --git a/src/chrome/popup.html b/src/chrome/popup.html index 7a26d13..e6b336d 100644 --- a/src/chrome/popup.html +++ b/src/chrome/popup.html @@ -14,8 +14,9 @@