DmitrMakeev
commited on
Commit
•
caf7759
1
Parent(s):
d1e7442
Update ver2.html
Browse files
ver2.html
CHANGED
@@ -35,7 +35,7 @@
|
|
35 |
line-height: 30px;
|
36 |
color: white;
|
37 |
}
|
38 |
-
#apiKeyInput, #messageInput, #fileInput, #sendButton {
|
39 |
margin-top: 20px;
|
40 |
padding: 10px;
|
41 |
font-size: 16px;
|
@@ -57,6 +57,8 @@
|
|
57 |
<h1>Send Messages</h1>
|
58 |
<input type="text" id="apiKeyInput" placeholder="Enter API Key">
|
59 |
<input type="text" id="messageInput" placeholder="Enter Message">
|
|
|
|
|
60 |
<div id="progressBarContainer">
|
61 |
<div id="progressBar">
|
62 |
<div id="progress">0%</div>
|
@@ -69,6 +71,9 @@
|
|
69 |
document.getElementById('sendButton').addEventListener('click', function() {
|
70 |
const apiKey = document.getElementById('apiKeyInput').value;
|
71 |
const message = document.getElementById('messageInput').value;
|
|
|
|
|
|
|
72 |
if (!apiKey) {
|
73 |
alert('Please enter your API key.');
|
74 |
return;
|
@@ -77,6 +82,10 @@
|
|
77 |
alert('Please enter a message.');
|
78 |
return;
|
79 |
}
|
|
|
|
|
|
|
|
|
80 |
|
81 |
const fileInput = document.getElementById('fileInput');
|
82 |
const file = fileInput.files[0];
|
@@ -89,12 +98,12 @@
|
|
89 |
reader.onload = function(event) {
|
90 |
const text = event.target.result;
|
91 |
const phones = text.split('\n').map(phone => phone.trim()).filter(phone => phone);
|
92 |
-
sendMessages(phones, apiKey, message,
|
93 |
};
|
94 |
reader.readAsText(file);
|
95 |
});
|
96 |
|
97 |
-
async function sendMessages(phones, apiKey, message,
|
98 |
const totalPhones = phones.length;
|
99 |
const progressBar = document.getElementById('progress');
|
100 |
const progressText = document.getElementById('progress').textContent;
|
@@ -127,7 +136,8 @@
|
|
127 |
progressBar.textContent = `${progress.toFixed(2)}%`;
|
128 |
|
129 |
if (i < totalPhones - 1) {
|
130 |
-
|
|
|
131 |
}
|
132 |
}
|
133 |
}
|
|
|
35 |
line-height: 30px;
|
36 |
color: white;
|
37 |
}
|
38 |
+
#apiKeyInput, #messageInput, #minDelayInput, #maxDelayInput, #fileInput, #sendButton {
|
39 |
margin-top: 20px;
|
40 |
padding: 10px;
|
41 |
font-size: 16px;
|
|
|
57 |
<h1>Send Messages</h1>
|
58 |
<input type="text" id="apiKeyInput" placeholder="Enter API Key">
|
59 |
<input type="text" id="messageInput" placeholder="Enter Message">
|
60 |
+
<input type="number" id="minDelayInput" placeholder="Min Delay (ms)">
|
61 |
+
<input type="number" id="maxDelayInput" placeholder="Max Delay (ms)">
|
62 |
<div id="progressBarContainer">
|
63 |
<div id="progressBar">
|
64 |
<div id="progress">0%</div>
|
|
|
71 |
document.getElementById('sendButton').addEventListener('click', function() {
|
72 |
const apiKey = document.getElementById('apiKeyInput').value;
|
73 |
const message = document.getElementById('messageInput').value;
|
74 |
+
const minDelay = parseInt(document.getElementById('minDelayInput').value) || 1000;
|
75 |
+
const maxDelay = parseInt(document.getElementById('maxDelayInput').value) || 5000;
|
76 |
+
|
77 |
if (!apiKey) {
|
78 |
alert('Please enter your API key.');
|
79 |
return;
|
|
|
82 |
alert('Please enter a message.');
|
83 |
return;
|
84 |
}
|
85 |
+
if (minDelay >= maxDelay) {
|
86 |
+
alert('Min delay must be less than max delay.');
|
87 |
+
return;
|
88 |
+
}
|
89 |
|
90 |
const fileInput = document.getElementById('fileInput');
|
91 |
const file = fileInput.files[0];
|
|
|
98 |
reader.onload = function(event) {
|
99 |
const text = event.target.result;
|
100 |
const phones = text.split('\n').map(phone => phone.trim()).filter(phone => phone);
|
101 |
+
sendMessages(phones, apiKey, message, minDelay, maxDelay);
|
102 |
};
|
103 |
reader.readAsText(file);
|
104 |
});
|
105 |
|
106 |
+
async function sendMessages(phones, apiKey, message, minDelay, maxDelay) {
|
107 |
const totalPhones = phones.length;
|
108 |
const progressBar = document.getElementById('progress');
|
109 |
const progressText = document.getElementById('progress').textContent;
|
|
|
136 |
progressBar.textContent = `${progress.toFixed(2)}%`;
|
137 |
|
138 |
if (i < totalPhones - 1) {
|
139 |
+
const randomDelay = Math.floor(Math.random() * (maxDelay - minDelay + 1)) + minDelay;
|
140 |
+
await new Promise(resolve => setTimeout(resolve, randomDelay));
|
141 |
}
|
142 |
}
|
143 |
}
|