Spaces:
No application file
No application file
Update browser_automation_ui.html
Browse files- browser_automation_ui.html +25 -3
browser_automation_ui.html
CHANGED
|
@@ -97,6 +97,12 @@
|
|
| 97 |
<div class="api-header"><i class="lucide lucide-camera"></i><h3>Screenshot</h3></div>
|
| 98 |
<div class="api-body">
|
| 99 |
<button class="btn btn-primary" onclick="takeScreenshot()"><i class="lucide lucide-camera"></i>Capture</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
<div id="shotPreview" style="margin-top:16px;"></div>
|
| 101 |
<div class="response-area" id="shotResp"></div>
|
| 102 |
</div>
|
|
@@ -224,12 +230,28 @@ All endpoints return { ok: true/false, data, error }
|
|
| 224 |
document.getElementById('browserResp').textContent = JSON.stringify(out,null,2);
|
| 225 |
}
|
| 226 |
|
| 227 |
-
async function takeScreenshot(){
|
| 228 |
const out = await api('/browser/screenshot');
|
| 229 |
-
|
| 230 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 231 |
}
|
| 232 |
|
|
|
|
| 233 |
async function elementAction() {
|
| 234 |
const selector = document.getElementById('selector').value.trim();
|
| 235 |
if (!selector) return alert('Enter selector');
|
|
|
|
| 97 |
<div class="api-header"><i class="lucide lucide-camera"></i><h3>Screenshot</h3></div>
|
| 98 |
<div class="api-body">
|
| 99 |
<button class="btn btn-primary" onclick="takeScreenshot()"><i class="lucide lucide-camera"></i>Capture</button>
|
| 100 |
+
<a id="downloadBtn"
|
| 101 |
+
class="btn btn-secondary"
|
| 102 |
+
style="display:none;margin-left:8px;"
|
| 103 |
+
download="screenshot.png">
|
| 104 |
+
<i class="lucide lucide-download"></i>Download
|
| 105 |
+
</a>
|
| 106 |
<div id="shotPreview" style="margin-top:16px;"></div>
|
| 107 |
<div class="response-area" id="shotResp"></div>
|
| 108 |
</div>
|
|
|
|
| 230 |
document.getElementById('browserResp').textContent = JSON.stringify(out,null,2);
|
| 231 |
}
|
| 232 |
|
| 233 |
+
async function takeScreenshot () {
|
| 234 |
const out = await api('/browser/screenshot');
|
| 235 |
+
|
| 236 |
+
// Separate the big base64 string so we don’t dump it in the response box
|
| 237 |
+
const { b64, ...meta } = out;
|
| 238 |
+
document.getElementById('shotResp').textContent = JSON.stringify(meta, null, 2);
|
| 239 |
+
|
| 240 |
+
if (b64) {
|
| 241 |
+
const dataUrl = `data:image/png;base64,${b64}`;
|
| 242 |
+
|
| 243 |
+
// Show thumbnail
|
| 244 |
+
document.getElementById('shotPreview').innerHTML =
|
| 245 |
+
`<img src="${dataUrl}" style="max-width:100%;border:1px solid #e2e8f0;border-radius:8px;">`;
|
| 246 |
+
|
| 247 |
+
// Wire up & reveal the download button
|
| 248 |
+
const dl = document.getElementById('downloadBtn');
|
| 249 |
+
dl.href = dataUrl;
|
| 250 |
+
dl.style.display = 'inline-flex';
|
| 251 |
+
}
|
| 252 |
}
|
| 253 |
|
| 254 |
+
|
| 255 |
async function elementAction() {
|
| 256 |
const selector = document.getElementById('selector').value.trim();
|
| 257 |
if (!selector) return alert('Enter selector');
|