File size: 4,303 Bytes
1b4ea06
 
 
 
a7423bc
1b4ea06
 
7e756a1
 
 
 
 
52faf17
7e756a1
 
52faf17
7e756a1
 
 
 
 
 
 
 
 
a7423bc
 
 
 
 
 
 
 
 
7e756a1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52faf17
7e756a1
 
52faf17
7e756a1
 
 
 
 
1b4ea06
 
 
 
 
52faf17
1b4ea06
52faf17
7e756a1
1b4ea06
52faf17
a7423bc
7e756a1
1b4ea06
 
52faf17
7e756a1
 
1b4ea06
 
 
a7423bc
1b4ea06
52faf17
a7423bc
1b4ea06
52faf17
 
 
 
7e756a1
 
52faf17
 
7e756a1
a7423bc
 
52faf17
a7423bc
7e756a1
 
 
52faf17
 
 
 
7e756a1
52faf17
 
 
 
 
7e756a1
52faf17
1b4ea06
 
 
52faf17
1b4ea06
52faf17
 
 
 
 
 
 
 
 
 
1b4ea06
52faf17
1b4ea06
52faf17
 
1b4ea06
52faf17
 
1b4ea06
a7423bc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52faf17
 
 
1b4ea06
52faf17
 
 
 
 
a7423bc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1b4ea06
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Static Screenshot Tool (ZIP Download)</title>

<style>
body {
  font-family: Arial, sans-serif;
  max-width: 1100px;
  margin: 20px auto;
  padding: 20px;
  background: #f4f6f8;
}

textarea, input, button {
  width: 100%;
  padding: 10px;
  margin-top: 10px;
}

button {
  cursor: pointer;
}

#downloadZip {
  display: none;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 4px;
  margin-top: 15px;
}

#screenshots {
  margin-top: 25px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 15px;
}

.card {
  background: #fff;
  padding: 10px;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0,0,0,.1);
}

.card img {
  width: 100%;
  border-radius: 4px;
}

.url {
  font-size: 12px;
  word-break: break-all;
  margin-top: 5px;
}

#logs {
  margin-top: 20px;
  background: #111827;
  color: #e5e7eb;
  padding: 10px;
  height: 180px;
  overflow-y: auto;
  font-family: monospace;
  font-size: 12px;
  border-radius: 6px;
}
</style>
</head>

<body>

<h1>Static Screenshot Tool</h1>

<textarea id="urlInput" placeholder="Paste URLs (one per line)"></textarea>
<input type="file" id="fileInput" accept=".txt">

<button onclick="start()">Capture Screenshots</button>
<button id="downloadZip" onclick="downloadZip()">⬇ Download ZIP</button>

<div id="screenshots"></div>

<h3>Logs</h3>
<div id="logs"></div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>

<script>
const ACCESS_KEY = "BiY4yQ0EnzeZ5A";

let screenshots = [];
let loadedCount = 0;

function log(msg) {
  const l = document.getElementById("logs");
  l.innerHTML += `[${new Date().toLocaleTimeString()}] ${msg}<br>`;
  l.scrollTop = l.scrollHeight;
}

async function start() {
  document.getElementById("screenshots").innerHTML = "";
  document.getElementById("logs").innerHTML = "";
  document.getElementById("downloadZip").style.display = "none";

  screenshots = [];
  loadedCount = 0;

  let urls = [];

  const text = document.getElementById("urlInput").value.trim();
  const file = document.getElementById("fileInput").files[0];

  if (text) {
    urls = text.split(/\r?\n/).map(u => u.trim()).filter(Boolean);
    log("Using textarea URLs");
  } else if (file) {
    const content = await file.text();
    urls = content.split(/\r?\n/).map(u => u.trim()).filter(Boolean);
    log("Using file URLs");
  } else {
    alert("Add URLs first");
    return;
  }

  log(`Total URLs: ${urls.length}`);

  urls.forEach(url => {
    const imgUrl =
      "https://api.screenshotone.com/take" +
      "?access_key=" + ACCESS_KEY +
      "&url=" + encodeURIComponent(url) +
      "&viewport_width=1280" +
      "&viewport_height=1024" +
      "&full_page=true" +
      "&block_ads=true" +
      "&block_cookie_banners=true";

    screenshots.push({ url, imgUrl });

    const card = document.createElement("div");
    card.className = "card";

    const img = document.createElement("img");
    img.src = imgUrl;

    img.onload = () => {
      loadedCount++;
      log(`Screenshot loaded (${loadedCount}/${urls.length})`);

      if (loadedCount === urls.length) {
        log("All screenshots loaded ✔");
        document.getElementById("downloadZip").style.display = "block";
      }
    };

    img.onerror = () => {
      loadedCount++;
      log(`Failed to load: ${url}`);
    };

    const label = document.createElement("div");
    label.className = "url";
    label.textContent = url;

    card.appendChild(img);
    card.appendChild(label);
    document.getElementById("screenshots").appendChild(card);
  });
}

async function downloadZip() {
  log("Creating ZIP file...");
  const zip = new JSZip();

  for (const item of screenshots) {
    log("Fetching image: " + item.url);

    const res = await fetch(item.imgUrl);
    const blob = await res.blob();

    const filename = item.url
      .replace(/^https?:\/\//, "")
      .replace(/[\/:?<>|"]/g, "_") + ".png";

    zip.file(filename, blob);
  }

  const zipBlob = await zip.generateAsync({ type: "blob" });
  const link = document.createElement("a");

  link.href = URL.createObjectURL(zipBlob);
  link.download = "screenshots.zip";
  link.click();

  log("ZIP downloaded ✔");
}
</script>

</body>
</html>