1、适配同级元素的查找

2、修改界面
3、增加打包工具
This commit is contained in:
jenkins 2025-04-29 23:34:47 +08:00
parent 35ece0e317
commit 2a12bc5779
10 changed files with 4362 additions and 12 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
/node
/node_modules
/src/.amo-upload-uuid
/src/web-ext-artifacts

View File

@ -1,3 +1,6 @@
# rutoxpath # rutoxpath
基于rutoxpath的二次开发 基于rutoxpath6.0.1 版本的二次开发:
1. 增加了robotid元素的获取
2. 修改了图标等信息
3. 尊重开源原则,此插件仅在个人学习使用,永不会在商店中上架

4
node_env.bat Normal file
View File

@ -0,0 +1,4 @@
set PROJECT_HOME=%~dp0
set PATH=%PROJECT_HOME%\node;%PROJECT_HOME%\node_modules\.bin;%PROJECT_HOME%\node\yarn\dist\bin;%PATH%

4248
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

5
package.json Normal file
View File

@ -0,0 +1,5 @@
{
"dependencies": {
"web-ext": "^8.6.0"
}
}

71
pom.xml Normal file
View File

@ -0,0 +1,71 @@
<project xmlns = "http://maven.apache.org/POM/4.0.0"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation = "http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<!-- 模型版本 -->
<modelVersion>4.0.0</modelVersion>
<groupId>com.zmr.test</groupId>
<!-- 项目的唯一ID一个groupId下面可能多个项目就是靠artifactId来区分的 -->
<artifactId>test-war</artifactId>
<!-- 版本号 -->
<version>1.0</version>
<!-- <packagin>war</packagin> -->
<name>test-war</name>
<repositories>
<repository>
<id>alimaven</id>
<url>https://maven.aliyun.com/repository/public</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>alimaven</id>
<url>https://maven.aliyun.com/repository/public</url>
</pluginRepository>
</pluginRepositories>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<node.version>v22.15.0</node.version>
<frontend-maven-plugin.version>1.10.0</frontend-maven-plugin.version>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
</properties>
<build>
<finalName>test</finalName>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>${frontend-maven-plugin.version}</version>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<nodeVersion>${node.version}</nodeVersion>
<!-- <npmVersion>6.4.1</npmVersion> -->
<nodeDownloadRoot>https://npmmirror.com/mirrors/node/</nodeDownloadRoot>
<npmDownloadRoot>https://npmmirror.com/mirrors/npm/</npmDownloadRoot>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>install --registry=https://registry.npmmirror.com </arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -639,7 +639,7 @@ function getParent(element, tagName) {
} }
if (parentRobotIdXPath != null && parentRobotIdXPath != undefined) { if (parentRobotIdXPath != null && parentRobotIdXPath != undefined) {
getParentXp(parentRobotIdXPath, tagName, 'robotid', element); getParentXp(parentRobotIdXPath, tagName, 'robotid', element);
xpathArray.push([1, 'Parent based RobotId is unique:', parentRobotId]) xpathArray.push([2, 'Parent based RobotId is unique:', parentRobotId])
} }
if (parentClass != null && parentClass != undefined) { if (parentClass != null && parentClass != undefined) {
getParentXp(parentClass, tagName, 'class', element); getParentXp(parentClass, tagName, 'class', element);
@ -834,6 +834,12 @@ function addPreviousSibling(preSib, tagName) {
} }
} }
break; break;
case 'robotid':
if (preSib.hasAttribute('robotid')) {
tempvalue = item.value
xpathArray.push([2, 'Following sibling based RobotId:', tempvalue])
}
break;
case 'class': case 'class':
if (preSib.hasAttribute('class')) { if (preSib.hasAttribute('class')) {
tempvalue = preSib.className; tempvalue = preSib.className;

View File

@ -3,9 +3,9 @@
"short_name": "RXPath", "short_name": "RXPath",
"author": "halliday2023", "author": "halliday2023",
"manifest_version": 2, "manifest_version": 2,
"version": "1.0.0", "version": "1.0.1",
"content_security_policy": "script-src 'self'; object-src 'self'", "content_security_policy": "script-src 'self'; object-src 'self'",
"description": "Rūto-Powered XPath Browser Add-on Learning Use Only, Not for Distribution", "description": "基于Rūto-XPath Finder 6.0.1版本的二次开发,仅个人学习使用。",
"homepage_url": "https://gitea.kiki.kim/HA/rutoxpath", "homepage_url": "https://gitea.kiki.kim/HA/rutoxpath",
"commands": { "commands": {
"_execute_browser_action": { "_execute_browser_action": {

View File

@ -17,14 +17,14 @@
</head> </head>
<body id="body"> <body id="body">
<!-- <div class="review"> <div class="review">
<p>Ruto wishes you a happy and prosperous new year</p> <p>开启后点击页面元素即可获取Xpath信息</p>
</div> --> </div>
<div id="version" class="flex-containers"> <div id="version" class="flex-containers">
<div <div
class="onoffswitch" class="onoffswitch"
data-balloon-length="large" 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" data-balloon-pos="right"
> >
<input <input
@ -113,6 +113,7 @@
<div class="record" id="startRecord"> <div class="record" id="startRecord">
<div> <div>
<p>Record sequence of test script</p> <p>Record sequence of test script</p>
<p style="font-size:0.6em; color:#888; margin-top:0.8em">基于Rūto-XPath Finder 6.0.1版本的二次开发</p>
</div> </div>
<div class="onoffswitch"> <div class="onoffswitch">
<input <input

View File

@ -384,7 +384,7 @@ function show_notifications(text) {
var notify = { var notify = {
type: 'basic', type: 'basic',
iconUrl: 'logo/128.png', iconUrl: 'logo/128.png',
title: 'Ruto', title: 'RXPath',
message: `${text}` message: `${text}`
} }
browser.notifications.create('notify', notify) browser.notifications.create('notify', notify)
@ -581,8 +581,16 @@ function copy(e) {
inp.select(); inp.select();
try { try {
// copy text // copy text
document.execCommand('copy'); // document.execCommand('copy');
inp.blur(); // 异步方法(推荐)
navigator.clipboard.writeText(inp.value)
.then(() => {
console.log('复制成功!');
inp.blur();
})
.catch(err => {
console.error('复制失败:', err);
});
// copied animation // copied animation
if (t.tagName == 'IMG') { if (t.tagName == 'IMG') {
t.parentElement.classList.add('copied'); t.parentElement.classList.add('copied');
@ -662,7 +670,7 @@ function downloadFiles(values) {
downloadFile = downloadFile + xpathPOM[index] + '\n' downloadFile = downloadFile + xpathPOM[index] + '\n'
} }
let lines = '------------------------------------'; let lines = '------------------------------------';
downloadFile += `\n${lines}\n|Generated by Ruto-XPath Finder|\n${lines}\nPage Title: ${values.title}\nPage URL: ${values.URL}` downloadFile += `\n${lines}\n|Generated by RXPath Finder|\n${lines}\nPage Title: ${values.title}\nPage URL: ${values.URL}`
// let t = saveTextInFile(downloadFile); // let t = saveTextInFile(downloadFile);
filename = `RutoCode(${Date.now().toString()}).txt`; filename = `RutoCode(${Date.now().toString()}).txt`;