1
- import { calculateViewportHeight } from "./utils" ;
2
-
3
1
export async function debugDom ( ) {
4
2
window . chunkNumber = 0 ;
5
3
@@ -10,7 +8,6 @@ export async function debugDom() {
10
8
const selectorMap = multiSelectorMapToSelectorMap ( multiSelectorMap ) ;
11
9
12
10
drawChunk ( selectorMap ) ;
13
- setupChunkNav ( ) ;
14
11
}
15
12
16
13
function multiSelectorMapToSelectorMap (
@@ -67,7 +64,6 @@ function drawChunk(selectorMap: Record<number, string>) {
67
64
68
65
async function cleanupDebug ( ) {
69
66
cleanupMarkers ( ) ;
70
- cleanupNav ( ) ;
71
67
}
72
68
73
69
function cleanupMarkers ( ) {
@@ -77,74 +73,5 @@ function cleanupMarkers() {
77
73
} ) ;
78
74
}
79
75
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
-
149
76
window . debugDom = debugDom ;
150
77
window . cleanupDebug = cleanupDebug ;
0 commit comments