Skip to content

Commit 4e3f8ac

Browse files
authored
chore: sync extension files from sentience-chrome v2.6.0
1 parent 05e1d8e commit 4e3f8ac

File tree

4 files changed

+75
-37
lines changed

4 files changed

+75
-37
lines changed

sentience/extension/injected_api.js

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,21 @@
157157
}
158158
return null;
159159
}
160+
function normalizeNearbyText(text) {
161+
return text ? text.replace(/\s+/g, " ").trim() : "";
162+
}
163+
function isInteractableElement(el) {
164+
if (!el || !el.tagName) return !1;
165+
const tag = el.tagName.toLowerCase(), role = el.getAttribute ? el.getAttribute("role") : null, hasTabIndex = !!el.hasAttribute && el.hasAttribute("tabindex"), hasHref = "A" === el.tagName && !!el.hasAttribute && el.hasAttribute("href");
166+
if ([ "button", "input", "textarea", "select", "option", "details", "summary", "a" ].includes(tag)) return !("a" === tag && !hasHref);
167+
if (role && [ "button", "link", "tab", "menuitem", "checkbox", "radio", "switch", "slider", "combobox", "textbox", "searchbox", "spinbutton" ].includes(role.toLowerCase())) return !0;
168+
if (hasTabIndex) return !0;
169+
if (el.onclick || el.onkeydown || el.onkeypress || el.onkeyup) return !0;
170+
if (el.getAttribute) {
171+
if (el.getAttribute("onclick") || el.getAttribute("onkeydown") || el.getAttribute("onkeypress") || el.getAttribute("onkeyup")) return !0;
172+
}
173+
return !1;
174+
}
160175
function getText(el) {
161176
if (el.getAttribute("aria-label")) return el.getAttribute("aria-label");
162177
if ("INPUT" === el.tagName) {
@@ -391,11 +406,7 @@
391406
}), textVal = semanticText.text || getText(el), inferredRole = function(el, options = {}) {
392407
const {enableInference: enableInference = !0} = options;
393408
if (!enableInference) return null;
394-
if (!function(el) {
395-
if (!el || !el.tagName) return !1;
396-
const tag = el.tagName.toLowerCase(), role = el.getAttribute ? el.getAttribute("role") : null, hasTabIndex = !!el.hasAttribute && el.hasAttribute("tabindex"), hasHref = "A" === el.tagName && !!el.hasAttribute && el.hasAttribute("href");
397-
return [ "button", "input", "textarea", "select", "option", "details", "summary", "a" ].includes(tag) ? !("a" === tag && !hasHref) : !(!role || ![ "button", "link", "tab", "menuitem", "checkbox", "radio", "switch", "slider", "combobox", "textbox", "searchbox", "spinbutton" ].includes(role.toLowerCase())) || (!!hasTabIndex || (!!(el.onclick || el.onkeydown || el.onkeypress || el.onkeyup) || !(!el.getAttribute || !(el.getAttribute("onclick") || el.getAttribute("onkeydown") || el.getAttribute("onkeypress") || el.getAttribute("onkeyup")))));
398-
}(el)) return null;
409+
if (!isInteractableElement(el)) return null;
399410
const hasAriaLabel = el.getAttribute ? el.getAttribute("aria-label") : null, hasExplicitRole = el.getAttribute ? el.getAttribute("role") : null;
400411
if (hasAriaLabel || hasExplicitRole) return null;
401412
const tag = el.tagName.toLowerCase();
@@ -478,7 +489,33 @@
478489
}
479490
const title = el.getAttribute("title");
480491
return title && title.trim() ? title.trim().substring(0, 200) : "";
481-
}(el) || null);
492+
}(el) || null), nearbyText = isInteractableElement(el) ? function(el, options = {}) {
493+
if (!el) return null;
494+
const maxLen = "number" == typeof options.maxLen ? options.maxLen : 80, ownText = normalizeNearbyText(el.innerText || ""), candidates = [], collect = node => {
495+
if (!node) return;
496+
let text = "";
497+
try {
498+
text = normalizeNearbyText(node.innerText || node.textContent || "");
499+
} catch (e) {
500+
text = "";
501+
}
502+
text && text !== ownText && candidates.push(text);
503+
};
504+
if (collect(el.previousElementSibling), collect(el.nextElementSibling), 0 === candidates.length && el.parentElement) {
505+
let parentText = "";
506+
try {
507+
parentText = normalizeNearbyText(el.parentElement.innerText || "");
508+
} catch (e) {
509+
parentText = "";
510+
}
511+
parentText && parentText !== ownText && parentText.length <= 120 && candidates.push(parentText);
512+
}
513+
if (0 === candidates.length) return null;
514+
let text = candidates[0];
515+
return text.length > maxLen && (text = text.slice(0, maxLen).trim()), text || null;
516+
}(el, {
517+
maxLen: 80
518+
}) : null;
482519
rawData.push({
483520
id: idx,
484521
tag: tagName,
@@ -509,6 +546,7 @@
509546
inferred_label: semanticText?.source && ![ "explicit_aria_label", "input_value", "img_alt", "inner_text" ].includes(semanticText.source) ? toSafeString(semanticText.text) : null,
510547
label_source: semanticText?.source || null,
511548
inferred_role: inferredRole ? toSafeString(inferredRole) : null,
549+
nearby_text: toSafeString(nearbyText),
512550
href: toSafeString(el.href || el.getAttribute("href") || el.closest && el.closest("a")?.href || null),
513551
class: toSafeString(getClassName(el)),
514552
value: null !== safeValue ? toSafeString(safeValue) : null,

sentience/extension/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"manifest_version": 3,
33
"name": "Sentience Semantic Visual Grounding Extractor",
4-
"version": "2.4.1",
4+
"version": "2.6.0",
55
"description": "Extract semantic visual grounding data from web pages",
66
"permissions": ["activeTab", "scripting"],
77
"host_permissions": ["<all_urls>"],
3.35 KB
Binary file not shown.

sentience/extension/release.json

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/276945051",
3-
"assets_url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/276945051/assets",
4-
"upload_url": "https://uploads.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/276945051/assets{?name,label}",
5-
"html_url": "https://github.com/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/tag/v2.5.0",
6-
"id": 276945051,
2+
"url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/277691523",
3+
"assets_url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/277691523/assets",
4+
"upload_url": "https://uploads.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/277691523/assets{?name,label}",
5+
"html_url": "https://github.com/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/tag/v2.6.0",
6+
"id": 277691523,
77
"author": {
88
"login": "rcholic",
99
"id": 135060,
@@ -25,21 +25,21 @@
2525
"user_view_type": "public",
2626
"site_admin": false
2727
},
28-
"node_id": "RE_kwDOQshiJ84Qgdib",
29-
"tag_name": "v2.5.0",
28+
"node_id": "RE_kwDOQshiJ84QjTyD",
29+
"tag_name": "v2.6.0",
3030
"target_commitish": "main",
31-
"name": "Release v2.5.0",
31+
"name": "Release v2.6.0",
3232
"draft": false,
3333
"immutable": false,
3434
"prerelease": false,
35-
"created_at": "2026-01-15T05:36:52Z",
36-
"updated_at": "2026-01-15T05:37:59Z",
37-
"published_at": "2026-01-15T05:37:19Z",
35+
"created_at": "2026-01-18T08:03:53Z",
36+
"updated_at": "2026-01-18T08:05:04Z",
37+
"published_at": "2026-01-18T08:04:24Z",
3838
"assets": [
3939
{
40-
"url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/assets/340810705",
41-
"id": 340810705,
42-
"node_id": "RA_kwDOQshiJ84UUFvR",
40+
"url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/assets/342221644",
41+
"id": 342221644,
42+
"node_id": "RA_kwDOQshiJ84UZeNM",
4343
"name": "extension-files.tar.gz",
4444
"label": "",
4545
"uploader": {
@@ -65,17 +65,17 @@
6565
},
6666
"content_type": "application/gzip",
6767
"state": "uploaded",
68-
"size": 75548,
69-
"digest": "sha256:8cfe2dd1bc2b927b9fbbc7c670b72943cb3704f830bce147606c9dd8b24ccc20",
70-
"download_count": 6,
71-
"created_at": "2026-01-15T05:37:59Z",
72-
"updated_at": "2026-01-15T05:37:59Z",
73-
"browser_download_url": "https://github.com/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/download/v2.5.0/extension-files.tar.gz"
68+
"size": 77212,
69+
"digest": "sha256:82d79bfb011dbdf6ecd81b30689da13ee2045ac3df93534bee4b3c9ae3717670",
70+
"download_count": 0,
71+
"created_at": "2026-01-18T08:05:04Z",
72+
"updated_at": "2026-01-18T08:05:04Z",
73+
"browser_download_url": "https://github.com/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/download/v2.6.0/extension-files.tar.gz"
7474
},
7575
{
76-
"url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/assets/340810706",
77-
"id": 340810706,
78-
"node_id": "RA_kwDOQshiJ84UUFvS",
76+
"url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/assets/342221645",
77+
"id": 342221645,
78+
"node_id": "RA_kwDOQshiJ84UZeNN",
7979
"name": "extension-package.zip",
8080
"label": "",
8181
"uploader": {
@@ -101,15 +101,15 @@
101101
},
102102
"content_type": "application/zip",
103103
"state": "uploaded",
104-
"size": 77323,
105-
"digest": "sha256:6be50503ddda9f0457b05b4399159de5e456d3fa3c5a6f6f18d8d287d52b5546",
104+
"size": 79031,
105+
"digest": "sha256:1f8fe71aeedf7143064afafadc19d83577932d125b66de3eb70e1f302173d172",
106106
"download_count": 0,
107-
"created_at": "2026-01-15T05:37:59Z",
108-
"updated_at": "2026-01-15T05:37:59Z",
109-
"browser_download_url": "https://github.com/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/download/v2.5.0/extension-package.zip"
107+
"created_at": "2026-01-18T08:05:04Z",
108+
"updated_at": "2026-01-18T08:05:04Z",
109+
"browser_download_url": "https://github.com/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/download/v2.6.0/extension-package.zip"
110110
}
111111
],
112-
"tarball_url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/tarball/v2.5.0",
113-
"zipball_url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/zipball/v2.5.0",
112+
"tarball_url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/tarball/v2.6.0",
113+
"zipball_url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/zipball/v2.6.0",
114114
"body": ""
115115
}

0 commit comments

Comments
 (0)