适配chrome
|
@ -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'
|
||||
});
|
||||
|
|
|
@ -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;
|
||||
|
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 235 B After Width: | Height: | Size: 250 B |
Before Width: | Height: | Size: 404 B After Width: | Height: | Size: 851 B |
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 85 KiB |
|
@ -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",
|
||||
|
|
|
@ -14,8 +14,9 @@
|
|||
|
||||
<body id="body">
|
||||
<div id="version" class="flex-containers">
|
||||
<p>开启后点击页面元素即可获取Xpath信息</p>
|
||||
<div class="onoffswitch" data-balloon-length="large"
|
||||
data-balloon="Use only when right click in not available in pages. Get XPath in a single click. Note: Default click action will be disabled in pages, turn off to use regular click action."
|
||||
data-balloon="开启后点击对象即可获取Xpath,同时原页面的点击动作失效。"
|
||||
data-balloon-pos="right">
|
||||
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch" />
|
||||
<label class="onoffswitch-label" for="myonoffswitch">
|
||||
|
@ -27,10 +28,10 @@
|
|||
<img src="./logo/icon/controls.svg" alt="Setting" />
|
||||
</div>
|
||||
<div class="likediv" data-balloon-length="small" data-balloon="leave a review" data-balloon-pos="left">
|
||||
<a href="https://chrome.google.com/webstore/detail/ruto-xpath-finder/ilcoelkkcokgeeijnopjnolmmighnppp/reviews"
|
||||
<!-- <a href="https://chrome.google.com/webstore/detail/ruto-xpath-finder/ilcoelkkcokgeeijnopjnolmmighnppp/reviews"
|
||||
target="_blank">
|
||||
<img src="./logo/icon/love.svg" alt="review" />
|
||||
</a>
|
||||
</a> -->
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
|
@ -76,11 +77,14 @@
|
|||
<hr />
|
||||
<div class="logos">
|
||||
<div class="flex" data-balloon="Home" data-balloon-pos="right">
|
||||
<a href="https://sites.google.com/testleaf.com/ruto/" target="_blank">
|
||||
<img src="logo/ruto.webp" alt="Ruto" style="width: 80px;" class="rutohome" />
|
||||
<a href="https://gitea.kiki.kim/HA/rutoxpath" target="_blank">
|
||||
<img src="logo/ruto.webp" alt="Ruto" style="width: 90px;height: 50px;" class="rutohome" />
|
||||
</a>
|
||||
</div>
|
||||
<div class="record" id="startRecord">
|
||||
<div>
|
||||
<p style="font-size:0.6em; color:#888; margin-top:0.8em">Powered by Rūto-XPath Finder 7.0.1</p>
|
||||
</div>
|
||||
<div class="onoffswitch">
|
||||
<input type="checkbox" name="onoffswitchRecord" class="onoffswitch-checkbox" id="recordIcon" />
|
||||
<label class="onoffswitch-label" for="recordIcon">
|
||||
|
@ -90,8 +94,8 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="flex">
|
||||
<a href="https://testleaf.com" target="_blank">
|
||||
<img src="logo/tl.webp" alt="logo" style="width: 80px;" />
|
||||
<a href="https://kiki.kim/" target="_blank">
|
||||
<img src="logo/tl.webp" alt="logo" style="width: 80px;height: 50px;" />
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -837,7 +837,8 @@ function addPreviousSibling(preSib, tagName) {
|
|||
case 'robotid':
|
||||
if (preSib.hasAttribute('robotid')) {
|
||||
tempvalue = item.value
|
||||
xpathArray.push([2, 'Following sibling based RobotId:', tempvalue])
|
||||
// 这个获取的是前一个兄弟节点的元素
|
||||
// xpathArray.push([2, 'Following sibling based RobotId:', tempvalue])
|
||||
}
|
||||
break;
|
||||
case 'class':
|
||||
|
|