Jarvis-Brain 0.1.13.7__tar.gz → 0.1.13.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {jarvis_brain-0.1.13.7 → jarvis_brain-0.1.13.8}/PKG-INFO +1 -1
- {jarvis_brain-0.1.13.7 → jarvis_brain-0.1.13.8}/pyproject.toml +1 -1
- {jarvis_brain-0.1.13.7 → jarvis_brain-0.1.13.8}/tools/tools.py +19 -17
- {jarvis_brain-0.1.13.7 → jarvis_brain-0.1.13.8}/.gitignore +0 -0
- {jarvis_brain-0.1.13.7 → jarvis_brain-0.1.13.8}/README.md +0 -0
- {jarvis_brain-0.1.13.7 → jarvis_brain-0.1.13.8}/mcp_tools/__init__.py +0 -0
- {jarvis_brain-0.1.13.7 → jarvis_brain-0.1.13.8}/mcp_tools/dp_tools.py +0 -0
- {jarvis_brain-0.1.13.7 → jarvis_brain-0.1.13.8}/mcp_tools/main.py +0 -0
- {jarvis_brain-0.1.13.7 → jarvis_brain-0.1.13.8}/tools/__init__.py +0 -0
- {jarvis_brain-0.1.13.7 → jarvis_brain-0.1.13.8}/tools/browser_manager.py +0 -0
- {jarvis_brain-0.1.13.7 → jarvis_brain-0.1.13.8}/tools/browser_proxy.py +0 -0
- {jarvis_brain-0.1.13.7 → jarvis_brain-0.1.13.8}/uv.lock +0 -0
|
@@ -105,6 +105,9 @@ return getSimplifiedDOM(document.body);
|
|
|
105
105
|
# 我自己优化后的版本,逻辑为:删除不可见元素、标签的任何属性value的长度大于20时直接删除这个属性、id和class采用简写方式:id=>#,class=>.
|
|
106
106
|
compress_html_js="""
|
|
107
107
|
function getSimplifiedDOM(node) {
|
|
108
|
+
// 全局配置:最大属性值长度
|
|
109
|
+
const MAX_ATTR_LEN = 40;
|
|
110
|
+
|
|
108
111
|
// 1. 处理文本节点
|
|
109
112
|
if (node.nodeType === Node.TEXT_NODE) {
|
|
110
113
|
const text = node.textContent.trim();
|
|
@@ -112,7 +115,6 @@ function getSimplifiedDOM(node) {
|
|
|
112
115
|
}
|
|
113
116
|
|
|
114
117
|
// 2. 过滤无用标签
|
|
115
|
-
// 注意:保留了 SVG 标签以便进入内部处理 path
|
|
116
118
|
const ignoreTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'IFRAME', 'LINK', 'META', 'AUDIO', 'VIDEO', 'CANVAS'];
|
|
117
119
|
if (ignoreTags.includes(node.tagName)) return null;
|
|
118
120
|
if (node.nodeType !== Node.ELEMENT_NODE) return null;
|
|
@@ -128,20 +130,18 @@ function getSimplifiedDOM(node) {
|
|
|
128
130
|
const tagName = node.tagName.toLowerCase();
|
|
129
131
|
let tagStr = tagName;
|
|
130
132
|
|
|
131
|
-
// 获取 ID 和 Class,用于简写逻辑
|
|
132
133
|
const id = node.id;
|
|
133
|
-
// SVG 元素的 className 是对象,需用 getAttribute 安全获取
|
|
134
134
|
const className = node.getAttribute('class');
|
|
135
135
|
|
|
136
136
|
// A. 处理 ID 简写 (#id)
|
|
137
|
-
//
|
|
138
|
-
if (id && id.length <=
|
|
137
|
+
// 限制提高到 40
|
|
138
|
+
if (id && id.length <= MAX_ATTR_LEN) {
|
|
139
139
|
tagStr += `#${id}`;
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
// B. 处理 Class 简写 (.class)
|
|
143
|
-
//
|
|
144
|
-
if (className && typeof className === 'string' && className.length <=
|
|
143
|
+
// 限制提高到 40
|
|
144
|
+
if (className && typeof className === 'string' && className.length <= MAX_ATTR_LEN) {
|
|
145
145
|
const classes = className.trim().split(/\s+/);
|
|
146
146
|
if (classes.length > 0) {
|
|
147
147
|
tagStr += `.${classes.join('.')}`;
|
|
@@ -150,28 +150,30 @@ function getSimplifiedDOM(node) {
|
|
|
150
150
|
|
|
151
151
|
let propsStr = '';
|
|
152
152
|
|
|
153
|
-
// C.
|
|
153
|
+
// C. 处理属性
|
|
154
154
|
if (node.hasAttributes()) {
|
|
155
155
|
for (const attr of node.attributes) {
|
|
156
156
|
const name = attr.name;
|
|
157
157
|
const value = attr.value;
|
|
158
158
|
|
|
159
|
-
// 1. 跳过 ID 和 Class
|
|
160
|
-
// 注意:即使因为过长在上面没显示,这里也不应该重复显示,遵循“过长即删除”原则
|
|
159
|
+
// 1. 跳过 ID 和 Class (已在 tagStr 处理,或因过长被丢弃)
|
|
161
160
|
if (name === 'id' || name === 'class') continue;
|
|
162
161
|
|
|
163
|
-
// 2.
|
|
162
|
+
// 2. 黑名单:直接删除 style 和 aria-label
|
|
164
163
|
if (name === 'style' || name === 'aria-label') continue;
|
|
165
164
|
|
|
166
|
-
// 3.
|
|
167
|
-
// (continue 意味着直接跳过该属性的拼接,即 key 和 value 都不显示)
|
|
165
|
+
// 3. 特殊标签:path 标签删除所有属性
|
|
168
166
|
if (tagName === 'path') continue;
|
|
169
167
|
|
|
170
|
-
// 4.
|
|
171
|
-
//
|
|
172
|
-
|
|
168
|
+
// 4. 【长度与白名单逻辑】
|
|
169
|
+
// 如果不是 src 且不是 href,同时长度又超过了 40,则删除
|
|
170
|
+
const isLinkAttr = (name === 'src' || name === 'href');
|
|
171
|
+
|
|
172
|
+
if (!isLinkAttr && value.length > MAX_ATTR_LEN) {
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
173
175
|
|
|
174
|
-
// 5.
|
|
176
|
+
// 5. 拼接保留的属性
|
|
175
177
|
propsStr += ` ${name}="${value.replace(/"/g, '"')}"`;
|
|
176
178
|
}
|
|
177
179
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|