Skip to content

Commit f647090

Browse files
authored
Merge pull request #176 from SentienceAPI/sync-extension-v2.9.0
Sync Extension: v2.9.0
2 parents 39aec94 + 29d5d71 commit f647090

File tree

4 files changed

+155
-51
lines changed

4 files changed

+155
-51
lines changed

src/extension/injected_api.js

Lines changed: 106 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,103 @@
558558
}(options.waitForStability || {});
559559
const rawData = [];
560560
window.sentience_registry = [];
561-
getAllElements().forEach((el, idx) => {
561+
const nodes = getAllElements(), parseAriaInt = (el, attr) => {
562+
try {
563+
const raw = el.getAttribute ? el.getAttribute(attr) : null;
564+
if (!raw) return null;
565+
const n = parseInt(String(raw), 10);
566+
return Number.isFinite(n) ? n : null;
567+
} catch (e) {
568+
return null;
569+
}
570+
}, safeKeyPart = (s, maxLen = 48) => String(s || "").replace(/\s+/g, " ").trim().slice(0, maxLen) || null, buildContainerKey = container => {
571+
try {
572+
const tag = container.tagName ? container.tagName.toLowerCase() : "div", role = container.getAttribute ? container.getAttribute("role") : null, id = container.id ? `#${safeKeyPart(container.id, 32)}` : null, cls = (() => {
573+
if (!container.className) return null;
574+
const parts = String(container.className).split(/\s+/).filter(Boolean).slice(0, 2);
575+
return parts.length ? `.${safeKeyPart(parts.join("."), 48)}` : null;
576+
})(), ariaLabel = container.getAttribute && container.getAttribute("aria-label") ? `aria=${safeKeyPart(container.getAttribute("aria-label"), 40)}` : null, parts = [ safeKeyPart(tag, 16), role ? `role=${safeKeyPart(role, 24)}` : null, id, cls, ariaLabel ].filter(Boolean);
577+
return parts.length ? parts.join("|") : null;
578+
} catch (e) {
579+
return null;
580+
}
581+
}, computeContainerInfo = el => {
582+
try {
583+
if (!("A" === el.tagName && (el.getAttribute("href") || el.href) || "BUTTON" === el.tagName || el.getAttribute && ("link" === el.getAttribute("role") || "button" === el.getAttribute("role")) || isInteractableElement(el))) return null;
584+
const candidates = [];
585+
let node = el;
586+
for (let depth = 0; depth < 6 && node && node.parentElement; depth++) {
587+
const p = node.parentElement, tag = p.tagName ? p.tagName.toLowerCase() : "", role = p.getAttribute ? p.getAttribute("role") : null, isExplicit = "ul" === tag || "ol" === tag || "table" === tag || "tbody" === tag || "list" === role || "feed" === role || "grid" === role || "table" === role, childCount = p.children ? p.children.length : 0;
588+
(isExplicit || childCount >= 6) && candidates.push({
589+
p: p,
590+
depth: depth,
591+
tag: tag,
592+
role: role,
593+
childCount: childCount
594+
}), node = p;
595+
}
596+
if (!candidates.length) return null;
597+
const pickItemNodes = (container, tag, role) => {
598+
if ("ul" === tag || "ol" === tag || "list" === role) {
599+
const lis = Array.from(container.children || []).filter(c => c && "LI" === c.tagName), filtered = lis.filter(li => {
600+
if (!li || !li.querySelector) return !1;
601+
const a = li.querySelector("a[href]");
602+
if (!a) return !1;
603+
return (a.textContent || "").replace(/\s+/g, " ").trim().length >= 8;
604+
});
605+
return filtered.length ? filtered : lis;
606+
}
607+
if ("table" === tag || "tbody" === tag || "table" === role || "grid" === role) {
608+
const rows = Array.from(container.children || []).filter(c => c && "TR" === c.tagName), allRows = rows.length ? rows : Array.from(container.querySelectorAll("tr")), filtered = allRows.filter(tr => {
609+
if (!tr || !tr.querySelector) return !1;
610+
const links = Array.from(tr.querySelectorAll("a[href]"));
611+
let bestLen = 0;
612+
for (const a of links) {
613+
const t = (a.textContent || "").replace(/\s+/g, " ").trim();
614+
t.length > bestLen && (bestLen = t.length);
615+
}
616+
return bestLen >= 12;
617+
});
618+
return filtered.length ? filtered : allRows;
619+
}
620+
const kids = Array.from(container.children || []), items = kids.filter(c => {
621+
if (!c || !c.querySelector) return !1;
622+
if (!c.querySelector('a[href],button,[role="link"],[role="button"]')) return !1;
623+
return (c.textContent || "").replace(/\s+/g, " ").trim().length >= 8;
624+
});
625+
return items.length ? items : kids;
626+
};
627+
let best = null;
628+
for (const c of candidates) {
629+
const items = pickItemNodes(c.p, c.tag, c.role), size = items.length || 0;
630+
if (size < 4) continue;
631+
let itemIndex = null;
632+
for (let i = 0; i < items.length; i++) {
633+
const it = items[i];
634+
if (it && (it === el || it.contains(el))) {
635+
itemIndex = i;
636+
break;
637+
}
638+
}
639+
if (null === itemIndex) continue;
640+
const score = size + ("ul" === c.tag || "ol" === c.tag || "table" === c.tag || c.role ? 2 : 0) - .4 * c.depth;
641+
(!best || score > best.score) && (best = {
642+
key: buildContainerKey(c.p),
643+
index: itemIndex,
644+
size: size,
645+
score: score
646+
});
647+
}
648+
return best && best.key ? {
649+
container_key: best.key,
650+
index_in_container: best.index,
651+
container_item_count: best.size
652+
} : null;
653+
} catch (e) {
654+
return null;
655+
}
656+
};
657+
nodes.forEach((el, idx) => {
562658
if (!el.getBoundingClientRect) return;
563659
const rect = el.getBoundingClientRect();
564660
if (rect.width < 5 || rect.height < 5) return;
@@ -722,7 +818,7 @@
722818
return text.length > maxLen && (text = text.slice(0, maxLen).trim()), text || null;
723819
}(el, {
724820
maxLen: 80
725-
}) : null;
821+
}) : null, containerInfo = computeContainerInfo(el);
726822
rawData.push({
727823
id: idx,
728824
tag: tagName,
@@ -762,8 +858,15 @@
762858
disabled: void 0 !== el.disabled ? String(el.disabled) : null,
763859
aria_checked: toSafeString(el.getAttribute("aria-checked")),
764860
aria_disabled: toSafeString(el.getAttribute("aria-disabled")),
765-
aria_expanded: toSafeString(el.getAttribute("aria-expanded"))
861+
aria_expanded: toSafeString(el.getAttribute("aria-expanded")),
862+
aria_posinset: parseAriaInt(el, "aria-posinset"),
863+
aria_setsize: parseAriaInt(el, "aria-setsize"),
864+
aria_rowindex: parseAriaInt(el, "aria-rowindex"),
865+
aria_colindex: parseAriaInt(el, "aria-colindex")
766866
},
867+
container_key: containerInfo ? containerInfo.container_key : null,
868+
index_in_container: containerInfo ? containerInfo.index_in_container : null,
869+
container_item_count: containerInfo ? containerInfo.container_item_count : null,
767870
text: toSafeString(textVal),
768871
in_viewport: inView,
769872
is_occluded: occluded,

src/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.8.6",
4+
"version": "2.9.0",
55
"description": "Extract semantic visual grounding data from web pages",
66
"permissions": ["activeTab", "scripting"],
77
"host_permissions": ["<all_urls>"],
0 Bytes
Binary file not shown.

src/extension/release.json

Lines changed: 48 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
11
{
2-
"url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/279771305",
3-
"assets_url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/279771305/assets",
4-
"upload_url": "https://uploads.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/279771305/assets{?name,label}",
5-
"html_url": "https://github.com/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/tag/v2.8.6",
6-
"id": 279771305,
2+
"url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/285093610",
3+
"assets_url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/285093610/assets",
4+
"upload_url": "https://uploads.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/285093610/assets{?name,label}",
5+
"html_url": "https://github.com/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/tag/v2.9.0",
6+
"id": 285093610,
77
"author": {
8-
"login": "rcholic",
9-
"id": 135060,
10-
"node_id": "MDQ6VXNlcjEzNTA2MA==",
11-
"avatar_url": "https://avatars.githubusercontent.com/u/135060?v=4",
8+
"login": "github-actions[bot]",
9+
"id": 41898282,
10+
"node_id": "MDM6Qm90NDE4OTgyODI=",
11+
"avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4",
1212
"gravatar_id": "",
13-
"url": "https://api.github.com/users/rcholic",
14-
"html_url": "https://github.com/rcholic",
15-
"followers_url": "https://api.github.com/users/rcholic/followers",
16-
"following_url": "https://api.github.com/users/rcholic/following{/other_user}",
17-
"gists_url": "https://api.github.com/users/rcholic/gists{/gist_id}",
18-
"starred_url": "https://api.github.com/users/rcholic/starred{/owner}{/repo}",
19-
"subscriptions_url": "https://api.github.com/users/rcholic/subscriptions",
20-
"organizations_url": "https://api.github.com/users/rcholic/orgs",
21-
"repos_url": "https://api.github.com/users/rcholic/repos",
22-
"events_url": "https://api.github.com/users/rcholic/events{/privacy}",
23-
"received_events_url": "https://api.github.com/users/rcholic/received_events",
24-
"type": "User",
13+
"url": "https://api.github.com/users/github-actions%5Bbot%5D",
14+
"html_url": "https://github.com/apps/github-actions",
15+
"followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers",
16+
"following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}",
17+
"gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}",
18+
"starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}",
19+
"subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions",
20+
"organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs",
21+
"repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos",
22+
"events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}",
23+
"received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events",
24+
"type": "Bot",
2525
"user_view_type": "public",
2626
"site_admin": false
2727
},
28-
"node_id": "RE_kwDOQshiJ84QrPip",
29-
"tag_name": "v2.8.6",
28+
"node_id": "RE_kwDOQshiJ84Q_i7q",
29+
"tag_name": "v2.9.0",
3030
"target_commitish": "main",
31-
"name": "Release v2.8.6",
31+
"name": "Release v2.9.0",
3232
"draft": false,
3333
"immutable": false,
3434
"prerelease": false,
35-
"created_at": "2026-01-25T20:33:25Z",
36-
"updated_at": "2026-01-25T20:34:33Z",
37-
"published_at": "2026-01-25T20:33:51Z",
35+
"created_at": "2026-02-11T04:42:28Z",
36+
"updated_at": "2026-02-11T04:43:38Z",
37+
"published_at": "2026-02-11T04:43:37Z",
3838
"assets": [
3939
{
40-
"url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/assets/345751999",
41-
"id": 345751999,
42-
"node_id": "RA_kwDOQshiJ84Um8G_",
40+
"url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/assets/354007414",
41+
"id": 354007414,
42+
"node_id": "RA_kwDOQshiJ84VGbl2",
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": 79706,
69-
"digest": "sha256:c2e5381ff623b044f18020ef5d0562378496314772b9494c3b2ce71ff63f2646",
70-
"download_count": 2,
71-
"created_at": "2026-01-25T20:34:33Z",
72-
"updated_at": "2026-01-25T20:34:33Z",
73-
"browser_download_url": "https://github.com/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/download/v2.8.6/extension-files.tar.gz"
68+
"size": 81085,
69+
"digest": "sha256:30397ec5b3500ddc33955d2e0dee67393920ac6798ae807f9f267b3ae869035c",
70+
"download_count": 0,
71+
"created_at": "2026-02-11T04:43:38Z",
72+
"updated_at": "2026-02-11T04:43:38Z",
73+
"browser_download_url": "https://github.com/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/download/v2.9.0/extension-files.tar.gz"
7474
},
7575
{
76-
"url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/assets/345751998",
77-
"id": 345751998,
78-
"node_id": "RA_kwDOQshiJ84Um8G-",
76+
"url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/assets/354007415",
77+
"id": 354007415,
78+
"node_id": "RA_kwDOQshiJ84VGbl3",
7979
"name": "extension-package.zip",
8080
"label": "",
8181
"uploader": {
@@ -101,15 +101,16 @@
101101
},
102102
"content_type": "application/zip",
103103
"state": "uploaded",
104-
"size": 81339,
105-
"digest": "sha256:35232bcde1fe0c8e6d0178b04377fe80f6442dcb01296a15dddf4639542f7354",
104+
"size": 82665,
105+
"digest": "sha256:dab6ffd92ac462890b88605effc088227dfe181a303ea6db41f93cfc6baecf38",
106106
"download_count": 0,
107-
"created_at": "2026-01-25T20:34:33Z",
108-
"updated_at": "2026-01-25T20:34:33Z",
109-
"browser_download_url": "https://github.com/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/download/v2.8.6/extension-package.zip"
107+
"created_at": "2026-02-11T04:43:38Z",
108+
"updated_at": "2026-02-11T04:43:38Z",
109+
"browser_download_url": "https://github.com/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/download/v2.9.0/extension-package.zip"
110110
}
111111
],
112-
"tarball_url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/tarball/v2.8.6",
113-
"zipball_url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/zipball/v2.8.6",
114-
"body": ""
112+
"tarball_url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/tarball/v2.9.0",
113+
"zipball_url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/zipball/v2.9.0",
114+
"body": "## What's Changed\n* change release package by @rcholic in https://github.com/SentienceAPI/Sentience-Geometry-Chrome-Extension/pull/41\n\n\n**Full Changelog**: https://github.com/SentienceAPI/Sentience-Geometry-Chrome-Extension/compare/v2.8.6...v2.9.0",
115+
"mentions_count": 1
115116
}

0 commit comments

Comments
 (0)