@@ -125,7 +125,7 @@ async def draw_observe_overlay(page, elements: list[dict]):
125125 (elements) => {
126126 // First remove any existing overlays
127127 document.querySelectorAll('.stagehand-observe-overlay').forEach(el => el.remove());
128-
128+
129129 // Create container for overlays
130130 const container = document.createElement('div');
131131 container.style.position = 'fixed';
@@ -137,26 +137,26 @@ async def draw_observe_overlay(page, elements: list[dict]):
137137 container.style.zIndex = '10000';
138138 container.className = 'stagehand-observe-overlay';
139139 document.body.appendChild(container);
140-
140+
141141 // Process each element
142142 elements.forEach((element, index) => {
143143 try {
144144 // Parse the selector
145145 let selector = element.selector;
146146 if (selector.startsWith('xpath=')) {
147147 selector = selector.substring(6);
148-
148+
149149 // Evaluate the XPath to get the element
150150 const result = document.evaluate(
151- selector, document, null,
151+ selector, document, null,
152152 XPathResult.FIRST_ORDERED_NODE_TYPE, null
153153 );
154-
154+
155155 if (result.singleNodeValue) {
156156 // Get the element's position
157157 const el = result.singleNodeValue;
158158 const rect = el.getBoundingClientRect();
159-
159+
160160 // Create the overlay
161161 const overlay = document.createElement('div');
162162 overlay.style.position = 'absolute';
@@ -168,7 +168,7 @@ async def draw_observe_overlay(page, elements: list[dict]):
168168 overlay.style.backgroundColor = 'rgba(255, 0, 0, 0.1)';
169169 overlay.style.boxSizing = 'border-box';
170170 overlay.style.pointerEvents = 'none';
171-
171+
172172 // Add element ID
173173 const label = document.createElement('div');
174174 label.textContent = index + 1;
@@ -180,7 +180,7 @@ async def draw_observe_overlay(page, elements: list[dict]):
180180 label.style.padding = '2px 5px';
181181 label.style.borderRadius = '3px';
182182 label.style.fontSize = '12px';
183-
183+
184184 overlay.appendChild(label);
185185 container.appendChild(overlay);
186186 }
@@ -189,7 +189,7 @@ async def draw_observe_overlay(page, elements: list[dict]):
189189 const el = document.querySelector(selector);
190190 if (el) {
191191 const rect = el.getBoundingClientRect();
192-
192+
193193 // Create the overlay (same as above)
194194 const overlay = document.createElement('div');
195195 overlay.style.position = 'absolute';
@@ -201,7 +201,7 @@ async def draw_observe_overlay(page, elements: list[dict]):
201201 overlay.style.backgroundColor = 'rgba(255, 0, 0, 0.1)';
202202 overlay.style.boxSizing = 'border-box';
203203 overlay.style.pointerEvents = 'none';
204-
204+
205205 // Add element ID
206206 const label = document.createElement('div');
207207 label.textContent = index + 1;
@@ -213,7 +213,7 @@ async def draw_observe_overlay(page, elements: list[dict]):
213213 label.style.padding = '2px 5px';
214214 label.style.borderRadius = '3px';
215215 label.style.fontSize = '12px';
216-
216+
217217 overlay.appendChild(label);
218218 container.appendChild(overlay);
219219 }
@@ -222,7 +222,7 @@ async def draw_observe_overlay(page, elements: list[dict]):
222222 console.error(`Error drawing overlay for element ${index}:`, error);
223223 }
224224 });
225-
225+
226226 // Auto-remove after 5 seconds
227227 setTimeout(() => {
228228 document.querySelectorAll('.stagehand-observe-overlay').forEach(el => el.remove());
0 commit comments