abeea commited on
Commit
52faf17
·
verified ·
1 Parent(s): 41ab1b6

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +53 -147
index.html CHANGED
@@ -2,7 +2,7 @@
2
  <html lang="en">
3
  <head>
4
  <meta charset="UTF-8">
5
- <title>Bulk Screenshot Tool (Logs + ZIP)</title>
6
 
7
  <style>
8
  body {
@@ -10,20 +10,11 @@ body {
10
  max-width: 1100px;
11
  margin: 20px auto;
12
  padding: 20px;
13
- background: #f5f7fa;
14
  }
15
 
16
- h1 { text-align: center; }
17
-
18
- textarea {
19
  width: 100%;
20
- height: 120px;
21
- padding: 10px;
22
- margin-top: 10px;
23
- resize: vertical;
24
- }
25
-
26
- input, button {
27
  padding: 10px;
28
  margin-top: 10px;
29
  }
@@ -32,11 +23,6 @@ button {
32
  cursor: pointer;
33
  }
34
 
35
- #status {
36
- margin-top: 15px;
37
- font-weight: bold;
38
- }
39
-
40
  #screenshots {
41
  margin-top: 25px;
42
  display: grid;
@@ -64,180 +50,100 @@ button {
64
 
65
  #logs {
66
  margin-top: 20px;
67
- background: #0f172a;
68
  color: #e5e7eb;
69
  padding: 10px;
70
- height: 200px;
71
  overflow-y: auto;
72
  font-family: monospace;
73
  font-size: 12px;
74
  border-radius: 6px;
75
  }
76
-
77
- #downloadZip {
78
- display: none;
79
- margin-top: 15px;
80
- background: #2563eb;
81
- color: #fff;
82
- border: none;
83
- border-radius: 4px;
84
- }
85
  </style>
86
  </head>
87
 
88
  <body>
89
 
90
- <h1>Bulk Screenshot Tool</h1>
91
-
92
- <h3>1️⃣ Paste URL(s)</h3>
93
- <textarea id="urlInput" placeholder="https://example.com&#10;https://example.com/login&#10;https://example.com/admin"></textarea>
94
 
95
- <h3>OR</h3>
96
 
97
- <h3>2️⃣ Upload .txt File</h3>
98
  <input type="file" id="fileInput" accept=".txt">
99
 
100
- <br>
101
- <button id="startBtn">▶ Start Capture</button>
102
- <button id="downloadZip">⬇ Download ZIP</button>
103
-
104
- <div id="status"></div>
105
 
106
- <h3>🖼 Screenshots</h3>
107
  <div id="screenshots"></div>
108
 
109
- <h3>📜 Logs</h3>
110
  <div id="logs"></div>
111
 
112
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
113
 
114
  <script>
115
- const ACCESS_KEY = "BiY4yQ0EnzeZ5A"; // 🔴 replace
116
 
117
- let screenshotData = [];
118
 
119
- function log(message) {
120
- const logs = document.getElementById("logs");
121
- logs.innerHTML += `[${new Date().toLocaleTimeString()}] ${message}<br>`;
122
- logs.scrollTop = logs.scrollHeight;
123
  }
124
 
125
- document.getElementById("startBtn").addEventListener("click", async () => {
126
- const textarea = document.getElementById("urlInput").value;
127
- const fileInput = document.getElementById("fileInput");
128
- const status = document.getElementById("status");
129
- const container = document.getElementById("screenshots");
130
-
131
- container.innerHTML = "";
132
- screenshotData = [];
133
- document.getElementById("downloadZip").style.display = "none";
134
  document.getElementById("logs").innerHTML = "";
 
135
 
136
  let urls = [];
137
 
138
- if (textarea.trim()) {
139
- log("Reading URLs from textarea");
140
- urls = textarea.split(/\r?\n/).map(u => u.trim()).filter(Boolean);
141
- } else if (fileInput.files.length) {
142
- log("Reading URLs from file");
143
- const text = await fileInput.files[0].text();
144
  urls = text.split(/\r?\n/).map(u => u.trim()).filter(Boolean);
 
 
 
 
 
145
  } else {
146
- alert("Paste URLs or upload a .txt file");
147
  return;
148
  }
149
 
150
- log(`Total URLs detected: ${urls.length}`);
151
- status.textContent = `Sending ${urls.length} URLs to ScreenshotOne...`;
152
-
153
- const payload = {
154
- access_key: ACCESS_KEY,
155
- execute: true,
156
- optimize: false,
157
- options: {
158
- viewport_width: 1280,
159
- viewport_height: 1024,
160
- full_page: true,
161
- block_ads: true,
162
- block_cookie_banners: true
163
- },
164
- requests: urls.map(url => ({ url }))
165
- };
166
-
167
- try {
168
- log("Sending bulk request...");
169
- const res = await fetch("https://api.screenshotone.com/bulk", {
170
- method: "POST",
171
- headers: { "Content-Type": "application/json" },
172
- body: JSON.stringify(payload)
173
- });
174
-
175
- log(`HTTP Status: ${res.status}`);
176
- const data = await res.json();
177
-
178
- if (!data.responses) throw new Error("Invalid API response");
179
-
180
- data.responses.forEach((item, i) => {
181
- screenshotData.push({ url: urls[i], image: item.url });
182
-
183
- const card = document.createElement("div");
184
- card.className = "card";
185
-
186
- const img = document.createElement("img");
187
- img.src = item.url;
188
- img.loading = "lazy";
189
-
190
- const label = document.createElement("div");
191
- label.className = "url";
192
- label.textContent = urls[i];
193
-
194
- card.appendChild(img);
195
- card.appendChild(label);
196
- container.appendChild(card);
197
-
198
- log(`Screenshot ready: ${urls[i]}`);
199
- });
200
-
201
- status.textContent = "Screenshots captured successfully ✔";
202
- document.getElementById("downloadZip").style.display = "inline-block";
203
- log("All screenshots processed");
204
-
205
- } catch (err) {
206
- console.error(err);
207
- status.textContent = "❌ Error occurred";
208
- log("ERROR: " + err.message);
209
- }
210
- });
211
-
212
- document.getElementById("downloadZip").addEventListener("click", async () => {
213
- const zip = new JSZip();
214
- const status = document.getElementById("status");
215
 
216
- status.textContent = "Creating ZIP...";
217
- log("Starting ZIP generation");
 
 
 
 
 
 
 
 
218
 
219
- for (const item of screenshotData) {
220
- log(`Downloading image: ${item.url}`);
221
- const res = await fetch(item.image);
222
- const blob = await res.blob();
223
 
224
- const filename = item.url
225
- .replace(/^https?:\/\//, "")
226
- .replace(/[\/:?<>|"]/g, "_") + ".png";
227
 
228
- zip.file(filename, blob);
229
- }
230
 
231
- const zipBlob = await zip.generateAsync({ type: "blob" });
232
- const link = document.createElement("a");
 
233
 
234
- link.href = URL.createObjectURL(zipBlob);
235
- link.download = "screenshots.zip";
236
- link.click();
237
 
238
- status.textContent = "ZIP downloaded ✔";
239
- log("ZIP download completed");
240
- });
241
  </script>
242
 
243
  </body>
 
2
  <html lang="en">
3
  <head>
4
  <meta charset="UTF-8">
5
+ <title>Static Screenshot Tool (HF Compatible)</title>
6
 
7
  <style>
8
  body {
 
10
  max-width: 1100px;
11
  margin: 20px auto;
12
  padding: 20px;
13
+ background: #f4f6f8;
14
  }
15
 
16
+ textarea, input, button {
 
 
17
  width: 100%;
 
 
 
 
 
 
 
18
  padding: 10px;
19
  margin-top: 10px;
20
  }
 
23
  cursor: pointer;
24
  }
25
 
 
 
 
 
 
26
  #screenshots {
27
  margin-top: 25px;
28
  display: grid;
 
50
 
51
  #logs {
52
  margin-top: 20px;
53
+ background: #111827;
54
  color: #e5e7eb;
55
  padding: 10px;
56
+ height: 180px;
57
  overflow-y: auto;
58
  font-family: monospace;
59
  font-size: 12px;
60
  border-radius: 6px;
61
  }
 
 
 
 
 
 
 
 
 
62
  </style>
63
  </head>
64
 
65
  <body>
66
 
67
+ <h1>Static Screenshot Tool</h1>
 
 
 
68
 
69
+ <textarea id="urlInput" placeholder="Paste URLs (one per line)"></textarea>
70
 
 
71
  <input type="file" id="fileInput" accept=".txt">
72
 
73
+ <button onclick="start()">Capture Screenshots</button>
 
 
 
 
74
 
 
75
  <div id="screenshots"></div>
76
 
77
+ <h3>Logs</h3>
78
  <div id="logs"></div>
79
 
80
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
81
 
82
  <script>
83
+ const ACCESS_KEY = "YOUR_SCREENSHOTONE_API_KEY"; // exposed but required in static
84
 
85
+ let screenshots = [];
86
 
87
+ function log(msg) {
88
+ const l = document.getElementById("logs");
89
+ l.innerHTML += `[${new Date().toLocaleTimeString()}] ${msg}<br>`;
90
+ l.scrollTop = l.scrollHeight;
91
  }
92
 
93
+ async function start() {
94
+ document.getElementById("screenshots").innerHTML = "";
 
 
 
 
 
 
 
95
  document.getElementById("logs").innerHTML = "";
96
+ screenshots = [];
97
 
98
  let urls = [];
99
 
100
+ const text = document.getElementById("urlInput").value.trim();
101
+ const file = document.getElementById("fileInput").files[0];
102
+
103
+ if (text) {
 
 
104
  urls = text.split(/\r?\n/).map(u => u.trim()).filter(Boolean);
105
+ log("Using textarea URLs");
106
+ } else if (file) {
107
+ const content = await file.text();
108
+ urls = content.split(/\r?\n/).map(u => u.trim()).filter(Boolean);
109
+ log("Using file URLs");
110
  } else {
111
+ alert("Add URLs first");
112
  return;
113
  }
114
 
115
+ log(`Total URLs: ${urls.length}`);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
 
117
+ urls.forEach(url => {
118
+ const imgUrl =
119
+ "https://api.screenshotone.com/take" +
120
+ "?access_key=" + ACCESS_KEY +
121
+ "&url=" + encodeURIComponent(url) +
122
+ "&viewport_width=1280" +
123
+ "&viewport_height=1024" +
124
+ "&full_page=true" +
125
+ "&block_ads=true" +
126
+ "&block_cookie_banners=true";
127
 
128
+ screenshots.push({ url, imgUrl });
 
 
 
129
 
130
+ const card = document.createElement("div");
131
+ card.className = "card";
 
132
 
133
+ const img = document.createElement("img");
134
+ img.src = imgUrl;
135
 
136
+ const label = document.createElement("div");
137
+ label.className = "url";
138
+ label.textContent = url;
139
 
140
+ card.appendChild(img);
141
+ card.appendChild(label);
142
+ document.getElementById("screenshots").appendChild(card);
143
 
144
+ log("Loaded: " + url);
145
+ });
146
+ }
147
  </script>
148
 
149
  </body>