Open
Conversation
Collaborator
Author
📚
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Type
Feature
PR Checklist
Overview
This PR introduces the functionality to capture and send the DOM structure alongside a computed page map (both raw text and structured JSON) to the backend (
/node_ai_contents).This addresses the need for richer context when analyzing pages, especially concerning performance and iframe complexity, as hinted by previous fixes related to performance and iframe inspection.
Key changes in
background.js:node_ai_contentsAPI call is now debounced globally for each tab (2000ms) to prevent excessive calls. Before sending, a SHA-256 hash of the combined DOM, page map, and page map JSON is calculated. If the hash matches the previous send for that tab, the request is skipped, addressing performance issues related to constantly sending unchanged content.page_mapandpage_map_jsonalongsidedom.Key changes in
inspect.js:page_map_extractor.js, is injected and executesextractPageMapData()periodically. This function generates an ordered list of visible, interactive, and text-contextual elements, along with their computed XPath/attributes, compiling it intopage_map_json(structured data) andpage_map(human-readable text summary).inspect.jsto ensure DOM extraction only runs on the main window (window.top === window.self) to prevent conflicts from tracking pixels or nested content injection.This enhancement improves the quality and efficiency of data sent to the AI backend by providing a structured map of the page context.
Test Cases
page_map_extractor.js, is included in the content script injection.