forked from suzumiyahifumi/Fantia-Downloader-tampermonkey
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFantiaDownloader.js
965 lines (901 loc) · 48.2 KB
/
FantiaDownloader.js
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
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
/* jshint esversion: 9 */
// ==UserScript==
// @name Fantia downloader
// @name:en Fantia downloader
// @name:ja Fantia downloader
// @namespace http://tampermonkey.net/
// @version 3.1.9
// @description Download your Fantia rewards more easily!
// @description:en Download your Fantia rewards more easily!
// @description:ja Download your Fantia rewards more easily!
// @author suzumiyahifumi
// @include https://fantia.jp/posts/*
// @include https://fantia.jp/fanclubs/*/backnumbers*
// @icon https://www.google.com/s2/favicons?domain=fantia.jp
// @require https://cdn.jsdelivr.net/npm/@zip.js/[email protected]/dist/zip-full.min.js
// @grant GM_download
// ==/UserScript==
//log: 3.1.5 remove jQuery inject
(function () {
'use strict';
Date.prototype.Format = function (fmt) {
let o = {
"M+": this.getMonth() + 1,
"d+": this.getDate(),
"h+": this.getHours(),
"m+": this.getMinutes(),
"s+": this.getSeconds(),
"q+": Math.floor((this.getMonth() + 3) / 3),
"S": this.getMilliseconds()
};
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (let k in o)
if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
return fmt;
};
$('head').append(`<style type="text/css">
.fa-download2::before{
content: "\\f021"
}
.hdr{ pointer-events: none; }
.titleImage{
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAcwAAAA2CAYAAABKpalNAAAWGUlEQVR4nO1dPU/rytZ+7qtb0uQtKQMFPVuicqoQKspsyX8gCKVGpEwJSo0i8gcs4ZIKSEWqSDt9CnZKypOG/tzCy+CM19gz47HzNY+0dc7Oth1nzZr1NevjP3DYeTRaYQ1AG8Ds/bU9W/f7ODisG1/9izaAJ/pr76D/cr/O99lGDI8HTQB3AOoA7q8/bnaehv+37hdwKBeNVngK4A+ARwB/Gq3wcc2v5OCwCbhL/v9X/+J2bW+yvXgCcAqgBuBueDyor/l9SodTmLuP2AKM0Wm0wua6XsbBYd346l+cYnVP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OZdb3p3d5B+Es4XDynPqtHKj2qG6g8OJs2VMAi4w2U3EtHDdj7lwjrMWi0QrrWC3Gn72/tn+ZPIsyYlN0T2bNCten6H7Qf1GiexmgkFkNJQ84zwOFX7lwnQwzRB6E8pmONw3+UXy+TFnGz9Ed2DyiWjttEK/WNTO543u/95pqIfpX/6KJaB2+ocqfxEvaa2iacV22zFMYVTjGTxg2eV+KP64/bta2x/NAPNaGBp9kgVOYHCHLyCAsDVSrlAwdhYeT542ayUgjbJJW4BJRG6jCyT/UnLqN6Pcb903UBdVnrtD9oP+yUXRfFxKdWfIs8vvDybN279qM+YFJZCpLzWcBBZTluvDVv+jgJ5ozovN3JZDSVFrDAv2HjWAi88jAj2d9xtnlIaIyOtaIoXvehI/PTRyMbQSnMDmCbJXCBL4ZqI0oLX/jiqATyRMxo/4u6l1uAkhptgEsD/ovG0f3dYMSfGJBFSMOpY9Me81mRC0AKtfQ6Z6S42kuEYVht3J9iUdrOQMFpKAEH+kalphElokqZB5F4EQ+y+qAtlNgXWnBy1wCOFpj5xMHBwcFSJTcDEKCj8bzYgH8HdoGMNtWRelgB8PjgXhs18tq7LJLkMaeyYqqIbKYnLJ0cNgCkNLsgIYcO+XmYBvD44E43Se8/rjZi6MXaS/ZslPuHRwc7IMyDPfC2ndYG8SuRBtRv18FNrXTj4ODg4PDZuIeP+UaY+yRgfY/wDKD0FiMfk4AAAAASUVORK5CYII=");
background-repeat: no-repeat;
background-position: center;
background-size: 200px;
}
#settingCenter{
position: fixed;
z-index: 9999;
width: 50px;
height: 50px;
left: 50px;
top: calc(100vh - 100px);
border-style: solid;
border-color: #c3c3c345;
border-width: thin;
border-radius: 50px;
color: #c3c3c345;
padding: 10px 20px;
cursor: pointer;
transition: border-color 0.8s;
transition: box-shadow 0.5s;
box-shadow: 0 0 10px #000;
font-size: 3em;
backdrop-filter: blur(5px);
background-image: url("data:image/svg+xml;charset=UTF-8,<svg enable-background='new 0 0 24 24' height='512' viewBox='0 0 24 24' width='512' xmlns='http://www.w3.org/2000/svg'><path d='m22.683 9.394-1.88-.239c-.155-.477-.346-.937-.569-1.374l1.161-1.495c.47-.605.415-1.459-.122-1.979l-1.575-1.575c-.525-.542-1.379-.596-1.985-.127l-1.493 1.161c-.437-.223-.897-.414-1.375-.569l-.239-1.877c-.09-.753-.729-1.32-1.486-1.32h-2.24c-.757 0-1.396.567-1.486 1.317l-.239 1.88c-.478.155-.938.345-1.375.569l-1.494-1.161c-.604-.469-1.458-.415-1.979.122l-1.575 1.574c-.542.526-.597 1.38-.127 1.986l1.161 1.494c-.224.437-.414.897-.569 1.374l-1.877.239c-.753.09-1.32.729-1.32 1.486v2.24c0 .757.567 1.396 1.317 1.486l1.88.239c.155.477.346.937.569 1.374l-1.161 1.495c-.47.605-.415 1.459.122 1.979l1.575 1.575c.526.541 1.379.595 1.985.126l1.494-1.161c.437.224.897.415 1.374.569l.239 1.876c.09.755.729 1.322 1.486 1.322h2.24c.757 0 1.396-.567 1.486-1.317l.239-1.88c.477-.155.937-.346 1.374-.569l1.495 1.161c.605.47 1.459.415 1.979-.122l1.575-1.575c.542-.526.597-1.379.127-1.985l-1.161-1.494c.224-.437.415-.897.569-1.374l1.876-.239c.753-.09 1.32-.729 1.32-1.486v-2.24c.001-.757-.566-1.396-1.316-1.486zm-10.683 7.606c-2.757 0-5-2.243-5-5s2.243-5 5-5 5 2.243 5 5-2.243 5-5 5z'/></svg>");
background-size: 30px;
background-repeat: no-repeat;
background-position: center;
}
#settingCenter:hover{
border-color: #c3c3c370;
color: #c3c3c370;
box-shadow: 0px 0px 20px #000;
}
#settingCenter:active{
border-color: #fe7070;
color: #fe7070;
}
#settingCenter:after {
content: '';
display: block;
position: absolute;
width: 50px;
height: 50px;
top: 0;
left: 0;
border-radius: 50px;
pointer-events: none;
background-image: radial-gradient(circle, #fe7070 10%, transparent 10.01%);
background-repeat: no-repeat;
background-position: 50%;
transform: scale(10, 10);
opacity: 0;
transition: transform .5s, opacity .5s;
}
#settingCenter:active:after {
transform: scale(0, 0);
opacity: .3;
transition: 0s;
}
.close {
display: none;
}
.unBlur {
background-color: #adadaded !important;
backdrop-filter: blur(0px) !important;
}
#settingCenterDiv{
position: fixed;
z-index: 9999;
width: 500px;
height: 90vh;
left: calc(50vw - 250px);
top: 5vh;
background-color: #9090907d;
border-radius: 15px;
backdrop-filter: blur(15px);
box-shadow: 0 0 10px #000;
text-align: center;
margin: 0 auto;
overflow: auto;
min-height: 450px;
}
.settingCenterButton:hover {
border-bottom-style: groove;
border-bottom-color: #fff;
}
.settingCenterButton:active {
border-bottom-style: none;
border-bottom-color: #fff0;
}
#cookieOn:checked ~ #cookieOnLabel {
background-color: #fff;
}
#cookieOff:checked ~ #cookieOffLabel {
background-color: #fff;
}
#generalSave:checked ~ #generalSaveLabel {
background-color: #fff;
}
#authorSave:checked ~ #authorSaveLabel {
background-color: #fff;
}
#paramsTable table {
width: 100%;
height: 100%;
}
#paramsTable th{
text-align: center;
}
#paramsTable table, #paramsTable td {
border: 1px solid #fff0;
}
#paramsTable thead, #paramsTable tfoot {
background-color: #fff0;
color: #fff;
}
</style>`);
$('nav.scroll-tabs>div').append(`<a id="set" class="tab-item tab-item-text set-FD" style="cursor: pointer;" onclick="JAVASCRIPT:getDownLoadButton()">擷取下載</a>`);
let windowSetting;
let init = setInterval(() => {
let pageType = (window.location.href.match(/https:\/\/fantia\.jp\/posts\/*/g) != null) ? `post` : `backnumber`;
let post = (pageType == "backnumber") ? 1 : $(`.the-post`).length;
if (windowSetting) {
var postContent = (windowSetting.metaData.content == undefined || windowSetting.metaData.content.length == 0) ? true : false;
} else {
windowSetting = new Setting();
}
if (($(`div[id^='post-content-id-']`).length != 0 || postContent) && post != 0) {
// for nonImgbox
$(`div.image-thumbnails`).each((i, div) => {
let b = $(div).closest('div.content-block').find(`div.text-center > div.btn-group-tabs`);
if (b.length == 0) $(div).before(`<div ng-if="$ctrl.isVisibleAndMulti()" class="ng-scope"><div class="text-center"><div class="btn-group btn-group-tabs mb-20" role="group"></div></div></div>`);
});
// for single image
$(`a.fantiaImage`).each((i, div) => {
$(div).before(`<div ng-if="$ctrl.isVisibleAndMulti()" class="ng-scope blogBox" blog-img-index="${$(div).attr("data-id")}"><div class="text-center"><div class="btn-group btn-group-tabs mb-20" role="group"></div></div></div>`);
});
// for post
$(`.the-post .post-thumbnail .img-default`).closest(`div.post-thumbnail`).before(`<div ng-if="$ctrl.isVisibleAndMulti()" class="ng-scope"><div class="text-center"><div class="btn-group btn-group-tabs mb-20" role="group"></div></div></div>`);
// make sure the button has been inserted before stopping interval.
if ($(`div[role="group"]`).length) {
getDownLoadButton();
handleInteractions();
clearInterval(init);
}
}
}, 500);
class Setting {
constructor() {
this.pageType = (window.location.href.match(/https:\/\/fantia\.jp\/posts\/*/g) != null) ? `post` : `backnumber`;
let qs = new URLSearchParams((this.pageType == `post`) ? `` : (window.location.search == ``) ? $(`div.text-center>a.active`).attr("href").split("?")[1] : window.location.search);
this.jsonUrl = `https://fantia.jp/api/v1/${(this.pageType == `post`) ? `posts/${window.location.href.split("/").pop()}` : `fanclub/backnumbers/monthly_contents/plan/${qs.get("plan")}/month/${qs.get("month")}`}`;
let authorId = $("h1.fanclub-name>a").attr(`href`).split("/").pop();
const keyArr = [`cookieSave`, `lang`, `authorId_${authorId}`, `generalSaveZIP`, `generalSaveFile`, `authorSaveZIP_${authorId}`, `authorSaveFile_${authorId}`, `dateFormat`];
this.cookieOri = document.cookie;
this.cookie = this.cookieParser(keyArr);
this.cookieSave = this.cookie.cookieSave || this.defaultCookie(`cookieSave`);
this.setCookie({
cookieSave: this.cookieSave,
lang: (this.cookieSave == `On`) ? this.cookie.lang : this.getOriLang(),
generalSave: this.defaultCookie(`generalSave`),
authorSave: this.defaultCookie(`authorSave`),
authorSaveCheck: this.cookie[`authorId_${authorId}`] || this.defaultCookie(`authorSaveCheck`),
authorId: authorId,
dateFormat: (this.cookieSave == `On`) ? this.cookie.dateFormat : this.defaultCookie(`dateFormat`)
});
if (this.cookieSave == `On`) {
let g = this.cookieParser([`generalSaveZIP`, `generalSaveFile`]);
this.setCookie({
generalSave: {
zipName: g.generalSaveZIP,
fileName: g.generalSaveFile
}
});
if (this.cookie[`authorId_${authorId}`]) {
// `authorId_${authorId}` exist in cookie.
// load authorSave settings even when authorSave is off.
let a = this.cookieParser([`authorSaveZIP_${authorId}`, `authorSaveFile_${authorId}`]);
this.setCookie({
authorSave: {
zipName: a[`authorSaveZIP_${authorId}`] || this.defaultCookie(`authorSave`).zipName,
fileName: a[`authorSaveFile_${authorId}`] || this.defaultCookie(`authorSave`).fileName
}
});
if (this.cookie[`authorId_${authorId}`] === 'On') {
this[`authorId_${authorId}`] = `On`;
this.setCookie({
authorSaveCheck: `On`
});
}
}
}
this.saveCookie(false);
this.metaJson = {};
this.metaData = {};
if (window.csrfToken) {
$.ajaxSetup({
headers: {
"x-csrf-token": window.csrfToken
}
});
}
let self = this;
$.get(this.jsonUrl, (json) => {
self.metaJson = json;
let data = json[self.pageType];
self.metaData = {
user: data.fanclub.creator_name,
uid: data.fanclub.id,
content: data[`${self.pageType}_contents`]
};
});
return this;
}
saveCookie(check) {
if (this.cookie.cookieSave == 'On') {
let date = new Date();
date.setDate(date.getDate() + 75);
let cookie = {
cookieSave: this.cookie.cookieSave,
lang: this.cookie.lang,
dateFormat: this.cookie.dateFormat,
Expires: date.toUTCString()
};
cookie.generalSaveZIP = this.cookie.generalSave.zipName;
cookie.generalSaveFile = this.cookie.generalSave.fileName;
if (this[`authorId_${this.authorId}`] == 'On') {
cookie[`authorId_${this.authorId}`] = 'On';
cookie[`authorSaveZIP_${this.authorId}`] = this.cookie.authorSave.zipName;
cookie[`authorSaveFile_${this.authorId}`] = this.cookie.authorSave.fileName;
} else {
cookie[`authorId_${this.authorId}`] = 'Off';
}
this.updateCookie(cookie);
} else {
let date = new Date();
date.setDate(date.getTime() - 1);
let cookie = {
cookieSave: 'Off',
Expires: date.toUTCString()
};
cookie[`authorId_${this.authorId}`] = 'Off';
this.updateCookie(cookie);
}
return (check != false) ? alert(this.getDefault(`saveMessage`, this.lang)) : true;
}
updateCookie(cookie = undefined) {
let Expires = cookie.Expires;
delete cookie.Expires;
for (let [key, value] of Object.entries(cookie)) {
document.cookie = `${key}=${value}; Expires=${Expires}; Path=/`;
}
this.cookieOri = document.cookie;
return this.cookieOri;
}
cookieParser(keyArr) {
return (typeof keyArr == `string`) ? document.cookie.split('; ').map(row => row.split('=')).filter(row => keyArr == row[0])[1] || undefined : Object.fromEntries(document.cookie.split('; ').map(row => row.split('=')).filter(row => keyArr.includes(row[0])));
}
setCookie(settingObj) {
for (let [key, value] of Object.entries(settingObj)) {
this.cookie[key] = value;
this[key] = value;
}
return this.cookie;
}
setLang(Lang) {
let lang = Lang || this.getOriLang().toLowerCase();
if (/^ja\b/.test(lang)) this.lang = `ja`;
if (/^zh\b/.test(lang)) this.lang = `zh`;
return this.lang;
}
getOriLang() {
let res = `en`;
let lang = (navigator.language || navigator.browserLanguage).toLowerCase();
if (/^ja\b/.test(lang)) res = `ja`;
if (/^zh\b/.test(lang)) res = `zh`;
return res;
}
defaultCookie(key) {
let defaultSetting = {
cookieSave: "Off",
lang: this.getOriLang(),
generalSave: {
zipName: `{postTitle}_{boxTitle}`,
fileName: `{imgIndex:0}`
},
authorSave: {
zipName: `[{user}]{postTitle}_{boxTitle}`,
fileName: `{boxTitle}_{imgIndex:0}`
},
authorSaveCheck: `Off`,
dateFormat: `yyyyMMdd`
};
return (key) ? defaultSetting[key] : defaultSetting;
}
getDefault(key, lang = undefined) {
let defaultSetting = {
en: {
downloadImg: `Download Images`,
downloadImgZip: `Download ZIP`,
retrieving: `Retrieving Link`,
zipping: `Zipping`,
processing: `Processing`,
done: `Done`,
// 按紐
settingCenter: `Setting`,
cookieButton: `Cookie`,
languageButton: `言語設定/Language/界面語言`,
generalSave: `Global Save`,
authorSave: `Author Save`,
zipName: `ZIP file name`,
fileName: `image file name`,
dateFormat: `Date Format`,
saveSetting: `Apply Setting`,
closeSetting: `Close`,
tableParams: `Parameter`,
tableMean: `Mean`,
saveMessage: `Setting has save!`,
// 參數
user: `Creator Name`,
uid: `Creator ID`,
postTitle: `Post Title`,
postId: `Post ID`,
boxTitle: `Image Box Title`,
"imgIndex:0": `Index for image, Number is first index number.`,
plan: `Name of Plan`,
fee: `fee of Plan`,
postDate: `Post Date`,
taskDate: `Download Date`,
ext: `Filename Extension`
},
ja: {
downloadImg: `ダウンロード`,
downloadImgZip: `ZIPダウンロード`,
retrieving: `取得中`,
zipping: `zip圧縮`,
processing: `圧縮`,
done: `ダウンロード完了`,
// 按紐
settingCenter: `設定`,
cookieButton: `Cookie`,
languageButton: `Language/言語設定/界面語言`,
generalSave: `保存の設定`,
authorSave: `クリエイターに保存`,
zipName: `ZIPフォルダ`,
fileName: `ファイル`,
dateFormat: `日時の設定`,
saveSetting: `設定を保存する`,
closeSetting: `閉じる`,
tableParams: `パラメータ`,
tableMean: `効果`,
saveMessage: `設定を保存しました!`,
// 參數
user: `クリエイターの名前`,
uid: `クリエイターのID`,
postTitle: `投稿のタイトル`,
postId: `投稿のID`,
boxTitle: `イラストボックスのタイトル`,
"imgIndex:0": `画像のインデックス、番号は最初のインデックス番号です`,
plan: `プラン名`,
fee: `プランの月額料金`,
postDate: `公開日時`,
taskDate: `ダウンロード日時`,
ext: `拡張子`
},
zh: {
downloadImg: `全圖片下載`,
downloadImgZip: `ZIP 下載`,
retrieving: `擷取連結中`,
zipping: `壓縮檔案中`,
processing: `壓縮`,
done: `下載已完成`,
// 按紐
settingCenter: `設定`,
cookieButton: `Cookie`,
languageButton: `Language/界面語言/言語設定`,
generalSave: `全域設定`,
authorSave: `作者特訂`,
zipName: `壓縮檔檔名`,
fileName: `圖片檔檔名`,
dateFormat: `日期時間格式`,
saveSetting: `儲存設定`,
closeSetting: `關閉`,
tableParams: `參數`,
tableMean: `效果`,
saveMessage: `設定已儲存!`,
// 參數
user: `創作者名稱`,
uid: `創作者 ID`,
postTitle: `投稿標題`,
postId: `投稿 ID`,
boxTitle: `圖片區標題`,
"imgIndex:0": `檔案排序號,數字決定起始數字`,
plan: `訂閱方案名`,
fee: `瀏覽月費`,
postDate: `投稿日期`,
taskDate: `下載日期`,
ext: `檔案副檔名`
}
};
return (key) ? defaultSetting[lang || this.lang][key] : defaultSetting[lang || this.lang];
}
renderSettingParams() {
$(`#cookie${this.cookieSave}`).attr("checked", true);
$(`#${(this.authorSaveCheck == `On`) ? `authorSave` : `generalSave`}`).attr("checked", true);
$(`#selectSetting option[value='${this.lang}']`).attr("selected", true);
$(`#zipNameInput`).val(this[(this.authorSaveCheck == `On`) ? `authorSave` : `generalSave`].zipName);
$(`#fileNameInput`).val(this[(this.authorSaveCheck == `On`) ? `authorSave` : `generalSave`].fileName);
$(`#dateFormatInput`).val(this.dateFormat);
$(`#paramsTable`).html(this.paramsTemplate(this.lang));
return this;
}
changeStyle(mode) {
let blur = CSS.supports(`backdrop-filter`, `blur(15px)`);
switch (mode) {
case `Blur`:
return;
case `unBlur`:
return;
default:
return;
}
}
changeLang(Lang) {
let lang = Lang || $("#selectSetting option:selected").val();
this.setCookie({
lang: lang
});
$("#titleSetting").text(this.getDefault(`settingCenter`, lang));
$("#cookieSetting").text(this.getDefault(`cookieButton`, lang));
$("#langSetting").text(this.getDefault(`languageButton`, lang));
$("#generalSaveSetting").text(this.getDefault(`generalSave`, lang));
$("#authorSaveSetting").text(this.getDefault(`authorSave`, lang));
$("#zipNameSetting").text(this.getDefault(`zipName`, lang));
$("#fileNameSetting").text(this.getDefault(`fileName`, lang));
$("#dateFormatSetting").text(this.getDefault(`dateFormat`, lang));
$("#saveSetting").text(this.getDefault(`saveSetting`, lang));
$("#closeSetting").text(this.getDefault(`closeSetting`, lang));
$(".downloadSpan").text(this.getDefault('downloadImg', lang));
$(".downloadSpanZip").text(this.getDefault('downloadImgZip', lang));
$("#paramsTable").html(this.paramsTemplate(this.lang));
return;
}
changeName(type) {
let name = $(`#${type}NameInput`).val();
let setting = $(`input[name='saveCheck']:checked`).attr("id");
if (name == ``) {
this.changeSaveSetting(setting);
} else {
this[setting][`${type}Name`] = name;
}
return;
}
changeSaveSetting(id) {
let setting = this[id];
$(`#zipNameInput`).val(setting.zipName);
$(`#zipNameInput`).attr("placeholder", setting.zipName);
$(`#fileNameInput`).val(setting.fileName);
$(`#fileNameInput`).attr("placeholder", setting.fileName);
return;
}
paramsTemplate(lang = this.lang) {
let table = `<table><tbody><tr style="text-align:center;">
<th>${windowSetting.getDefault(`tableParams`, lang)}</th>
<th>${windowSetting.getDefault(`tableMean`, lang)}</th>
</tr>`;
let a = [`user`, `uid`, `postTitle`, `postId`, `boxTitle`, `imgIndex:0`, `plan`, `fee`, `postDate`, `taskDate`, `ext`].forEach((p, i) => {
table += `<tr style="background-color: ${(i % 2 == 0) ? `#71b6ff2b` : `#fff0`};">
<td style="border-right: 1px solid #131313;">{${p}}</td>
<td style="border-left: 1px solid #131313;">${windowSetting.getDefault(p, lang)}</td>
</tr>`;
});
table += `</tbody></table>`;
return table;
}
settingCenterTemplate(lang) {
return `<div id="settingCenterDiv" class="close ${(CSS.supports(`backdrop-filter`, `blur(15px)`)) ? `` : `unBlur`}">
<div class="settingTitleColor" style="width: 100%;height: 25px;position: relative;background-color: #ffffff78;display: flex;align-items: center;">
<p id="titleSetting" style="margin: 0 auto;">${this.getDefault(`settingCenter`, lang)}</p>
</div>
<div class="titleImage" onclick="location.href = 'https://github.com/suzumiyahifumi/Fantia-Downloader-tampermonkey'" style="width: 100%;height: 55px;background-color: #ffffff78;position: relative;margin: 0 auto;cursor: pointer;border-top-style: solid;border-top-color: #757575;border-top-width: 1px;border-bottom-left-radius: 10px;border-bottom-right-radius: 10px;"></div>
<div style="width: 95%;height: 2.5em;background-color: #fff0;margin: 10px auto;position: relative;border-radius: 5px;">
<div class="settingTitleColor" style="width: calc(50% - 1px);height: 100%;background-color: #ffffff69;border-top-left-radius: 5px;border-bottom-left-radius: 5px;float: left;display: flex;align-items: center;margin: 0 1px 0 auto;">
<p id="cookieSetting" style="margin: 0 auto;">${this.getDefault(`cookieButton`, lang)}</p>
</div>
<div class="settingTitleColor" style="width: calc(50% - 1px);height: 100%;background-color: #ffffff69;border-top-right-radius: 5px;border-bottom-right-radius: 5px;float: left;position: relative;margin: 0 auto 0 1px;">
<label style="float: left;width: 50%;height: 100%;display: flex;align-items: center;cursor: pointer;margin: auto;" for="cookieOn" id="cookieOnLabel" class="settingCenterButton"><input style="cursor: pointer;appearance: none;" type="radio" id="cookieOn" name="cookieCheck">
<div id="cookieOnLabel" style="width: 100%;height: 100%;display: flex;align-items: center;cursor: pointer;margin: auto;">
<span style="margin: 0 auto;">On</span></div>
</label><label style="float: left;width: 50%;height: 100%;display: flex;align-items: center;cursor: pointer;margin: auto;border-top-right-radius: 5px;border-bottom-right-radius: 5px;" for="cookieOff" id="cookieOffLabel" class="settingCenterButton"><input style="cursor: pointer;appearance: none;" type="radio" name="cookieCheck" id="cookieOff">
<div style="width: 100%;height: 100%;display: flex;align-items: center;cursor: pointer;margin: auto;border-top-right-radius: 5px;border-bottom-right-radius: 5px;" id="cookieOffLabel"><span style="margin: 0 auto;">Off</span></div>
</label></div>
</div>
<div style="width: 95%;height: 2.5em;background-color: #fff0;margin: 10px auto;position: relative;border-radius: 5px;">
<div class="settingTitleColor" style="width: calc(50% - 1px);height: 100%;background-color: #ffffff69;border-top-left-radius: 5px;border-bottom-left-radius: 5px;float: left;display: flex;align-items: center;margin: 0 1px 0 auto;">
<p id="langSetting" style="margin: 0 auto;">${this.getDefault(`languageButton`, lang)}</p>
</div>
<div class="settingCenterButton" style="width: calc(50% - 1px);height: 100%;background-color: #77777769;border-top-right-radius: 5px;border-bottom-right-radius: 5px;border-left-color: #c8c8c800;border-left-width: 1px;border-left-style: solid;float: left;position: relative;margin: 0 auto 0 1px;">
<select id="selectSetting" style="height: 100%;border-style: hidden;border-top-right-radius: 5px;border-bottom-right-radius: 5px;width: 100%;background-color: #fff;cursor: pointer;text-align: center;text-align-last: center;-webkit-appearance: none;-moz-appearance: none;" name="lang">
<option value="zh">中文</option>
<option value="en">English</option>
<option value="ja">日本語</option>
</select></div>
</div>
<div style="width: 95%;height: calc(100% - 80px - 50px - 7.5em);background-color: #fff0;margin: 10px auto;position: relative;border-radius: 5px;">
<div class="settingTitleColor" style="width: calc(50% - 1px);height: 2.5em;background-color: #ffffff69;border-top-left-radius: 5px;float: left;display: flex;align-items: center;cursor: pointer;margin: 0 1px 1px 0;/*! border-bottom-style: groove; *//*! border-bottom-color: #fff; */">
<label style="float: left;width: 100%;height: 100%;display: flex;align-items: center;cursor: pointer;margin: auto;" for="generalSave" class="settingCenterButton"><input style="cursor: pointer;appearance: none;" type="radio" id="generalSave" name="saveCheck">
<div style="width: 100%;height: 100%;display: flex;align-items: center;cursor: pointer;margin: auto;border-top-left-radius: 5px;" id="generalSaveLabel" author-id="${this.authorId}"><span id="generalSaveSetting" style="margin: 0 auto;">${this.getDefault(`generalSave`, lang)}</span></div>
</label></div>
<div class="settingTitleColor" style="width: calc(50% - 1px);height: 2.5em;background-color: #ffffff69;border-top-right-radius: 5px;float: left;display: flex;align-items: center;position: relative;cursor: pointer;margin: 0 0 1px 1px;">
<label style="float: left;width: 100%;height: 100%;display: flex;align-items: center;cursor: pointer;margin: auto;" for="authorSave" class="settingCenterButton"><input style="cursor: pointer;appearance: none;" type="radio" name="saveCheck" id="authorSave">
<div style="width: 100%;height: 100%;display: flex;align-items: center;cursor: pointer;margin: auto;border-top-right-radius: 5px;" id="authorSaveLabel" author-id="${this.authorId}"><span id="authorSaveSetting" style="margin: 0 auto;">${this.getDefault(`authorSave`, lang)}</span></div>
</label></div>
<div class="settingTitleColor" style="width: calc(25% - 1px);height: 2.5em;float: left;display: flex;align-items: center;position: relative;background-color: #ffffff69;margin: 1px 1px 1px 0;">
<p id="zipNameSetting" style="margin: 0 auto;">${this.getDefault(`zipName`, lang)}</p>
</div>
<div class="settingTitleColor" style="width: calc(60% - 1px);height: 2.5em;background-color: #ffffff69;float: left;display: flex;align-items: center;position: relative;cursor: pointer;margin: 1px 1px 1px 1px;">
<input id="zipNameInput" placeholder="{postTitle}_{boxTitle}" style="margin: 0 auto;background: #ffffff2e;width: 95%;border-style: none;padding: 0.2em;">
</div>
<div class="settingTitleColor" style="width: calc(15% - 2px);height: 2.5em;background-color: #ffffff69;float: left;display: flex;align-items: center;position: relative;margin: 1px auto 1px 1px;">
<p style="margin: 0 auto;">.zip</p>
</div>
<div class="settingTitleColor" style="width: calc(25% - 1px);height: 2.5em;float: left;display: flex;align-items: center;position: relative;background-color: #ffffff69;margin: 1px 1px 1px auto;">
<p id="fileNameSetting" style="margin: 0 auto;">${this.getDefault(`fileName`, lang)}</p>
</div>
<div class="settingTitleColor" style="width: calc(60% - 1px);height: 2.5em;background-color: #ffffff69;float: left;display: flex;align-items: center;position: relative;cursor: pointer;margin: 1px 1px 1px 1px;">
<input id="fileNameInput" placeholder="{imgIndex:0}" style="margin: 0 auto;background: #ffffff2e;width: 95%;border-style: none;padding: 0.2em;">
</div>
<div class="settingTitleColor" style="width: calc(15% - 2px);height: 2.5em;background-color: #ffffff69;float: left;display: flex;align-items: center;position: relative;margin: 1px auto 1px 1px;">
<p style="margin: 0 auto;">.{ext}</p>
</div>
<div class="settingTitleColor" style="width: calc(50% - 1px);height: 2.5em;float: left;display: flex;align-items: center;position: relative;background-color: #ffffff69;margin: 1px 1px 1px 0;">
<p id="dateFormatSetting" style="margin: 0 auto;">${this.getDefault(`dateFormat`, lang)}</p>
</div>
<div class="settingTitleColor" style="width: calc(50% - 1px);height: 2.5em;background-color: #ffffff69;float: left;display: flex;align-items: center;position: relative;margin: 1px auto 1px 1px;">
<input id="dateFormatInput" style="margin: 0 auto;background: #ffffff2e;width: 95%;border-style: none;padding: 0.2em;text-align:center;">
</div>
<div id="paramsTable" class="settingTitleColor" style="width: 100%;height: calc(100% - 10em - 6px);position: relative;background-color: #ffffff69;border-bottom-left-radius: 5px;border-bottom-right-radius: 5px;float: left;margin: 1px 0 0 0;overflow: auto;">
</div>
</div>
<div class="settingTitleColor" style="width: 95%;height: 2.5em;background-color: #fff0;margin: 10px auto;position: relative;border-radius: 5px;">
<div class="settingCenterButton" id="saveSettingButton" style="width: calc(65% - 5px);height: 100%;background-color: #ffffff69;border-radius: 5px;float: left;cursor: pointer;display: flex;align-items: center;margin: 0 5px 0 0;">
<p id="saveSetting" style="margin: 0 auto;">${this.getDefault(`saveSetting`, lang)}</p>
</div>
<div class="settingCenterButton" id="closeSettingButton" style="width: calc(35% - 5px);height: 100%;background-color: #f65c5c9e;float: left;position: relative;border-radius: 5px;cursor: pointer;display: flex;align-items: center;margin: 0 0 0 5px;">
<p id="closeSetting" style="margin: 0 auto;">${this.getDefault(`closeSetting`, lang)}</p>
</div>
</div>
</div>`;
}
}
class downloader {
constructor(event) {
this.pageType = windowSetting.pageType;
this.metaData = windowSetting.metaData;
this.button = ($(event.target).is("button")) ? $(event.target) : $(event.target).closest("button");
this.boxType = this.button.attr("box-type");
this.postContent = $(event.target).closest(".boxIndex");
this.type = (this.button.hasClass(`zip`)) ? `zip` : `file`;
this.boxIndex = this.postContent.attr("boxIndex");
if (this.boxType == "box") {
let content = this.metaData.content[this.boxIndex];
let p = (content.plan == null) ? `一般公開` : undefined;
this.metaData.category = content.category;
this.metaData.indextype = (content.category == "blog") ? this.button.closest(".blogBox").attr("blog-img-index") : "photo_gallery";
this.metaData.srcArr = (content.category == "blog") ? [JSON.parse(content.comment).ops.filter(i => {
return (i.insert.fantiaImage && i.insert.fantiaImage.id == this.metaData.indextype) ? true : false
})[0].insert.fantiaImage.original_url] : content.post_content_photos.map(img => img.url.original);
this.metaData.fee = p || content.plan.price;
this.metaData.plan = p || content.plan.name;
this.metaData.postDate = content.parent_post.date;
this.metaData.postId = content.parent_post.url.split("/").pop();
this.metaData.postTitle = content.parent_post.title;
this.metaData.title = content.title;
this.metaData.d = (content.category == "photo_gallery") ? downloader.getDigits(Number(content.post_content_photos.length)) : 1;
} else if (this.boxType == "post") {
let p = `一般公開`;
this.metaData.category = "post";
this.metaData.indextype = "post";
this.metaData.srcArr = [windowSetting.metaJson.post.thumb.original];
this.metaData.fee = p;
this.metaData.plan = p;
this.metaData.postDate = windowSetting.metaJson.post.posted_at;
this.metaData.postId = windowSetting.metaJson.post.uri.show.split("/").pop();
this.metaData.postTitle = windowSetting.metaJson.post.title;
this.metaData.title = windowSetting.metaJson.post.title;
this.metaData.d = 1;
}
this.zipName = `${windowSetting[`${(windowSetting.authorSaveCheck == 'On') ? `author` : `general`}Save`].zipName}.zip`;
this.fileName = `${windowSetting[`${(windowSetting.authorSaveCheck == 'On') ? `author` : `general`}Save`].fileName}.{ext}`;
this.dateFormat = windowSetting.dateFormat;
this.zipfmt = ``;
this.zipImgIndex0 = 0;
this.filefmt = ``;
this.fileImgIndex0 = 0;
this.d = this.metaData.d;
if (this.type === 'zip') {
const blobWriter = new zip.BlobWriter('application/zip');
this.zip = new zip.ZipWriter(blobWriter);
}
return this.downloadImg();
}
changeButton(mode, input = false) {
let button = this.button;
switch (mode) {
case `start`:
button.addClass(['active', 'hdr']);
if (this.type == `file`) {
button.find('i').removeClass('fa-download');
button.find('i').addClass('fa-spinner');
button.find('i').addClass('fa-pulse');
} else {
button.find('i').removeClass('fa-file-archive-o');
button.find('i').addClass('fa-spinner');
button.find('i').addClass('fa-pulse');
}
break;
case `catchLink`:
button.find('span').text(windowSetting.getDefault(`retrieving`));
break;
case `countTask`:
button.find('span').text(`${this.finCount} / ${this.imgSrc.length}`);
break;
case `pickUp`:
button.find('span').text(windowSetting.getDefault(`zipping`));
break;
case `end`:
if (this.type == `file`) {
button.find('i').removeClass('fa-pulse').removeClass('fa-spinner').addClass('fa-download');
} else {
button.find('i').removeClass('fa-pulse').removeClass('fa-spinner').addClass('fa-file-archive-o');
}
button.removeClass(['active', 'hdr']);
button.find('span').text(windowSetting.getDefault(`done`));
break;
case `log`:
button.find('span').text(input);
break;
default:
return this;
}
return this;
}
paramsParser(type, fmt) {
const replaceSlash = `_`;
let o = {
user: () => {
return (this.metaData.user || $("h1.fanclub-name>a").text()).replace(/\/|\\/g, replaceSlash);
},
uid: () => {
return this.metaData.uid || this.authorId;
},
postTitle: () => {
return (this.metaData.postTitle || $("h1.post-title").text()).replace(/\/|\\/g, replaceSlash);
},
postId: () => {
return this.metaData.postId || window.location.href.split("/").pop();
},
boxTitle: () => {
return (this.metaData.boxTitle || this.button.closest("div.post-content-inner").find('h2').text()).replace(/\/|\\/g, replaceSlash);
},
plan: () => {
let feeStr = this.metaData.plan || this.button.closest("div.post-content-inner").find(`div.post-content-for strong.ng-binding`).text();
let match = this.metaData.plan || feeStr.match(new RegExp(/(\d+円)以上限定$/g));
if (match != null) return (this.metaData.plan || feeStr.replace(match[0], ``)).replace(/\/|\\/g, replaceSlash);
return (this.metaData.plan || `一般公開`).replace(/\/|\\/g, replaceSlash);
},
fee: () => {
let feeStr = this.metaData.fee || this.button.closest("div.post-content-inner").find(`div.post-content-for strong.ng-binding`).text();
let match = this.metaData.fee || feeStr.match(new RegExp(/((\d+)円)以上限定$/g));
if (match != null) return this.metaData.fee || RegExp.$1;
return this.metaData.fee || `一般公開`;
},
postDate: () => {
return new Date(this.metaData.postDate || $(`small.post-date>span`).text()).Format(this.dateFormat);
},
taskDate: () => {
return new Date().Format(this.dateFormat);
}
};
for (let k in o) {
fmt = fmt.replaceAll(new RegExp('(\\{' + k + '\\})', 'g'), o[k]());
}
// prevent empty folder name when replace value is empty. e.g. `poseTitle//image.png`
fmt = fmt.replace(/(?:\\|\/){2,}/g, '/').replace(/^(\\|\/)/, '');
let s = (/\{imgIndex(\:(\d+))?\}/g.test(fmt)) ? RegExp.$2 : 0;
if (/\{imgIndex(\:(\d+))?\}/g.test(fmt)) fmt = fmt.replace(RegExp.$1, ``);
this[`${type}fmt`] = fmt;
this[`${type}ImgIndex0`] = s;
return this;
}
nextName(type, index, mimeType) {
if (this.metaData.indextype != "photo_gallery") return this[`${type}fmt`].replace(`{imgIndex}`, (this.metaData.indextype).toString().padStart(this.d, 0)).replace(`{ext}`, mimeType.toString().split(`/`)[1]);
return this[`${type}fmt`].replace(`{imgIndex}`, (Number(index) + Number(this[`${type}ImgIndex0`])).toString().padStart(this.d, 0)).replace(`{ext}`, mimeType.toString().split(`/`)[1]);
}
downloadImg() {
let dataCont = 0;
this.paramsParser(`zip`, this.zipName);
this.paramsParser(`file`, this.fileName);
this.changeButton(`start`);
this.changeButton(`catchLink`);
this.changeButton(`log`, `${dataCont} / ${this.metaData.srcArr.length}`);
let self = this;
this.metaData.srcArr.forEach((url, i) => {
downloader.loadAsArrayBuffer(url, function (imgData, mimeType, lastModified) {
dataCont += 1;
self.changeButton(`log`, `${dataCont} / ${self.metaData.srcArr.length}`);
self.mimeType = mimeType;
let content = new Blob([imgData], { type: mimeType });
if (self.zip == undefined) {
if (dataCont == self.metaData.srcArr.length) self.changeButton('end');
downloader.download(content, self.nextName('file', i, mimeType));
return;
} else {
const sDate = lastModified && lastModified !== '' ? new Date(lastModified) : null;
const date = sDate ?? new Date();
self.zip.add(
self.nextName('file', i, mimeType),
new zip.BlobReader(content),
{
lastModDate: date,
level: 0 // The level of compression. 0 to 9, higher mean more compression.
}
);
if (dataCont === self.metaData.srcArr.length) {
self.changeButton(`pickUp`);
self.zip
.close({
// this is not getting call, maybe a bug?
onprogress: (progress, total) => {
const percent = (progress / total) * 100;
self.changeButton(
`log`,
`${windowSetting.getDefault(`processing`)}:${percent.toFixed(2)} %`
);
}
})
.then(zipBlob => {
self.changeButton('end');
downloader.download(zipBlob, self.nextName('zip', 0, 'application/zip'));
});
}
}
});
});
}
static download(content, name) {
GM_download({
name,
url: content instanceof Blob ? URL.createObjectURL(content) : content,
saveAs: false // this will popup "Save As" FileSavePicker window if set to true.
})
}
static getDigits(i) {
let L = 0;
while (i >= 1) {
i = i / 10;
L += 1;
}
return `${L}`;
}
static loadAsArrayBuffer(url, callback) {
let xhr = new XMLHttpRequest();
xhr.open("GET", url);
xhr.responseType = "arraybuffer";
xhr.onerror = function (error) {
return new Error(`ERROR`);
};
xhr.onload = function () {
if (xhr.status === 200) {
callback(xhr.response, xhr.getResponseHeader("Content-Type"), xhr.getResponseHeader("Last-Modified"));
} else {
return new Error(`ERROR`);
}
};
xhr.send();
}
}
const getDownLoadButton = () => {
$("div.post-content-inner").each((i, div) => {
$(div).addClass("boxIndex").attr("boxIndex", i);
$(div).find("div.btn-group-tabs").append(`<button box-type="box" class="btn btn-default btn-md downloadButton zip"><i class="fa fa-file-archive-o fa-2x" style="color: #f9a63b !important;"></i> <span class="btn-text-sub downloadSpanZip" style="color: #f9a63b !important;">${windowSetting.getDefault('downloadImgZip')}</span></button><button box-type="box" class="btn btn-default btn-md downloadButton file"><i class="fa fa-download fa-2x" style="color: #fe7070 !important;"></i> <span class="btn-text-sub downloadSpan" style="color: #fe7070 !important;">${windowSetting.getDefault('downloadImg')}</span></button>`);
});
$(`.the-post`).find("div.btn-group-tabs").append(`<button box-type="post" class="btn btn-default btn-md downloadButton zip"><i class="fa fa-file-archive-o fa-2x" style="color: #f9a63b !important;"></i> <span class="btn-text-sub downloadSpanZip" style="color: #f9a63b !important;">${windowSetting.getDefault('downloadImgZip')}</span></button><button box-type="post" class="btn btn-default btn-md downloadButton file"><i class="fa fa-download fa-2x" style="color: #fe7070 !important;"></i> <span class="btn-text-sub downloadSpan" style="color: #fe7070 !important;">${windowSetting.getDefault('downloadImg')}</span></button>`);
$('.set-FD').remove();
$("div#page").append(`<div id="settingCenter"></div>`);
$("div#page").append(windowSetting.settingCenterTemplate());
windowSetting.renderSettingParams().paramsTemplate();
};
/** Add listener to interactions, handles all buttons and inputs. */
const handleInteractions = () => {
// Download buttons
$('#settingCenter').on('click', () => {
if ($(`#settingCenterDiv`).hasClass(`close`)) {
$(`#settingCenterDiv`).removeClass(`close`);
}
});
$('.downloadButton').on('click', (event) => {
return checkBrowser(event, (event) => {
return new downloader(event);
});
})
// Setting menu
$('#cookieOn').on('click', () => {
windowSetting.setCookie({ cookieSave: 'On' });
})
$('#cookieOff').on('click', () => {
windowSetting.setCookie({ cookieSave: 'Off' });
})
$('#generalSaveLabel').on('click', (event) => {
const targetAuthorId = event.currentTarget.attributes['author-id'].value;
windowSetting.changeSaveSetting('generalSave');
windowSetting.setCookie({ authorSaveCheck: 'Off', [`authorId_${targetAuthorId}`]: 'Off' });
})
$('#authorSaveLabel').on('click', (event) => {
const targetAuthorId = event.currentTarget.attributes['author-id'].value;
windowSetting.changeSaveSetting('authorSave');
windowSetting.setCookie({ authorSaveCheck: 'On', [`authorId_${targetAuthorId}`]: 'On' });
})
$('#saveSettingButton').on('click', () => {
windowSetting.saveCookie();
})
$('#closeSettingButton').on('click', () => {
$('#settingCenterDiv').addClass('close');
})
// Language selector
$('#selectSetting').on('change', () => {
windowSetting.changeLang();
})
// Input
$('#zipNameInput').on('change', () => {
windowSetting.changeName('zip');
})
$('#fileNameInput').on('change', () => {
windowSetting.changeName('file');
})
$('#dateFormatInput').on('change', () => {
windowSetting.setCookie({ dateFormat: $('#dateFormatInput').val() });
})
}
const checkBrowser = (event, callBack) => {
try {
let excludes = [];
let ex = excludes.map(b => navigator.userAgent.indexOf(b)).filter(b => (b != -1) ? true : false);
if (ex.length >= 1) {
alert(`請使用 Firefox 下載圖片!\nPlease run this script on Firefox!\n
Also you can check the new script version!`);
return;
} else {
return callBack(event);
}
} catch (err) {
console.log(err);
alert(`出了些問題!你可以嘗試使用 Firefox 下載圖片!\nThere are some ERROR, You can try this script on Firefox!\n
Also you can check the new script version!`);
return;
}
};
})();