Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
Offset
Magnus Müller02986c7d88d3
diff --git a/browser_use/browser/session.py b/browser_use/browser/session.pyindex e57de895e..9e3c83c6a 100644--- a/browser_use/browser/session.py+++ b/browser_use/browser/session.py@@ -1897,7 +1897,8 @@ class BrowserSession(BaseModel):Math.min(maxCornerSize, Math.min(rect.width, rect.height) * 0.35));const borderWidth = 3;- const offset = 10; // Starting offset in pixels+ const startOffset = 10; // Starting offset in pixels+ const finalOffset = -3; // Final position slightly outside the element// Create container for all cornersconst container = document.createElement('div');@@ -1914,10 +1915,10 @@ class BrowserSession(BaseModel):// Create 4 corner bracketsconst corners = [- {{ pos: 'top-left', x: -offset, y: -offset }},- {{ pos: 'top-right', x: offset, y: -offset }},- {{ pos: 'bottom-left', x: -offset, y: offset }},- {{ pos: 'bottom-right', x: offset, y: offset }}+ {{ pos: 'top-left', startX: -startOffset, startY: -startOffset, finalX: finalOffset, finalY: finalOffset }},+ {{ pos: 'top-right', startX: startOffset, startY: -startOffset, finalX: -finalOffset, finalY: finalOffset }},+ {{ pos: 'bottom-left', startX: -startOffset, startY: startOffset, finalX: finalOffset, finalY: -finalOffset }},+ {{ pos: 'bottom-right', startX: startOffset, startY: startOffset, finalX: -finalOffset, finalY: -finalOffset }}];corners.forEach(corner => {{@@ -1936,32 +1937,32 @@ class BrowserSession(BaseModel):bracket.style.left = '0';bracket.style.borderTop = `${{borderWidth}}px solid ${{color}}`;bracket.style.borderLeft = `${{borderWidth}}px solid ${{color}}`;- bracket.style.transform = `translate(${{corner.x}}px, ${{corner.y}}px)`;+ bracket.style.transform = `translate(${{corner.startX}}px, ${{corner.startY}}px)`;}} else if (corner.pos === 'top-right') {{bracket.style.top = '0';bracket.style.right = '0';bracket.style.borderTop = `${{borderWidth}}px solid ${{color}}`;bracket.style.borderRight = `${{borderWidth}}px solid ${{color}}`;- bracket.style.transform = `translate(${{corner.x}}px, ${{corner.y}}px)`;+ bracket.style.transform = `translate(${{corner.startX}}px, ${{corner.startY}}px)`;}} else if (corner.pos === 'bottom-left') {{bracket.style.bottom = '0';bracket.style.left = '0';bracket.style.borderBottom = `${{borderWidth}}px solid ${{color}}`;bracket.style.borderLeft = `${{borderWidth}}px solid ${{color}}`;- bracket.style.transform = `translate(${{corner.x}}px, ${{corner.y}}px)`;+ bracket.style.transform = `translate(${{corner.startX}}px, ${{corner.startY}}px)`;}} else if (corner.pos === 'bottom-right') {{bracket.style.bottom = '0';bracket.style.right = '0';bracket.style.borderBottom = `${{borderWidth}}px solid ${{color}}`;bracket.style.borderRight = `${{borderWidth}}px solid ${{color}}`;- bracket.style.transform = `translate(${{corner.x}}px, ${{corner.y}}px)`;+ bracket.style.transform = `translate(${{corner.startX}}px, ${{corner.startY}}px)`;}}container.appendChild(bracket);- // Animate inward after a tiny delay+ // Animate to final position slightly outside the elementsetTimeout(() => {{- bracket.style.transform = 'translate(0, 0)';+ bracket.style.transform = `translate(${{corner.finalX}}px, ${{corner.finalY}}px)`;}}, 10);}});