diff --git a/src/extension/content.js b/src/extension/content.js index e94cde1a..b65cfb52 100644 --- a/src/extension/content.js +++ b/src/extension/content.js @@ -114,6 +114,41 @@ case "SENTIENCE_CLEAR_OVERLAY": removeOverlay(); + break; + + case "SENTIENCE_SHOW_GRID_OVERLAY": + !function(data) { + const {grids: grids, targetGridId: targetGridId} = data; + if (!grids || !Array.isArray(grids)) return; + 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" + }); + grids.forEach(grid => { + const bbox = grid.bbox; + if (!bbox) return; + const isTarget = grid.grid_id === targetGridId, isDominant = !0 === grid.is_dominant; + let color = "#9B59B6"; + isTarget ? color = "#FF0000" : isDominant && (color = "#FF8C00"); + const borderStyle = isTarget ? "solid" : "dashed", borderWidth = isTarget ? 3 : isDominant ? 2.5 : 2, opacity = isTarget ? 1 : isDominant ? .9 : .8, fillOpacity = .1 * opacity, hexOpacity = Math.round(255 * fillOpacity).toString(16).padStart(2, "0"), box = document.createElement("div"); + box.style.cssText = `\n position: absolute;\n left: ${bbox.x}px;\n top: ${bbox.y}px;\n width: ${bbox.width}px;\n height: ${bbox.height}px;\n border: ${borderWidth}px ${borderStyle} ${color};\n background-color: ${color}${hexOpacity};\n box-sizing: border-box;\n opacity: ${opacity};\n pointer-events: none;\n `; + let labelText = grid.label ? `Grid ${grid.grid_id}: ${grid.label}` : `Grid ${grid.grid_id}`; + grid.is_dominant && (labelText = `⭐ ${labelText} (dominant)`); + const badge = document.createElement("span"); + if (badge.textContent = labelText, badge.style.cssText = `\n position: absolute;\n top: -18px;\n left: 0;\n background: ${color};\n color: white;\n font-size: 11px;\n font-weight: bold;\n padding: 2px 6px;\n font-family: Arial, sans-serif;\n border-radius: 3px;\n opacity: 0.95;\n white-space: nowrap;\n pointer-events: none;\n `, + box.appendChild(badge), isTarget) { + const targetIndicator = document.createElement("span"); + targetIndicator.textContent = "🎯", targetIndicator.style.cssText = "\n position: absolute;\n top: -18px;\n right: 0;\n font-size: 16px;\n pointer-events: none;\n ", + box.appendChild(targetIndicator); + } + shadow.appendChild(box); + }), overlayTimeout = setTimeout(() => { + removeOverlay(); + }, 5e3); + }(event.data); } }); const OVERLAY_HOST_ID = "sentience-overlay-host"; diff --git a/src/extension/injected_api.js b/src/extension/injected_api.js index f8c1ec14..e70bfb40 100644 --- a/src/extension/injected_api.js +++ b/src/extension/injected_api.js @@ -855,6 +855,14 @@ timestamp: Date.now() }, "*"); } + function showGrid(grids, targetGridId = null) { + grids && Array.isArray(grids) && window.postMessage({ + type: "SENTIENCE_SHOW_GRID_OVERLAY", + grids: grids, + targetGridId: targetGridId, + timestamp: Date.now() + }, "*"); + } function clearOverlay() { window.postMessage({ type: "SENTIENCE_CLEAR_OVERLAY" @@ -875,6 +883,7 @@ click: click, startRecording: startRecording, showOverlay: showOverlay, + showGrid: showGrid, clearOverlay: clearOverlay }, window.sentience_iframe_handler_setup || (window.addEventListener("message", async event => { if ("SENTIENCE_IFRAME_SNAPSHOT_REQUEST" === event.data?.type) { diff --git a/src/extension/manifest.json b/src/extension/manifest.json index 7c821a42..b497bf3b 100644 --- a/src/extension/manifest.json +++ b/src/extension/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 3, "name": "Sentience Semantic Visual Grounding Extractor", - "version": "2.4.0", + "version": "2.4.1", "description": "Extract semantic visual grounding data from web pages", "permissions": ["activeTab", "scripting"], "host_permissions": [""], diff --git a/src/extension/pkg/sentience_core_bg.wasm b/src/extension/pkg/sentience_core_bg.wasm index 77c665ab..71ba0559 100644 Binary files a/src/extension/pkg/sentience_core_bg.wasm and b/src/extension/pkg/sentience_core_bg.wasm differ diff --git a/src/extension/release.json b/src/extension/release.json index e8f6da27..bfe54d30 100644 --- a/src/extension/release.json +++ b/src/extension/release.json @@ -1,45 +1,45 @@ { - "url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/275780781", - "assets_url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/275780781/assets", - "upload_url": "https://uploads.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/275780781/assets{?name,label}", - "html_url": "https://github.com/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/tag/v2.4.0", - "id": 275780781, + "url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/276563152", + "assets_url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/276563152/assets", + "upload_url": "https://uploads.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/276563152/assets{?name,label}", + "html_url": "https://github.com/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/tag/v2.4.1", + "id": 276563152, "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_kwDOQshiJ84QcBSt", - "tag_name": "v2.4.0", + "node_id": "RE_kwDOQshiJ84QfATQ", + "tag_name": "v2.4.1", "target_commitish": "main", - "name": "Release v2.4.0", + "name": "Release v2.4.1", "draft": false, "immutable": false, "prerelease": false, - "created_at": "2026-01-11T03:04:44Z", - "updated_at": "2026-01-11T03:07:27Z", - "published_at": "2026-01-11T03:06:49Z", + "created_at": "2026-01-14T01:02:36Z", + "updated_at": "2026-01-14T01:04:42Z", + "published_at": "2026-01-14T01:04:00Z", "assets": [ { - "url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/assets/338955721", - "id": 338955721, - "node_id": "RA_kwDOQshiJ84UNA3J", + "url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/assets/340210571", + "id": 340210571, + "node_id": "RA_kwDOQshiJ84URzOL", "name": "extension-files.tar.gz", "label": "", "uploader": { @@ -65,17 +65,17 @@ }, "content_type": "application/gzip", "state": "uploaded", - "size": 73936, - "digest": "sha256:8e15a80621f3494616a751764e98a935933cea18b88423121d9f4373f0766306", - "download_count": 3, - "created_at": "2026-01-11T03:06:50Z", - "updated_at": "2026-01-11T03:06:50Z", - "browser_download_url": "https://github.com/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/download/v2.4.0/extension-files.tar.gz" + "size": 74389, + "digest": "sha256:ed8aeac5d364186b1a6b255aa3aeb5b562f204830f75402d528f2c7e6d819cfd", + "download_count": 0, + "created_at": "2026-01-14T01:04:41Z", + "updated_at": "2026-01-14T01:04:42Z", + "browser_download_url": "https://github.com/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/download/v2.4.1/extension-files.tar.gz" }, { - "url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/assets/338955720", - "id": 338955720, - "node_id": "RA_kwDOQshiJ84UNA3I", + "url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/assets/340210572", + "id": 340210572, + "node_id": "RA_kwDOQshiJ84URzOM", "name": "extension-package.zip", "label": "", "uploader": { @@ -101,16 +101,15 @@ }, "content_type": "application/zip", "state": "uploaded", - "size": 76016, - "digest": "sha256:56dcf5134d47ed4ab8025fb81c21946acf51461baa6973a60ea59727d6d44351", + "size": 76376, + "digest": "sha256:7f209ac1eac7d1a3be1a12248bf523f82a47f6767501dba7dc01660ed218763e", "download_count": 0, - "created_at": "2026-01-11T03:06:49Z", - "updated_at": "2026-01-11T03:06:50Z", - "browser_download_url": "https://github.com/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/download/v2.4.0/extension-package.zip" + "created_at": "2026-01-14T01:04:41Z", + "updated_at": "2026-01-14T01:04:42Z", + "browser_download_url": "https://github.com/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/download/v2.4.1/extension-package.zip" } ], - "tarball_url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/tarball/v2.4.0", - "zipball_url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/zipball/v2.4.0", - "body": "## What's Changed\r\n* Structural tags by @rcholic in https://github.com/SentienceAPI/Sentience-Geometry-Chrome-Extension/pull/28\r\n\r\n\r\n**Full Changelog**: https://github.com/SentienceAPI/Sentience-Geometry-Chrome-Extension/compare/v2.3.0...v2.4.0", - "mentions_count": 1 + "tarball_url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/tarball/v2.4.1", + "zipball_url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/zipball/v2.4.1", + "body": "" }