Skip to content

Commit 89841fc

Browse files
authored
Remove Stagehand Nav (#360)
* Remove Stagehand Nav * changeset
1 parent b7b3701 commit 89841fc

File tree

2 files changed

+5
-73
lines changed

2 files changed

+5
-73
lines changed

Diff for: .changeset/ninety-timers-punch.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@browserbasehq/stagehand": patch
3+
---
4+
5+
Remove stagehand nav entirely

Diff for: lib/dom/debug.ts

-73
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { calculateViewportHeight } from "./utils";
2-
31
export async function debugDom() {
42
window.chunkNumber = 0;
53

@@ -10,7 +8,6 @@ export async function debugDom() {
108
const selectorMap = multiSelectorMapToSelectorMap(multiSelectorMap);
119

1210
drawChunk(selectorMap);
13-
setupChunkNav();
1411
}
1512

1613
function multiSelectorMapToSelectorMap(
@@ -67,7 +64,6 @@ function drawChunk(selectorMap: Record<number, string>) {
6764

6865
async function cleanupDebug() {
6966
cleanupMarkers();
70-
cleanupNav();
7167
}
7268

7369
function cleanupMarkers() {
@@ -77,74 +73,5 @@ function cleanupMarkers() {
7773
});
7874
}
7975

80-
function cleanupNav() {
81-
const stagehandNavElements = document.querySelectorAll(".stagehand-nav");
82-
stagehandNavElements.forEach((element) => {
83-
element.remove();
84-
});
85-
}
86-
87-
function setupChunkNav() {
88-
const viewportHeight = calculateViewportHeight();
89-
const documentHeight = document.documentElement.scrollHeight;
90-
const totalChunks = Math.ceil(documentHeight / viewportHeight);
91-
92-
if (window.chunkNumber > 0) {
93-
const prevChunkButton = document.createElement("button");
94-
prevChunkButton.className = "stagehand-nav";
95-
96-
prevChunkButton.textContent = "Previous";
97-
prevChunkButton.style.marginLeft = "50px";
98-
prevChunkButton.style.position = "fixed";
99-
prevChunkButton.style.bottom = "10px";
100-
prevChunkButton.style.left = "50%";
101-
prevChunkButton.style.transform = "translateX(-50%)";
102-
prevChunkButton.style.zIndex = "1000000000";
103-
prevChunkButton.onclick = async () => {
104-
cleanupMarkers();
105-
cleanupNav();
106-
window.chunkNumber -= 1;
107-
window.scrollTo(0, window.chunkNumber * viewportHeight);
108-
await window.waitForDomSettle();
109-
const { selectorMap: multiSelectorMap } = await window.processElements(
110-
window.chunkNumber,
111-
);
112-
113-
const selectorMap = multiSelectorMapToSelectorMap(multiSelectorMap);
114-
115-
drawChunk(selectorMap);
116-
setupChunkNav();
117-
};
118-
document.body.appendChild(prevChunkButton);
119-
}
120-
if (totalChunks > window.chunkNumber) {
121-
const nextChunkButton = document.createElement("button");
122-
nextChunkButton.className = "stagehand-nav";
123-
nextChunkButton.textContent = "Next";
124-
nextChunkButton.style.marginRight = "50px";
125-
nextChunkButton.style.position = "fixed";
126-
nextChunkButton.style.bottom = "10px";
127-
nextChunkButton.style.right = "50%";
128-
nextChunkButton.style.transform = "translateX(50%)";
129-
nextChunkButton.style.zIndex = "1000000000";
130-
nextChunkButton.onclick = async () => {
131-
cleanupMarkers();
132-
cleanupNav();
133-
window.chunkNumber += 1;
134-
window.scrollTo(0, window.chunkNumber * viewportHeight);
135-
await window.waitForDomSettle();
136-
137-
const { selectorMap: multiSelectorMap } = await window.processElements(
138-
window.chunkNumber,
139-
);
140-
const selectorMap = multiSelectorMapToSelectorMap(multiSelectorMap);
141-
drawChunk(selectorMap);
142-
setupChunkNav();
143-
};
144-
145-
document.body.appendChild(nextChunkButton);
146-
}
147-
}
148-
14976
window.debugDom = debugDom;
15077
window.cleanupDebug = cleanupDebug;

0 commit comments

Comments
 (0)