forked from lirix360/ReadmangaGrabber
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
318 lines (291 loc) · 16.3 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
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
<!doctype html>
<html lang="ru">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,400;0,700;1,400;1,700&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@300&display=swap" rel="stylesheet">
<title>Manga Grabber</title>
<style>
html {
padding: 0;
margin: 0;
}
body {
padding: 10px;
font-family: 'Roboto', sans-serif;
}
.log {
font-family: 'Roboto Mono', monospace;
font-size: 0.8rem;
}
</style>
</head>
<body>
<div class="container">
<div class="card border-secondary">
<div class="card-header text-white bg-secondary">
Manga Grabber
<div class="float-end" data-bs-toggle="modal" data-bs-target="#optionsModal"><i class="bi bi-gear" style="cursor: pointer;" data-bs-toggle="tooltip" data-bs-placement="left" title="Настройки утилиты"></i></div>
</div>
<div class="card-body bg-transparent">
<p>Manga Grabber - утилита для скачивания манги с ресурсов ReadManga, MintManga, SelfManga и MangaLib.</p>
<hr />
<form>
<div id="optionsSection">
<div class="mb-3">
<label for="mangaURL" class="form-label">Настройки скачивания</label><br />
<div class="form-check form-check-inline form-switch">
<input class="form-check-input opt-data" type="checkbox" id="optPDF" onchange="checkDeleteOption();">
<label class="form-check-label" for="optPDF">Создать PDF</label>
</div>
<div class="form-check form-check-inline form-switch">
<input class="form-check-input opt-data" type="checkbox" id="optCBZ" onchange="checkDeleteOption();">
<label class="form-check-label" for="optCBZ">Создать CBZ</label>
</div>
<div class="form-check form-check-inline form-switch">
<input class="form-check-input opt-data" type="checkbox" id="optDEL" disabled>
<label class="form-check-label" for="optDEL">Удалить скачанные файлы после создания PDF/CBZ</label>
</div>
</div>
<div class="mb-3">
<label for="mangaURL" class="form-label">Адрес манги</label>
<input type="text" class="form-control opt-data" id="mangaURL" required>
<div id="mangaURLHelp" class="form-text">Адрес страницы со списком глав (например: https://readmanga.live/the_disappearance_of_yuki_nagato или https://mangalib.me/kinjo-no-nanako-san)</div>
</div>
<div class="mb-3" style="text-align: center;">
<button type="button" class="btn btn-primary opt-data" id="getChaptersListBtn" onclick="getChaptersList();">Получить список глав</button>
<button type="button" class="btn btn-success opt-data" id="downloadAllChaptersBtn" onclick="downloadManga('all');">Скачать все главы</button>
</div>
</div>
<div id="waitSection" style="display: none;">
<hr />
<div class="text-center">
<div class="spinner-border text-info" role="status">
<span class="visually-hidden">Идет загрузка...</span>
</div>
</div>
</div>
<div id="errorSection" style="display: none;">
<hr />
<div class="alert alert-danger" id="errorData" role="alert"></div>
</div>
<div id="successSection" style="display: none;">
<hr />
<div class="alert alert-success" id="successData" role="alert"></div>
</div>
<div id="chaptersSection" style="display: none;">
<hr />
<div class="mb-3">
<label for="formFile" class="form-label">Скачать главы:</label>
<div class="row row-cols-4" id="chaptersList"></div>
</div>
<div class="mb-3" style="text-align: center;">
<button type="button" class="btn btn-success" id="downloadSelectedChaptersBtn" onclick="downloadManga('chapters');">Скачать выбранные главы</button>
</div>
</div>
<div id="downloadSection" style="display: none;">
<hr />
<div class="mb-3">
<p>Идет скачивание:</p>
<div class="progress">
<div class="progress-bar progress-bar-striped bg-info progress-bar-animated" id="progressBar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%; height: 20px;"></div>
</div>
</div>
<div class="mb-3">
<div class="card card-body log" id="log" style="max-height: 250px; overflow-y: auto;"></div>
</div>
</div>
</form>
</div>
</div>
</div>
<div class="modal" tabindex="-1" id="optionsModal" data-bs-backdrop="static" data-bs-keyboard="false">
<div class="modal-dialog modal-lg modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h6 class="modal-title" id="exampleModalLabel" style="font-weight: bold;">Настройки утилиты</h6>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
<form id="optionsForm">
<div class="mb-3">
<label for="optSavePath" class="form-label">Папка для скачивания манги</label>
<input type="text" class="form-control opt-data" id="optSavePath" required>
<div id="optSavePathHelp" class="form-text">Путь к папке для скачивания манги (например: Manga/ или D:/Downloads/MyManga/)</div>
</div>
<hr />
<p><b>ReadManga (MintManga, SelfManga)</b></p>
<div class="row">
<div class="col">
<label for="optRMChPause" class="form-label">Пауза между главами</label>
<input type="text" class="form-control flData" id="optRMChPause">
<div id="optRMChPauseHelp" class="form-text">Секунд. Не рекомендуется менее 0.5 сек.</div>
</div>
<div class="col">
<label for="optRMFilePause" class="form-label">Пауза между файлами</label>
<input type="text" class="form-control flData" id="optRMFilePause">
<div id="optRMFilePauseHelp" class="form-text">Секунд. Не рекомендуется менее 0.3 сек.</div>
</div>
</div>
<hr />
<p><b>MangaLib</b></p>
<div class="row">
<div class="col">
<label for="optMLChPause" class="form-label">Пауза между главами</label>
<input type="text" class="form-control flData" id="optMLChPause">
<div id="optMLChPauseHelp" class="form-text">Секунд. Не рекомендуется менее 1 сек.</div>
</div>
<div class="col">
<label for="optMLFilePause" class="form-label">Пауза между файлами</label>
<input type="text" class="form-control flData" id="optMLFilePause">
<div id="optMLFilePauseHelp" class="form-text">Секунд. Не рекомендуется менее 0.5 сек.</div>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-success btn-sm" onclick="SaveConfig();">Сохранить</button>
<button type="button" class="btn btn-secondary btn-sm" data-bs-dismiss="modal">Отменить</button>
</div>
</div>
</div>
</div>
<script>
var ws = new WebSocket("ws://127.0.0.1:8888/ws");
ws.onmessage = function(msg) {
var data = JSON.parse(msg.data);
console.log(data);
switch (data.cmd) {
case 'closeApp':
window.close();
break;
case 'initProgress':
$('#chaptersSection').hide();
$('#log').html('');
$('#progressBar').prop("aria-valuenow", data.payload.valNow)
$('#progressBar').prop("aria-valuemax", data.payload.valMax)
$('#progressBar').css("width", data.payload.width+"%")
$('#downloadSection').show();
break;
case 'updateProgress':
$('#progressBar').prop("aria-valuenow", data.payload.valNow)
$('#progressBar').css("width", data.payload.width+"%")
break;
case 'updateLog':
if (data.payload.type == "err") {
$('#log').append('<span style="color: red;">' + data.payload.text + '</span><br />')
} else {
$('#log').append(data.payload.text + '<br />')
}
//var elem = document.getElementById('log');
$('#log').scrollTop = elem.scrollHeight;
break;
case 'downloadComplete':
$('#downloadSection').hide();
$('#successData').html(data.payload.text);
$('#successSection').show();
break;
}
}
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl)
})
window.addEventListener("beforeunload", function (e) {
$.get("/closeApp");
return null;
});
$('#optionsModal').on('shown.bs.modal', function () {
LoadConfig();
})
function LoadConfig() {
$.get("/loadConfig", function(data) {
$('#optSavePath').val(data.savepath);
$('#optRMChPause').val(data.readmanga.timeout_chapter / 1000);
$('#optRMFilePause').val(data.readmanga.timeout_image / 1000);
$('#optMLChPause').val(data.mangalib.timeout_chapter / 1000);
$('#optMLFilePause').val(data.mangalib.timeout_image / 1000);
});
}
function SaveConfig() {
var optRMChPause = $('#optRMChPause').val();
var optRMFilePause = $('#optRMFilePause').val();
var optMLChPause = $('#optMLChPause').val();
var optMLFilePause = $('#optMLFilePause').val();
$.get("/saveConfig", {
"savepath": $('#optSavePath').val(),
"readmanga_timeout_chapter": optRMChPause.replace(',', '.') * 1000,
"readmanga_timeout_image": optRMFilePause.replace(',', '.') * 1000,
"mangalib_timeout_chapter": optMLChPause.replace(',', '.') * 1000,
"mangalib_timeout_image": optMLFilePause.replace(',', '.') * 1000
}, function(data) {
$('#optionsModal').modal('hide');
});
}
function checkDeleteOption() {
if ($('#optPDF').is(':checked') || $('#optCBZ').is(':checked')) {
$('#optDEL').prop("disabled", false);
} else {
$('#optDEL').prop("disabled", true);
}
}
function getChaptersList() {
$('.opt-data').prop('disabled', true);
$('#downloadSection').hide();
$('#successSection').hide();
$('#chaptersSection').hide();
$('#errorSection').hide();
$('#waitSection').show();
$('#chaptersList').html("");
$.get("/getChaptersList", { "mangaURL": $('#mangaURL').val() }, function(data) {
switch (data.status) {
case 'success':
$.each(data.payload, function(i, item) {
var html = "<div class='col'><div class='form-check'><input class='form-check-input single-chapter' type='checkbox' id='"+item.path+"' value='"+item.path+"'><label class='form-check-label' for='"+item.path+"'>"+item.title+"</label></div></div>";
$('#chaptersList').append(html);
});
$('#waitSection').hide();
$('#chaptersSection').show();
break;
case 'error':
$('#errorData').html(data.payload);
$('#waitSection').hide();
$('#errorSection').show();
break;
}
});
$('.opt-data').prop('disabled', false);
checkDeleteOption();
}
function downloadManga(type) {
$('#downloadSection').hide();
$('#successSection').hide();
$('#chaptersSection').hide();
var optPDF = $('#optPDF').is(':checked') ? 1 : 0;
var optCBZ = $('#optCBZ').is(':checked') ? 1 : 0;
var optDEL = ($('#optPDF').is(':checked') || $('#optCBZ').is(':checked')) && $('#optDEL').is(':checked') ? 1 : 0;
var chapters = [];
if (type == 'chapters') {
$('.single-chapter:checked').each(function() {
chapters.push($(this).val());
});
}
var chaptersJSON = JSON.stringify(chapters);
$.get("/downloadManga", {
"downloadType": type,
"mangaURL": $('#mangaURL').val(),
"optPDF": optPDF,
"optCBZ": optCBZ,
"optDEL": optDEL,
"selectedChapters": chaptersJSON
}, function(data) {});
}
</script>
</body>
</html>