Spaces:
Sleeping
Sleeping
DmitrMakeev
commited on
Commit
•
3774d8e
1
Parent(s):
1716b93
Create se_mes_im2.html
Browse files- se_mes_im2.html +115 -106
se_mes_im2.html
CHANGED
@@ -3,8 +3,7 @@
|
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
-
<title>
|
7 |
-
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/toastify-js/src/toastify.min.css">
|
8 |
<style>
|
9 |
body {
|
10 |
font-family: Arial, sans-serif;
|
@@ -20,136 +19,146 @@
|
|
20 |
margin: 0;
|
21 |
border-bottom: 2px solid #388E3C;
|
22 |
}
|
23 |
-
|
24 |
-
color: white;
|
25 |
-
background-color: #4CAF50;
|
26 |
-
border: none;
|
27 |
-
cursor: pointer;
|
28 |
-
padding: 10px 20px;
|
29 |
-
font-size: 16px;
|
30 |
-
border-radius: 5px;
|
31 |
-
margin-top: 20px;
|
32 |
-
}
|
33 |
-
button[type="submit"]:hover {
|
34 |
-
background-color: #388E3C;
|
35 |
-
}
|
36 |
-
#mediaContainer {
|
37 |
-
margin-top: 20px;
|
38 |
display: flex;
|
39 |
justify-content: center;
|
40 |
-
|
41 |
-
|
42 |
-
max-width: 100%;
|
43 |
-
height: auto;
|
44 |
}
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
|
|
49 |
}
|
50 |
-
#
|
|
|
51 |
margin-top: 20px;
|
52 |
-
font-size: 16px;
|
53 |
-
color: #333;
|
54 |
-
cursor: pointer;
|
55 |
-
text-decoration: underline;
|
56 |
}
|
57 |
#progressBarContainer {
|
58 |
width: 80%;
|
59 |
margin: 20px auto;
|
60 |
-
background-color: #ddd;
|
61 |
-
border-radius: 13px;
|
62 |
-
padding: 3px;
|
63 |
}
|
64 |
#progressBar {
|
|
|
|
|
|
|
|
|
65 |
width: 0%;
|
66 |
-
height:
|
67 |
background-color: #4CAF50;
|
68 |
-
border-radius: 10px;
|
69 |
text-align: center;
|
70 |
-
line-height:
|
71 |
color: white;
|
72 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
</style>
|
74 |
</head>
|
75 |
<body>
|
76 |
-
<h1
|
77 |
-
<div
|
78 |
-
|
|
|
|
|
79 |
</div>
|
|
|
80 |
<div id="progressBarContainer">
|
81 |
-
<div id="progressBar">
|
|
|
|
|
82 |
</div>
|
83 |
-
<
|
84 |
-
<
|
85 |
-
|
86 |
-
<button type="submit">Upload</button>
|
87 |
-
</form>
|
88 |
-
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/toastify-js"></script>
|
89 |
<script>
|
90 |
-
document.getElementById('
|
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 |
-
function
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
}
|
137 |
}
|
138 |
-
function copyToClipboard(element) {
|
139 |
-
var tempInput = document.createElement("input");
|
140 |
-
tempInput.value = element.innerText;
|
141 |
-
document.body.appendChild(tempInput);
|
142 |
-
tempInput.select();
|
143 |
-
document.execCommand("copy");
|
144 |
-
document.body.removeChild(tempInput);
|
145 |
-
Toastify({
|
146 |
-
text: "URL copied to clipboard",
|
147 |
-
duration: 3000,
|
148 |
-
gravity: "top",
|
149 |
-
position: "center",
|
150 |
-
backgroundColor: "#4CAF50",
|
151 |
-
}).showToast();
|
152 |
-
}
|
153 |
</script>
|
154 |
</body>
|
155 |
</html>
|
|
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>Send Messages with Image</title>
|
|
|
7 |
<style>
|
8 |
body {
|
9 |
font-family: Arial, sans-serif;
|
|
|
19 |
margin: 0;
|
20 |
border-bottom: 2px solid #388E3C;
|
21 |
}
|
22 |
+
.input-row {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
display: flex;
|
24 |
justify-content: center;
|
25 |
+
gap: 10px;
|
26 |
+
margin-top: 20px;
|
|
|
|
|
27 |
}
|
28 |
+
.input-row input, .input-row textarea {
|
29 |
+
padding: 10px;
|
30 |
+
font-size: 16px;
|
31 |
+
border: 1px solid #ccc;
|
32 |
+
border-radius: 5px;
|
33 |
}
|
34 |
+
#messageInput {
|
35 |
+
width: 80%;
|
36 |
margin-top: 20px;
|
|
|
|
|
|
|
|
|
37 |
}
|
38 |
#progressBarContainer {
|
39 |
width: 80%;
|
40 |
margin: 20px auto;
|
|
|
|
|
|
|
41 |
}
|
42 |
#progressBar {
|
43 |
+
width: 100%;
|
44 |
+
background-color: #ddd;
|
45 |
+
}
|
46 |
+
#progress {
|
47 |
width: 0%;
|
48 |
+
height: 30px;
|
49 |
background-color: #4CAF50;
|
|
|
50 |
text-align: center;
|
51 |
+
line-height: 30px;
|
52 |
color: white;
|
53 |
}
|
54 |
+
#sendButton {
|
55 |
+
color: white;
|
56 |
+
background-color: #4CAF50;
|
57 |
+
border: none;
|
58 |
+
cursor: pointer;
|
59 |
+
padding: 10px 20px;
|
60 |
+
font-size: 16px;
|
61 |
+
border-radius: 5px;
|
62 |
+
margin-top: 20px;
|
63 |
+
}
|
64 |
+
#sendButton:hover {
|
65 |
+
background-color: #388E3C;
|
66 |
+
}
|
67 |
</style>
|
68 |
</head>
|
69 |
<body>
|
70 |
+
<h1>Отправка сообщения с картинкой</h1>
|
71 |
+
<div class="input-row">
|
72 |
+
<input type="text" id="apiKeyInput" placeholder="Введите API ключ">
|
73 |
+
<input type="number" id="minDelayInput" placeholder="Min Delay (ms)" value="500">
|
74 |
+
<input type="number" id="maxDelayInput" placeholder="Max Delay (ms)" value="1000">
|
75 |
</div>
|
76 |
+
<textarea id="messageInput" placeholder="Введите текст сообщения с картинкой."></textarea>
|
77 |
<div id="progressBarContainer">
|
78 |
+
<div id="progressBar">
|
79 |
+
<div id="progress">0%</div>
|
80 |
+
</div>
|
81 |
</div>
|
82 |
+
<input type="file" id="fileInput" accept=".txt">
|
83 |
+
<button id="sendButton">Запустить рассылку</button>
|
84 |
+
|
|
|
|
|
|
|
85 |
<script>
|
86 |
+
document.getElementById('sendButton').addEventListener('click', function() {
|
87 |
+
const apiKey = document.getElementById('apiKeyInput').value;
|
88 |
+
const urlFile = localStorage.getItem('fileUrl');
|
89 |
+
const fileName = localStorage.getItem('filename');
|
90 |
+
const message = document.getElementById('messageInput').value;
|
91 |
+
const minDelay = parseInt(document.getElementById('minDelayInput').value) || 500;
|
92 |
+
const maxDelay = parseInt(document.getElementById('maxDelayInput').value) || 10000;
|
93 |
+
if (!apiKey) {
|
94 |
+
alert('Please enter your API key.');
|
95 |
+
return;
|
96 |
+
}
|
97 |
+
if (!urlFile) {
|
98 |
+
alert('URL of the file is not found in local storage.');
|
99 |
+
return;
|
100 |
+
}
|
101 |
+
if (!fileName) {
|
102 |
+
alert('File name is not found in local storage.');
|
103 |
+
return;
|
104 |
+
}
|
105 |
+
if (!message) {
|
106 |
+
alert('Please enter a message.');
|
107 |
+
return;
|
108 |
+
}
|
109 |
+
if (minDelay >= maxDelay) {
|
110 |
+
alert('Min delay must be less than max delay.');
|
111 |
+
return;
|
112 |
+
}
|
113 |
+
const fileInput = document.getElementById('fileInput');
|
114 |
+
const file = fileInput.files[0];
|
115 |
+
if (!file) {
|
116 |
+
alert('Please select a file.');
|
117 |
+
return;
|
118 |
+
}
|
119 |
+
const reader = new FileReader();
|
120 |
+
reader.onload = function(event) {
|
121 |
+
const text = event.target.result;
|
122 |
+
const phones = text.split('\n').map(phone => phone.trim()).filter(phone => phone);
|
123 |
+
sendMessages(phones, apiKey, urlFile, fileName, message, minDelay, maxDelay);
|
124 |
+
};
|
125 |
+
reader.readAsText(file);
|
126 |
});
|
127 |
+
async function sendMessages(phones, apiKey, urlFile, fileName, message, minDelay, maxDelay) {
|
128 |
+
const totalPhones = phones.length;
|
129 |
+
const progressBar = document.getElementById('progress');
|
130 |
+
for (let i = 0; i < totalPhones; i++) {
|
131 |
+
const phone = phones[i];
|
132 |
+
try {
|
133 |
+
const response = await fetch(`https://api.green-api.com/waInstance1101952913/sendFileByUrl/${apiKey}`, {
|
134 |
+
method: 'POST',
|
135 |
+
headers: {
|
136 |
+
'Content-Type': 'application/json'
|
137 |
+
},
|
138 |
+
body: JSON.stringify({
|
139 |
+
chatId: `${phone}@c.us`,
|
140 |
+
urlFile: urlFile,
|
141 |
+
fileName: fileName,
|
142 |
+
caption: message
|
143 |
+
})
|
144 |
+
});
|
145 |
+
if (!response.ok) {
|
146 |
+
throw new Error(`HTTP error! status: ${response.status}`);
|
147 |
+
}
|
148 |
+
const data = await response.json();
|
149 |
+
console.log(`Message sent to ${phone}:`, data);
|
150 |
+
} catch (error) {
|
151 |
+
console.error(`Error sending message to ${phone}:`, error);
|
152 |
+
}
|
153 |
+
const progress = ((i + 1) / totalPhones) * 100;
|
154 |
+
progressBar.style.width = `${progress}%`;
|
155 |
+
progressBar.textContent = `${progress.toFixed(2)}%`;
|
156 |
+
if (i < totalPhones - 1) {
|
157 |
+
const randomDelay = Math.floor(Math.random() * (maxDelay - minDelay + 1)) + minDelay;
|
158 |
+
await new Promise(resolve => setTimeout(resolve, randomDelay));
|
159 |
+
}
|
160 |
}
|
161 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
</script>
|
163 |
</body>
|
164 |
</html>
|