Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/extension/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,16 @@
case "SENTIENCE_SHOW_OVERLAY":
!function(data) {
const {elements: elements, targetElementId: targetElementId} = data;
if (!elements || !Array.isArray(elements)) return;
if (!elements || "object" != typeof elements || "number" != typeof elements.length) return;
const elementsArray = Array.isArray(elements) ? elements : Array.from(elements);
removeOverlay();
const host = document.createElement("div");
host.id = OVERLAY_HOST_ID, host.style.cssText = "\n position: fixed !important;\n top: 0 !important;\n left: 0 !important;\n width: 100vw !important;\n height: 100vh !important;\n pointer-events: none !important;\n z-index: 2147483647 !important;\n margin: 0 !important;\n padding: 0 !important;\n ",
document.body.appendChild(host);
const shadow = host.attachShadow({
mode: "closed"
}), maxImportance = Math.max(...elements.map(e => e.importance || 0), 1);
elements.forEach(element => {
}), maxImportance = Math.max(...elementsArray.map(e => e.importance || 0), 1);
elementsArray.forEach(element => {
const bbox = element.bbox;
if (!bbox) return;
const isTarget = element.id === targetElementId, isPrimary = element.visual_cues?.is_primary || !1, importance = element.importance || 0;
Expand Down
67 changes: 42 additions & 25 deletions src/extension/injected_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,33 +390,46 @@
return null;
}
function getRawHTML(root) {
const sourceRoot = root || document.body, clone = sourceRoot.cloneNode(!0);
[ "nav", "footer", "header", "script", "style", "noscript", "iframe", "svg" ].forEach(tag => {
clone.querySelectorAll(tag).forEach(el => {
el.parentNode && el.parentNode.removeChild(el);
});
});
const invisibleSelectors = [], walker = document.createTreeWalker(sourceRoot, NodeFilter.SHOW_ELEMENT, null, !1);
const sourceRoot = root || document.body, clone = sourceRoot.cloneNode(!0), unwantedTags = [ "script", "style", "noscript", "iframe", "svg" ], unwantedTagSet = new Set(unwantedTags);
function getChildIndex(node) {
let index = 0, sibling = node;
for (;sibling = sibling.previousElementSibling; ) index++;
return index;
}
function getElementPath(node, root) {
const path = [];
let current = node;
for (;current && current !== root && current.parentElement; ) path.unshift(getChildIndex(current)),
current = current.parentElement;
return path;
}
const invisiblePaths = [], walker = document.createTreeWalker(sourceRoot, NodeFilter.SHOW_ELEMENT, null, !1);
let node;
for (;node = walker.nextNode(); ) {
const tag = node.tagName.toLowerCase();
if ("head" === tag || "title" === tag) continue;
if (unwantedTagSet.has(tag)) continue;
const style = window.getComputedStyle(node);
if ("none" === style.display || "hidden" === style.visibility || 0 === node.offsetWidth && 0 === node.offsetHeight) {
let selector = tag;
if (node.id) selector = `#${node.id}`; else if (node.className && "string" == typeof node.className) {
const classes = node.className.trim().split(/\s+/).filter(c => c);
classes.length > 0 && (selector = `${tag}.${classes.join(".")}`);
}
invisibleSelectors.push(selector);
}
"none" !== style.display && "hidden" !== style.visibility || invisiblePaths.push(getElementPath(node, sourceRoot));
}
invisibleSelectors.forEach(selector => {
try {
clone.querySelectorAll(selector).forEach(el => {
el.parentNode && el.parentNode.removeChild(el);
});
} catch (e) {}
invisiblePaths.sort((a, b) => {
if (a.length !== b.length) return b.length - a.length;
for (let i = a.length - 1; i >= 0; i--) if (a[i] !== b[i]) return b[i] - a[i];
return 0;
}), invisiblePaths.forEach(path => {
const el = function(root, path) {
let current = root;
for (const index of path) {
if (!current || !current.children || index >= current.children.length) return null;
current = current.children[index];
}
return current;
}(clone, path);
el && el.parentNode && el.parentNode.removeChild(el);
}), unwantedTags.forEach(tag => {
clone.querySelectorAll(tag).forEach(el => {
el.parentNode && el.parentNode.removeChild(el);
});
});
clone.querySelectorAll("a[href]").forEach(link => {
const href = link.getAttribute("href");
Expand Down Expand Up @@ -1178,17 +1191,21 @@
}, autoDisableTimeout)), window.sentience_stopRecording = stopRecording, stopRecording;
}
function showOverlay(elements, targetElementId = null) {
elements && Array.isArray(elements) && window.postMessage({
if (!elements || "object" != typeof elements || "number" != typeof elements.length) return;
const elementsArray = Array.isArray(elements) ? elements : Array.from(elements);
window.postMessage({
type: "SENTIENCE_SHOW_OVERLAY",
elements: elements,
elements: elementsArray,
targetElementId: targetElementId,
timestamp: Date.now()
}, "*");
}
function showGrid(grids, targetGridId = null) {
grids && Array.isArray(grids) && window.postMessage({
if (!grids || "object" != typeof grids || "number" != typeof grids.length) return;
const gridsArray = Array.isArray(grids) ? grids : Array.from(grids);
window.postMessage({
type: "SENTIENCE_SHOW_GRID_OVERLAY",
grids: grids,
grids: gridsArray,
targetGridId: targetGridId,
timestamp: Date.now()
}, "*");
Expand Down
2 changes: 1 addition & 1 deletion src/extension/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "Sentience Semantic Visual Grounding Extractor",
"version": "2.8.3",
"version": "2.8.4",
"description": "Extract semantic visual grounding data from web pages",
"permissions": ["activeTab", "scripting"],
"host_permissions": ["<all_urls>"],
Expand Down
92 changes: 46 additions & 46 deletions src/extension/release.json
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
{
"url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/279250819",
"assets_url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/279250819/assets",
"upload_url": "https://uploads.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/279250819/assets{?name,label}",
"html_url": "https://github.com/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/tag/v2.8.3",
"id": 279250819,
"url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/279701545",
"assets_url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/279701545/assets",
"upload_url": "https://uploads.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/279701545/assets{?name,label}",
"html_url": "https://github.com/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/tag/v2.8.4",
"id": 279701545,
"author": {
"login": "github-actions[bot]",
"id": 41898282,
"node_id": "MDM6Qm90NDE4OTgyODI=",
"avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4",
"login": "rcholic",
"id": 135060,
"node_id": "MDQ6VXNlcjEzNTA2MA==",
"avatar_url": "https://avatars.githubusercontent.com/u/135060?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/github-actions%5Bbot%5D",
"html_url": "https://github.com/apps/github-actions",
"followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers",
"following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}",
"gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}",
"starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions",
"organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs",
"repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos",
"events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}",
"received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events",
"type": "Bot",
"url": "https://api.github.com/users/rcholic",
"html_url": "https://github.com/rcholic",
"followers_url": "https://api.github.com/users/rcholic/followers",
"following_url": "https://api.github.com/users/rcholic/following{/other_user}",
"gists_url": "https://api.github.com/users/rcholic/gists{/gist_id}",
"starred_url": "https://api.github.com/users/rcholic/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/rcholic/subscriptions",
"organizations_url": "https://api.github.com/users/rcholic/orgs",
"repos_url": "https://api.github.com/users/rcholic/repos",
"events_url": "https://api.github.com/users/rcholic/events{/privacy}",
"received_events_url": "https://api.github.com/users/rcholic/received_events",
"type": "User",
"user_view_type": "public",
"site_admin": false
},
"node_id": "RE_kwDOQshiJ84QpQeD",
"tag_name": "v2.8.3",
"node_id": "RE_kwDOQshiJ84Qq-gp",
"tag_name": "v2.8.4",
"target_commitish": "main",
"name": "Release v2.8.3",
"name": "Release v2.8.4",
"draft": false,
"immutable": false,
"prerelease": false,
"created_at": "2026-01-23T06:12:02Z",
"updated_at": "2026-01-23T06:14:22Z",
"published_at": "2026-01-23T06:13:11Z",
"created_at": "2026-01-25T06:10:24Z",
"updated_at": "2026-01-25T06:11:51Z",
"published_at": "2026-01-25T06:11:11Z",
"assets": [
{
"url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/assets/344654926",
"id": 344654926,
"node_id": "RA_kwDOQshiJ84UiwRO",
"url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/assets/345545012",
"id": 345545012,
"node_id": "RA_kwDOQshiJ84UmJk0",
"name": "extension-files.tar.gz",
"label": "",
"uploader": {
Expand All @@ -65,17 +65,17 @@
},
"content_type": "application/gzip",
"state": "uploaded",
"size": 79317,
"digest": "sha256:0d8979ec6c3cde0fb679501f89e5fdb0db8d547661b1da7d6299f28262ad1fc4",
"size": 79724,
"digest": "sha256:d78574e7fb0dfa121a261b650478a1d7a188377b3ba03fed1205cf07f2e1895e",
"download_count": 0,
"created_at": "2026-01-23T06:13:12Z",
"updated_at": "2026-01-23T06:13:12Z",
"browser_download_url": "https://github.com/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/download/v2.8.3/extension-files.tar.gz"
"created_at": "2026-01-25T06:11:50Z",
"updated_at": "2026-01-25T06:11:51Z",
"browser_download_url": "https://github.com/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/download/v2.8.4/extension-files.tar.gz"
},
{
"url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/assets/344654925",
"id": 344654925,
"node_id": "RA_kwDOQshiJ84UiwRN",
"url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/assets/345545011",
"id": 345545011,
"node_id": "RA_kwDOQshiJ84UmJkz",
"name": "extension-package.zip",
"label": "",
"uploader": {
Expand All @@ -101,15 +101,15 @@
},
"content_type": "application/zip",
"state": "uploaded",
"size": 80784,
"digest": "sha256:cc80691d6efc868a9d4009fe1b8bdb94f33017666a7d2db429a1f4aaee978616",
"size": 81073,
"digest": "sha256:b6c4cb930256d2067e566281976840417da78595a734a48f6baae735e3a0356b",
"download_count": 0,
"created_at": "2026-01-23T06:13:12Z",
"updated_at": "2026-01-23T06:13:12Z",
"browser_download_url": "https://github.com/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/download/v2.8.3/extension-package.zip"
"created_at": "2026-01-25T06:11:50Z",
"updated_at": "2026-01-25T06:11:51Z",
"browser_download_url": "https://github.com/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/download/v2.8.4/extension-package.zip"
}
],
"tarball_url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/tarball/v2.8.3",
"zipball_url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/zipball/v2.8.3",
"body": "**Full Changelog**: https://github.com/SentienceAPI/Sentience-Geometry-Chrome-Extension/compare/v2.8.2...v2.8.3"
"tarball_url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/tarball/v2.8.4",
"zipball_url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/zipball/v2.8.4",
"body": ""
}
Loading