-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
42 lines (34 loc) · 1.32 KB
/
index.js
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
function getScreenShot() {
const displaySect = document.getElementById("display");
const urlSc = new URL("https://screenshotapi.net/api/v1/screenshot");
// const tokenKeys = document.getElementById('apiKey').value;
const tokenKeys = 'Q5HAZETMQYJCKERKETGWQJC2QZSHIVJX '
const urlInfo = document.getElementById('url').value;
if (urlInfo !== '' && tokenKeys !== '') {
urlSc.searchParams.append('url', urlInfo);
urlSc.searchParams.append('token', tokenKeys);
fetch(urlSc, { method: 'POST' })
.then(data => {
return data.json()
})
.then(res => {
let imageHold = document.querySelector('a')
imageHold.href = res.screenshot;
imageHold.download;
imageHold.click();
setTimeout(() => {
window.location.href = 'index.html';
}, 5000)
})
.catch(err => console.log(err))
displaySect.innerHTML = "Your image will be downloaded any second from now... ";
}
else {
alert('Kindly provide the URL to screenshot');
}
}
const burger = document.getElementById('burger');
const ul = document.querySelector('nav ul');
burger.addEventListener('click', () => {
ul.classList.toggle('show');
})