-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathenhanced.user.js
More file actions
3764 lines (3297 loc) · 153 KB
/
enhanced.user.js
File metadata and controls
3764 lines (3297 loc) · 153 KB
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
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ==UserScript==
// @name KakaoStory Enhanced
// @namespace http://chihaya.kr
// @version 1.37
// @description Add-on for KakaoStory
// @author Reflection and other contributors
// @match https://story.kakao.com/*
// @match https://accounts.kakao.com/*
// @icon https://raw.githubusercontent.com/reflection1921/KakaoStory-Enhanced/main/story_favicon.ico
// @downloadURL https://raw.githubusercontent.com/reflection1921/KakaoStory-Enhanced/main/enhanced.user.js
// @updateURL https://raw.githubusercontent.com/reflection1921/KakaoStory-Enhanced/main/enhanced.user.js
// @require https://cdn.jsdelivr.net/npm/chart.js
// ==/UserScript==
let scriptVersion = "1.37";
//let resourceURL = 'http://127.0.0.1:8977/kakaostory-enhanced/'; //for debug
//let resourceURL = 'https://raw.githubusercontent.com/reflection1921/KakaoStory-Enhanced/dev/'; //github dev
let resourceURL = 'https://raw.githubusercontent.com/reflection1921/KakaoStory-Enhanced/main/';
let myID = ''; //for discord mention style feature
let notyTimeCount = 0; //for notification feature
let blockedList = new Set(); //block users
let blockedStringList = []; //block strings
let feedBlockedList = new Set(); //blocked feed users
let catEffect = new Audio(resourceURL + 'sounds/cat-meow.mp3');
let dogEffect = new Audio(resourceURL + 'sounds/dog-bark.mp3');
let jThemes;
let powerComboCnt = 0;
let powerComboTimeCnt = 0;
let currentFavicon = "naver";
let currentTitle = "NAVER";
//let selCurPerm = 'Z'; //A = 전체공개, F = 친구공개, M = 나만보기, Z = 기본설정(모든 게시글)
//let selNewPerm = 'F'; //A = 전체공개, F = 친구공개, M = 나만보기
let notyOption = {
body: '',
icon: 'https://i.imgur.com/FSvg18g.png',
silent: false
}
//konami command to restore kakaostory favicon classic
let konami = ['ArrowUp','ArrowUp','ArrowDown','ArrowDown','ArrowLeft','ArrowRight','ArrowLeft','ArrowRight','KeyB','KeyA'];
let konamiCount = 0;
// media hide mode(blur)
const targetSelectorsBlur = [
'.fd_cont .wrap_swipe',
'.fd_cont .img_wrap',
'.fd_cont .movie_wrap',
'.fd_cont .link_imgthumb',
];
let mediaHideObserver = new MutationObserver((mutationsList) => {
for (const mutation of mutationsList) {
for (const node of mutation.addedNodes) {
if (!(node instanceof HTMLElement)) continue;
const targets = [];
for (const selector of targetSelectorsBlur) {
if (node.matches?.(selector)) {
targets.push(node);
}
node.querySelectorAll?.(selector)?.forEach(el => targets.push(el));
}
targets.forEach(AddBlurToMedia);
}
}
});
function GetFormattedDateTime() {
const now = new Date();
const yyyy = now.getFullYear();
const MM = String(now.getMonth() + 1).padStart(2, '0');
const dd = String(now.getDate()).padStart(2, '0');
const hh = String(now.getHours()).padStart(2, '0');
const mm = String(now.getMinutes()).padStart(2, '0');
const ss = String(now.getSeconds()).padStart(2, '0');
return `${yyyy}${MM}${dd}_${hh}${mm}${ss}`;
}
function AddEnhancedMenuObserver() {
const observer = new MutationObserver((mutations) => {
for (const { addedNodes } of mutations) {
for (const node of addedNodes) {
if (!(node instanceof HTMLElement)) continue;
const target = node.classList.contains('menu_util')
? node
: node.querySelector('.menu_util');
if (target) {
observer.disconnect();
AddEnhancedMenu();
return;
}
}
}
});
observer.observe(document.body, {
childList: true,
subtree: true,
});
}
function AddEnhancedMenu() {
document.getElementsByClassName("menu_util")[0].innerHTML = '<li><a href="#" id="enhancedHideSidebar" class="link_menu _btnSettingProfile">사이드바 숨기기</a></li><li class="enhanced_settings_menu"><a href="#" id="enhancedOpenSettings" class="link_menu _btnSettingProfile">Enhanced 설정</a></li>' + document.getElementsByClassName("menu_util")[0].innerHTML;
document.getElementById("enhancedOpenSettings").addEventListener("click", function() {
document.getElementById("enhancedLayer").style.display = 'block';
document.body.scrollTop = 0;
DisableScroll();
});
document.getElementById("enhancedHideSidebar").addEventListener("click", function() {
document.getElementById("mSnb").classList.add('enhanced_sidebar_hidden');
document.getElementById("enhancedShowSidebar").style.display = 'block';
SetValue('enhancedSidebarShow', 'false');
});
let showBtn = document.createElement('div');
showBtn.id = 'enhancedShowSidebar';
if (GetValue('enhancedSidebarLocation', 'right') === 'right')
{
showBtn.className = 'enhanced_sidebar_show';
showBtn.innerHTML = '<span class="enhanced_sidebar_show_btn_to_left"></span>'
}
else
{
showBtn.className = 'enhanced_sidebar_show_left';
showBtn.innerHTML = '<span class="enhanced_sidebar_show_btn_to_right"></span>'
}
document.getElementById("rnb").insertBefore(showBtn, document.getElementById("rnb").firstChild);
document.getElementById("enhancedShowSidebar").addEventListener("click", function() {
document.getElementById("mSnb").classList.remove('enhanced_sidebar_hidden');
document.getElementById("enhancedShowSidebar").style.display = 'none';
SetValue('enhancedSidebarShow', 'true');
});
if (GetValue('enhancedSidebarShow', 'true') === 'false')
{
document.getElementById("mSnb").classList.add('enhanced_sidebar_hidden');
document.getElementById("enhancedShowSidebar").style.display = 'block';
}
else
{
document.getElementById("mSnb").classList.remove('enhanced_sidebar_hidden');
document.getElementById("enhancedShowSidebar").style.display = 'none';
}
}
const eventHandlerModule = (function() {
let clickEventByIdMap = new Map();
function initialize()
{
document.addEventListener('click', function(event) {
if (clickEventByIdMap.has(event.target.id))
{
clickEventByIdMap.get(event.target.id)();
}
});
}
function addClickEventById(elemId, func)
{
clickEventByIdMap.set(elemId, func);
}
return {
initialize: initialize,
addClickEventById: addClickEventById
}
})();
const deleteFriendsModule = (function() {
let deletedFriendCount = 0;
let jsonMyFriends;
function initialize()
{
eventHandlerModule.addClickEventById('enhancedBtnDeleteFriendConfirm', deleteFriendsConfirm);
eventHandlerModule.addClickEventById('enhancedBtnDeleteBlockedFriendConfirm', deleteBlockedFriendsConfirm);
eventHandlerModule.addClickEventById('deleteFriendConfirmCancel', function() {
document.getElementById("deleteLayer").remove();
});
eventHandlerModule.addClickEventById('deleteFriendConfirmOK', function() {
document.getElementById("deleteLayer").remove();
deleteFriendsReConfirm();
});
eventHandlerModule.addClickEventById('deleteBlockedFriendConfirmCancel', function() {
document.getElementById("deleteBlockedLayer").remove();
});
eventHandlerModule.addClickEventById('deleteBlockedFriendConfirmOK', function() {
loadForDeleteFriends(true);
});
eventHandlerModule.addClickEventById('deleteFriendReConfirmCancel', function() {
document.getElementById("deleteLayer").remove();
});
eventHandlerModule.addClickEventById('deleteFriendReConfirmOK', function() {
loadForDeleteFriends(false);
});
eventHandlerModule.addClickEventById('deleteFriendComplete', function() {
document.getElementById("deleteLayer").remove();
document.getElementById("deleteCountLayer").remove();
});
eventHandlerModule.addClickEventById('enhancedFastDeleteClose', function() {
document.getElementById("fastDeleteLayer").remove();
});
eventHandlerModule.addClickEventById('enhancedBtnFastDeleteFriendConfirm', function() {
OpenFastDeleteFriend();
});
}
function loadForDeleteFriends(blockedUserOnly) {
let xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState === 4 && xmlHttp.status === 200) {
jsonMyFriends = JSON.parse(xmlHttp.responseText);
let deleteCountLayer = document.createElement('div');
deleteCountLayer.id = "deleteCountLayer";
deleteCountLayer.className = "cover _cover";
document.body.appendChild(deleteCountLayer);
document.getElementById('deleteCountLayer').innerHTML = '<div class="dimmed dimmed50" style="z-index: 201;"></div><div class="cover_wrapper" style="z-index: 201;"><div class="toast_popup cover_content cover_center" tabindex="-1" style="top: 436px; margin-left: -170px;"><div class="inner_toast_layer _toastBody"><p class="txt _dialogText" id="deleteFriendText">친구 삭제 중... (0 / 0)</p><div>※정책상 삭제 속도는 느리게 설정되었습니다.<br>취소하시려면 새로고침 하세요.</div><div class="btn_group"><a href="#" class="btn_com btn_or _dialogOk _dialogBtn" id="deleteFriendComplete" style="display: none;"><span>확인</span></a> </div></div></div></div>';
//deletedFriendCount = 0;
if (blockedUserOnly)
{
verifyBlockedUserForDeleteFriends();
}
deleteFriends();
}
}
xmlHttp.open("GET", "https://story.kakao.com/a/friends");
xmlHttp.setRequestHeader("x-kakao-apilevel", "49");
xmlHttp.setRequestHeader("x-kakao-deviceinfo", "web:d;-;-");
xmlHttp.setRequestHeader("Accept", "application/json");
xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xmlHttp.send();
}
// Remove unblocked users to remove blocked users only
function verifyBlockedUserForDeleteFriends()
{
for (let i = 0; i < jsonMyFriends.profiles.length; i++)
{
if (!jsonMyFriends.profiles[i].hasOwnProperty("blocked") || jsonMyFriends.profiles[i]["blocked"] === false)
{
jsonMyFriends.profiles.splice(i, 1);
i--;
}
}
}
function deleteBlockedFriendsConfirm()
{
let deleteLayer = document.createElement('div');
deleteLayer.id = "deleteBlockedLayer";
deleteLayer.className = "cover _cover";
document.body.appendChild(deleteLayer);
document.getElementById('deleteBlockedLayer').innerHTML = '<div class="dimmed dimmed50" style="z-index: 201;"></div>' +
'<div class="cover_wrapper" style="z-index: 201;">' +
'<div class="toast_popup cover_content cover_center" tabindex="-1" style="top: 436px; margin-left: -170px;">' +
'<div class="inner_toast_layer _toastBody">' +
'<p class="txt _dialogText">정말 제한된 사용자를 전체 삭제하시겠습니까?<br>취소하시려면 새로고침해야 합니다.</p>' +
'<div class="btn_group">' +
'<a href="#" class="btn_com btn_wh _dialogCancel _dialogBtn" id="deleteBlockedFriendConfirmCancel"><span style="pointer-events: none;">취소</span></a>' +
'<a href="#" class="btn_com btn_or _dialogOk _dialogBtn" id="deleteBlockedFriendConfirmOK"><span style="pointer-events: none;">확인</span></a>' +
'</div>' +
'</div>' +
'</div>' +
'</div>';
}
function deleteFriendsConfirm()
{
let deleteLayer = document.createElement('div');
deleteLayer.id = "deleteLayer";
deleteLayer.className = "cover _cover";
document.body.appendChild(deleteLayer);
document.getElementById('deleteLayer').innerHTML = '<div class="dimmed dimmed50" style="z-index: 201;"></div>' +
'<div class="cover_wrapper" style="z-index: 201;">' +
'<div class="toast_popup cover_content cover_center" tabindex="-1" style="top: 436px; margin-left: -170px;">' +
'<div class="inner_toast_layer _toastBody">' +
'<p class="txt _dialogText">정말 친구를 전체 삭제하시겠습니까?<br>취소하시려면 새로고침해야 합니다.<br>취소하더라도 이미 삭제된 친구는 복구되지 않습니다!</p>' +
'<div class="btn_group">' +
'<a href="#" class="btn_com btn_wh _dialogCancel _dialogBtn" id="deleteFriendConfirmCancel"><span style="pointer-events: none;">취소</span></a>' +
'<a href="#" class="btn_com btn_or _dialogOk _dialogBtn" id="deleteFriendConfirmOK"><span style="pointer-events: none;">확인</span></a>' +
'</div>' +
'</div>' +
'</div>' +
'</div>';
}
function deleteFriendsReConfirm()
{
let deleteLayer = document.createElement('div');
deleteLayer.id = "deleteLayer";
deleteLayer.className = "cover _cover";
document.body.appendChild(deleteLayer);
document.getElementById('deleteLayer').innerHTML = '<div class="dimmed dimmed50" style="z-index: 201;"></div>' +
'<div class="cover_wrapper" style="z-index: 201;">' +
'<div class="toast_popup cover_content cover_center" tabindex="-1" style="top: 436px; margin-left: -170px;">' +
'<div class="inner_toast_layer _toastBody">' +
'<p class="txt _dialogText">정말 친구를 전체 삭제하시겠습니까?<br>진행하면 되돌릴 수 없습니다!<br>다시 한 번 신중하게 생각해주세요!<br>취소하시려면 새로고침해야 합니다.<br>취소하더라도 이미 삭제된 친구는 복구되지 않습니다!</p>' +
'<div class="btn_group">' +
'<a href="#" class="btn_com btn_wh _dialogCancel _dialogBtn" id="deleteFriendReConfirmCancel"><span style="pointer-events: none;">취소</span></a>' +
'<a href="#" class="btn_com btn_or _dialogOk _dialogBtn" id="deleteFriendReConfirmOK"><span style="pointer-events: none;">확인</span></a>' +
'</div>' +
'</div>' +
'</div>' +
'</div>';
}
function deleteFriends() {
setTimeout(function() {
if (deletedFriendCount < jsonMyFriends.profiles.length) {
_deleteFriend(jsonMyFriends.profiles[deletedFriendCount]["id"]);
document.getElementById('deleteFriendText').innerHTML = '친구 삭제 중... (' + (deletedFriendCount + 1) + ' / ' + jsonMyFriends.profiles.length + ')';
deletedFriendCount++;
deleteFriends();
} else {
document.getElementById('deleteFriendText').innerHTML = '전체 삭제 완료';
document.getElementById('deleteFriendComplete').style.display = 'block';
}
}, 300);
}
function _deleteFriend(userid) {
let xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState === 4 && xmlHttp.status === 200) {
//Deleted Message;
}
}
xmlHttp.open("DELETE", "https://story.kakao.com/a/friends/" + userid);
xmlHttp.setRequestHeader("x-kakao-apilevel", "49");
xmlHttp.setRequestHeader("x-kakao-deviceinfo", "web:d;-;-");
xmlHttp.setRequestHeader("Accept", "application/json");
xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xmlHttp.send();
}
function OpenFastDeleteFriend()
{
let fastDeleteLayer = document.createElement('div');
fastDeleteLayer.id = "fastDeleteLayer";
fastDeleteLayer.className = "cover _cover";
document.body.appendChild(fastDeleteLayer);
document.getElementById('fastDeleteLayer').innerHTML = '<div class="dimmed dimmed50" style="z-index: 201;"></div><div class="cover_wrapper" style="z-index: 201;"><div class="story_layer story_feed_layer cover_content cover_center" data-kant-group="like"><div class="inner_story_layer _layerContainer" style="top: 630px;"><div class="layer_head"><strong class="tit_story">빠른 친구삭제</strong></div><div class="layer_body"><div class="fake_scroll"><ul id="enhancedFastDeleteTable" class="list_people list_people_v2 _listContainer" style="overflow-y: scroll;"></ul><div class="scroll" style="display: none; height: 60px;"><span class="top"></span><span class="bottom"></span></div></div></div><div class="layer_foot"><a href="#" class="btn_close _close" data-kant-id="false"><span id="enhancedFastDeleteClose" class="ico_ks ico_close">닫기</span></a></div></div></div></div>';
document.body.scrollTop = 0;
let xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState === 4 && xmlHttp.status === 200) {
let friends = JSON.parse(xmlHttp.responseText);
for (let i = 0; i < friends.profiles.length; i++)
{
let liFriend = document.createElement('li');
let friendProfileImageL = friends['profiles'][i]['profile_image_url'];
let friendProfileImageS = friends['profiles'][i]['profile_thumbnail_url'];
let friendName = friends['profiles'][i]['display_name'];
let friendID = friends['profiles'][i]['id'];
liFriend.id = "enhancedFastDelFriend_" + friendID;
document.getElementById("enhancedFastDeleteTable").appendChild(liFriend);
document.getElementById("enhancedFastDelFriend_" + friendID).innerHTML = '<a href="/' + friendID + '" class="link_people"><span class="thumb_user"><span class="img_profile thumb_img"><img src="' + friendProfileImageL + '" width="36" height="36" data-image-src="' + friendProfileImageS + '" data-movie-src="" class="img_thumb" alt=""></span></span> <span class="info_user"><span class="inner_user"><span class="txt_user"><em class="tit_userinfo">' + friendName + '</em></span></span></span></a><div class="btn_group btn_group_v2"><a href="#" id="' + 'btnEnhancedFastDelFriend_' + friendID + '" class="btn_com btn_wh _acceptFriend fastDelBtn"><span>삭제</span></a></div>';
document.getElementById("btnEnhancedFastDelFriend_" + friendID).addEventListener("click", function() {
_deleteFriend(friendID);
liFriend.remove();
});
}
}
}
xmlHttp.open("GET", "https://story.kakao.com/a/friends");
xmlHttp.setRequestHeader("x-kakao-apilevel", "49");
xmlHttp.setRequestHeader("x-kakao-deviceinfo", "web:d;-;-");
xmlHttp.setRequestHeader("Accept", "application/json");
xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xmlHttp.send();
}
return {
initialize: initialize
};
})();
const removeAllArticlesModule = (function() {
let jsonRemoveActivities;
let removedArticleCount = 0;
let removedArticleInternalCount = 0;
let removeArticlesUserID;
let removeArticlesActivityCount;
function initialize()
{
eventHandlerModule.addClickEventById('enhancedBtnRemoveAllArticlesConfirm', removeAllArticlesConfirm);
eventHandlerModule.addClickEventById('removeAllArticlesConfirmCancel', function() {
document.getElementById("deleteLayer").remove();
});
eventHandlerModule.addClickEventById('removeAllArticlesConfirmOK', function() {
document.getElementById("deleteLayer").remove();
removeAllArticlesReConfirm();
});
eventHandlerModule.addClickEventById('removeAllArticlesReConfirmCancel', function() {
document.getElementById("deleteLayer").remove();
});
eventHandlerModule.addClickEventById('removeAllArticlesReConfirmOK', function() {
prepareRemoveAllArticles();
});
eventHandlerModule.addClickEventById('removeAllArticlesBtnOK', function() {
document.getElementById("deleteLayer").remove();
document.getElementById("removeAllArticlesCountLayer").remove();
});
}
function removeAllArticlesConfirm()
{
let deleteLayer = document.createElement('div');
deleteLayer.id = "deleteLayer";
deleteLayer.className = "cover _cover";
document.body.appendChild(deleteLayer);
document.getElementById('deleteLayer').innerHTML = '<div class="dimmed dimmed50" style="z-index: 201;"></div>' +
'<div class="cover_wrapper" style="z-index: 201;">' +
'<div class="toast_popup cover_content cover_center" tabindex="-1" style="top: 436px; margin-left: -170px;">' +
'<div class="inner_toast_layer _toastBody">' +
'<p class="txt _dialogText">정말 게시글을 전체 삭제하시겠습니까?<br>취소하시려면 새로고침해야 합니다.<br>취소하더라도 이미 삭제된 게시글은 복구되지 않습니다!</p>' +
'<div class="btn_group">' +
'<a href="#" class="btn_com btn_wh _dialogCancel _dialogBtn" id="removeAllArticlesConfirmCancel"><span style="pointer-events: none;">취소</span></a>' +
'<a href="#" class="btn_com btn_or _dialogOk _dialogBtn" id="removeAllArticlesConfirmOK"><span style="pointer-events: none;">확인</span></a>' +
'</div>' +
'</div>' +
'</div>' +
'</div>';
}
function removeAllArticlesReConfirm()
{
let deleteLayer = document.createElement('div');
deleteLayer.id = "deleteLayer";
deleteLayer.className = "cover _cover";
document.body.appendChild(deleteLayer);
document.getElementById('deleteLayer').innerHTML = '<div class="dimmed dimmed50" style="z-index: 201;"></div>' +
'<div class="cover_wrapper" style="z-index: 201;">' +
'<div class="toast_popup cover_content cover_center" tabindex="-1" style="top: 436px; margin-left: -170px;">' +
'<div class="inner_toast_layer _toastBody">' +
'<p class="txt _dialogText">정말 게시글을 전체 삭제하시겠습니까?<br>진행하면 되돌릴 수 없습니다!<br>다시 한 번 신중하게 생각해주세요!<br>취소하시려면 새로고침해야 합니다.<br>취소하더라도 이미 삭제된 게시글은 복구되지 않습니다!</p>' +
'<div class="btn_group">' +
'<a href="#" class="btn_com btn_wh _dialogCancel _dialogBtn" id="removeAllArticlesReConfirmCancel"><span style="pointer-events: none;">취소</span></a>' +
'<a href="#" class="btn_com btn_or _dialogOk _dialogBtn" id="removeAllArticlesReConfirmOK"><span style="pointer-events: none;">확인</span></a>' +
'</div>' +
'</div>' +
'</div>' +
'</div>';
}
function _removeArticle(articleID)
{
let xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState === 4 && xmlHttp.status === 200) {
// Removed
}
}
xmlHttp.open("DELETE", "https://story.kakao.com/a/activities/" + articleID);
xmlHttp.setRequestHeader("x-kakao-apilevel", "49");
xmlHttp.setRequestHeader("x-kakao-deviceinfo", "web:d;-;-");
xmlHttp.setRequestHeader("Accept", "application/json");
xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xmlHttp.setRequestHeader("Accept-Language", "ko");
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")
xmlHttp.send();
}
function loadActivitiesForRemove(userID, lastArticleID) {
let xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState === 4 && xmlHttp.status === 200) {
let activities = JSON.parse(xmlHttp.responseText);
if (activities.length === 0) {
jsonRemoveActivities = null;
document.getElementById('removeAllArticlesText').innerHTML = '게시글이 성공적으로 삭제되었습니다.';
document.getElementById('removeAllArticlesBtnOK').style.display = 'block';
return;
}
jsonRemoveActivities = activities;
removeActivities();
}
}
xmlHttp.open("GET", "https://story.kakao.com/a/profiles/" + userID + "/activities?ag=false&since=" + lastArticleID);
xmlHttp.setRequestHeader("x-kakao-apilevel", "49");
xmlHttp.setRequestHeader("x-kakao-deviceinfo", "web:d;-;-");
xmlHttp.setRequestHeader("Accept", "application/json");
xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xmlHttp.send();
}
function removeActivities()
{
setTimeout(function() {
if (removedArticleInternalCount < jsonRemoveActivities.length - 1)
{
let activity = jsonRemoveActivities[removedArticleInternalCount];
let lArticleID = activity["sid"];
_removeArticle(lArticleID);
document.getElementById('removeAllArticlesText').innerHTML = '게시글 삭제 중... (' + (removedArticleCount + 1) + '/' + removeArticlesActivityCount + '개 완료)';
removedArticleCount++;
removedArticleInternalCount++;
removeActivities();
}
else
{
let activity = jsonRemoveActivities[removedArticleInternalCount];
let lArticleID = activity["sid"];
removedArticleInternalCount = 0;
loadActivitiesForRemove(removeArticlesUserID, jsonRemoveActivities[jsonRemoveActivities.length - 1]["sid"]);
_removeArticle(lArticleID);
}
}, 550);
}
function prepareRemoveAllArticles() {
removedArticleCount = 0; //reset count
let xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState === 4 && xmlHttp.status === 200) {
let jsonProfile = JSON.parse(xmlHttp.responseText);
removeArticlesUserID = jsonProfile.id;
removeArticlesActivityCount = jsonProfile.activity_count;
let removeAllArticlesCountLayer = document.createElement('div');
removeAllArticlesCountLayer.id = "removeAllArticlesCountLayer";
removeAllArticlesCountLayer.className = "cover _cover";
document.body.appendChild(removeAllArticlesCountLayer);
document.getElementById('removeAllArticlesCountLayer').innerHTML = '<div class="dimmed dimmed50" style="z-index: 201;"></div><div class="cover_wrapper" style="z-index: 201;"><div class="toast_popup cover_content cover_center" tabindex="-1" style="top: 436px; margin-left: -170px;"><div class="inner_toast_layer _toastBody"><p class="txt _dialogText" id="removeAllArticlesText">게시글 삭제 중... (0 / 0)</p><div>※정책상 변경 속도는 느리게 설정되었습니다.<br>취소하시려면 새로고침 하세요.</div><div class="btn_group"><a href="#" class="btn_com btn_or _dialogOk _dialogBtn" id="removeAllArticlesBtnOK" style="display: none;"><span style="pointer-events: none;">확인</span></a> </div></div></div></div>';
loadActivitiesForRemove(removeArticlesUserID, "");
}
}
xmlHttp.open("GET", "https://story.kakao.com/a/settings/profile");
xmlHttp.setRequestHeader("x-kakao-apilevel", "49");
xmlHttp.setRequestHeader("x-kakao-deviceinfo", "web:d;-;-");
xmlHttp.setRequestHeader("Accept", "application/json");
xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xmlHttp.send();
}
return {
initialize: initialize
};
})();
const changePermissionModule = (function() {
let jsonPermActivities;
let changePermCount = 0;
let changeInternalPermCount = 0;
let changePermUserID;
let changePermActivityCount;
function initialize() {
eventHandlerModule.addClickEventById('enhancedBtnChangePermConfirm', ChangePermissionConfirm);
eventHandlerModule.addClickEventById('changePermissionConfirmOK', PrepareChangePermission);
eventHandlerModule.addClickEventById('changePermissionConfirmCancel', function() {
document.getElementById("changePermLayer").remove();
});
eventHandlerModule.addClickEventById('changePermissionBtnOK', function() {
document.getElementById("changePermLayer").remove();
document.getElementById("changePermissionCountLayer").remove();
});
}
function ChangePermissionConfirm()
{
let sourcePermissionElem = document.getElementById("enhancedOptionSourcePerm");
let sourcePermissionText = sourcePermissionElem.options[sourcePermissionElem.selectedIndex].text;
let destPermissionElem = document.getElementById("enhancedOptionDestPerm");
let destPermissionText = destPermissionElem.options[destPermissionElem.selectedIndex].text;
let changePermLayer = document.createElement('div');
changePermLayer.id = "changePermLayer";
changePermLayer.className = "cover _cover";
document.body.appendChild(changePermLayer);
document.getElementById('changePermLayer').innerHTML = '<div class="dimmed dimmed50" style="z-index: 201;"></div>' +
'<div class="cover_wrapper" style="z-index: 201;">' +
'<div class="toast_popup cover_content cover_center" tabindex="-1" style="top: 436px; margin-left: -170px;">' +
'<div class="inner_toast_layer _toastBody">' +
'<p class="txt _dialogText">' + sourcePermissionText + ' 권한 게시글을 ' + destPermissionText + '로 변경할까요? 취소하시려면 새로고침해야 합니다.</p>' +
'<div class="btn_group">' +
'<a href="#" class="btn_com btn_wh _dialogCancel _dialogBtn" id="changePermissionConfirmCancel"><span style="pointer-events: none;">취소</span></a>' +
'<a href="#" class="btn_com btn_or _dialogOk _dialogBtn" id="changePermissionConfirmOK"><span style="pointer-events: none;">확인</span></a>' +
'</div>' +
'</div>' +
'</div>' +
'</div>';
}
function _ChangePermission(articleID, perm, enableShare /*, commentWriteable, isMustRead*/)
{
let xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState === 4 && xmlHttp.status === 200) {
//Changed
}
}
if (perm === 'M')
enableShare = "false";
xmlHttp.open("PUT", "https://story.kakao.com/a/activities/" + articleID);
xmlHttp.setRequestHeader("x-kakao-apilevel", "49");
xmlHttp.setRequestHeader("x-kakao-deviceinfo", "web:d;-;-");
xmlHttp.setRequestHeader("Accept", "application/json");
xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xmlHttp.setRequestHeader("Accept-Language", "ko");
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")
xmlHttp.send("permission=" + perm + "&enable_share=" + enableShare + "&comment_all_writable=true&is_must_read=false");
}
function LoadActivitiesForPermission(userID, lastArticleID) {
let xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState === 4 && xmlHttp.status === 200) {
let activities = JSON.parse(xmlHttp.responseText);
if (activities.length === 0) {
jsonPermActivities = null;
document.getElementById('changePermissionText').innerHTML = '게시글 권한이 성공적으로 변경되었습니다.';
document.getElementById('changePermissionBtnOK').style.display = 'block';
return;
}
jsonPermActivities = activities;
SetPermissionActivities();
}
}
xmlHttp.open("GET", "https://story.kakao.com/a/profiles/" + userID + "/activities?ag=false&since=" + lastArticleID);
xmlHttp.setRequestHeader("x-kakao-apilevel", "49");
xmlHttp.setRequestHeader("x-kakao-deviceinfo", "web:d;-;-");
xmlHttp.setRequestHeader("Accept", "application/json");
xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xmlHttp.send();
}
function SetPermissionActivities()
{
setTimeout(function() {
if (changeInternalPermCount < jsonPermActivities.length)
{
let activity = jsonPermActivities[changeInternalPermCount];
let lArticleID = activity["sid"];
let permission = activity["permission"];
let sourcePermission = document.getElementById("enhancedOptionSourcePerm").value;
let destPermission = document.getElementById("enhancedOptionDestPerm").value;
/* For user-set permissions */
//var isMustRead = activity["is_must_read"];
//var commentWriteable = activity["comment_all_writable"];
var shareable = activity["shareable"];
var shareableChecked = document.getElementById("enhancedShareFriendsEnablePermChange").checked;
var shareableCheckedStr = shareableChecked === true ? "true" : "false";
if ((permission === sourcePermission || sourcePermission === 'N') && (destPermission !== permission || shareable != shareableCheckedStr))
{
_ChangePermission(lArticleID, destPermission, shareableCheckedStr/*, commentWriteable, isMustRead*/);
}
document.getElementById('changePermissionText').innerHTML = '게시글 권한 변경 중... (' + (changePermCount + 1) + '/' + changePermActivityCount + '개 완료)';
changePermCount++;
changeInternalPermCount++;
SetPermissionActivities();
}
else
{
changeInternalPermCount = 0;
LoadActivitiesForPermission(changePermUserID, jsonPermActivities[jsonPermActivities.length - 1]["sid"]);
}
}, 550);
}
function PrepareChangePermission() {
changePermCount = 0; //reset count
let xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState === 4 && xmlHttp.status === 200) {
let jsonProfile = JSON.parse(xmlHttp.responseText);
changePermUserID = jsonProfile.id;
changePermActivityCount = jsonProfile.activity_count;
let permissionCountLayer = document.createElement('div');
permissionCountLayer.id = "changePermissionCountLayer";
permissionCountLayer.className = "cover _cover";
document.body.appendChild(permissionCountLayer);
document.getElementById('changePermissionCountLayer').innerHTML = '<div class="dimmed dimmed50" style="z-index: 201;"></div><div class="cover_wrapper" style="z-index: 201;"><div class="toast_popup cover_content cover_center" tabindex="-1" style="top: 436px; margin-left: -170px;"><div class="inner_toast_layer _toastBody"><p class="txt _dialogText" id="changePermissionText">게시글 권한 변경 중... (0 / 0)</p><div>※정책상 변경 속도는 느리게 설정되었습니다.<br>취소하시려면 새로고침 하세요.</div><div class="btn_group"><a href="#" class="btn_com btn_or _dialogOk _dialogBtn" id="changePermissionBtnOK" style="display: none;"><span style="pointer-events: none;">확인</span></a> </div></div></div></div>';
LoadActivitiesForPermission(changePermUserID, "");
}
}
xmlHttp.open("GET", "https://story.kakao.com/a/settings/profile");
xmlHttp.setRequestHeader("x-kakao-apilevel", "49");
xmlHttp.setRequestHeader("x-kakao-deviceinfo", "web:d;-;-");
xmlHttp.setRequestHeader("Accept", "application/json");
xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xmlHttp.send();
}
return {
initialize: initialize
}
})();
const loginThemeModule = (function() {
let svgDark = '<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="#000000" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" class="feather feather-moon"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path></svg>';
let svgLight = '<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="#ffffff" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" class="feather feather-sun"><circle cx="12" cy="12" r="5"></circle><line x1="12" y1="1" x2="12" y2="3"></line><line x1="12" y1="21" x2="12" y2="23"></line><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line><line x1="1" y1="12" x2="3" y2="12"></line><line x1="21" y1="12" x2="23" y2="12"></line><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line></svg>';
function initialize()
{
addThemeButton();
changeLoginTheme(GetValue('enhancedSelectThemeLogin', 'dark'));
}
function changeLoginTheme(theme)
{
if (theme === 'light')
{
document.querySelector('style').remove(); //Remove Dark Theme CSS
document.getElementById('enhancedLoginThemeChangeBtn').innerHTML = svgDark;
}
else // Light
{
setLoginDarkThemeCSS();
document.getElementById('enhancedLoginThemeChangeBtn').innerHTML = svgLight;
SetValue('enhancedSelectThemeLogin', 'dark');
}
}
function addThemeButton()
{
let btnLoginThemeElem = document.createElement('button');
btnLoginThemeElem.id = 'enhancedLoginThemeChangeBtn';
btnLoginThemeElem.innerHTML = svgDark;
btnLoginThemeElem.style.height = '48px';
btnLoginThemeElem.style.width = '48px';
btnLoginThemeElem.style.background = 'none';
btnLoginThemeElem.style.position = 'absolute';
btnLoginThemeElem.style.right = '10px';
btnLoginThemeElem.style.bottom = '10px';
let loginTheme = GetValue('enhancedSelectThemeLogin', 'dark');
btnLoginThemeElem.innerHTML = loginTheme === 'dark'? svgLight : svgDark;
btnLoginThemeElem.onclick = function() {
let theme = GetValue('enhancedSelectThemeLogin', 'dark');
theme = theme === 'dark'? 'light' : 'dark';
SetValue('enhancedSelectThemeLogin', theme);
changeLoginTheme(theme);
}
document.body.appendChild(btnLoginThemeElem);
}
function setLoginDarkThemeCSS()
{
const loginDarkThemeStyle = {
'--background-color': '#2f3136',
'--text-color': '#dcddde',
'--text-highlight-color': '#fff',
'--text-menu-color': '#b9bbbe',
'--discord-blue': '#7289da',
'--dark-background-color': '#202225'
}
for (const [key, value] of Object.entries(loginDarkThemeStyle))
{
document.documentElement.style.setProperty(key, value);
}
let styleElem = document.createElement('style');
styleElem.id = 'enhancedLoginDarkThemeCSS';
document.head.appendChild(styleElem);
document.getElementById('enhancedLoginDarkThemeCSS').innerHTML =
'body { background: var(--background-color) !important; }' +
'.set_login .lab_choice { color: var(--text-color) !important; }' +
'.doc-footer .txt_copyright { color: var(--text-color) !important; }' +
'a { color: var(--text-highlight-color) !important; }' +
'.cont_login a { color: var(--text-menu-color) !important; }' +
'.doc-footer .service_info .link_info { color: var(--text-menu-color) !important; }' +
'.item_select .link_selected { color: var(--text-menu-color) !important; }' +
'.box_tf { border: solid 0px var(--text-highlight-color) !important; background: var(--dark-background-color) !important; padding-left: 10px; padding-right: 10px; }' +
'.box_tf .tf_g { color: var(--text-color) !important; caret-color: auto !important; }' +
'.info_tip, .line_or .txt_or { color: var(--text-color) !important;}' +
'.info_tip .txt_tip { color: var(--discord-blue) !important; }' +
'.box_tf .txt_mail { color: var(--text-color) !important; margin-right: 10px !important }' +
'.doc-title .tit_service .logo_kakao { background: var(--background-color) url(/images/pc/logo_kakao.png) no-repeat 0 0 !important; background-size: 100px 80px !important; background-position: 0 -41px !important};';
}
return {
initialize: initialize
}
})();
const visitorChartModule = ( function() {
function addVisitorCountLayer()
{
let visitorCountLayer = document.createElement("div");
visitorCountLayer.id = "enhancedVisitorCountLayer";
visitorCountLayer.className = "profile_collection visitor_count_layer";
document.getElementsByClassName("profile_collection")[0].parentElement.appendChild(visitorCountLayer);
visitorCountLayer.innerHTML = '<fieldset><h4 class="tit_collection">방문자수</h4></br><div style=""><canvas id="visitorChartCanvas"></canvas></div></fieldset>';
}
function parseVisitorCount(jsonData)
{
let counterJSON = null;
for (let i = 0; i < jsonData.length; i++)
{
if (jsonData[i].type === "visit_counter")
{
counterJSON = jsonData[i].object.items;
break;
}
}
if (counterJSON == null)
{
document.getElementById("enhancedVisitorCountLayer").style.display = 'none';
return;
}
let labelData = ['', '', '', '', '', '', ''];
let countData = [0, 0, 0, 0, 0, 0, 0];
for (let i = 0; i < counterJSON.length; i++)
{
labelData[i] = counterJSON[i].date;
countData[i] = (counterJSON[i].count === -1? 0 : counterJSON[i].count);
}
let chartCanvas = document.getElementById('visitorChartCanvas').getContext('2d');
new Chart(chartCanvas, {
type: 'line',
data: {
labels: labelData,
datasets: [
{
fill: false,
data: countData,
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
],
borderColor: [
'rgba(255, 99, 132, 1)',
],
borderWidth: 1
}
]
},
options: {
plugins: {
legend: {
display: false
}
}
}
})
}
function viewVisitorChart()
{
if (document.getElementById("enhancedVisitorCountLayer") != null)
{
return;
}
if (document.getElementsByClassName("profile_collection").length < 1)
{
return;
}
let pathname = window.location.pathname;
let pathList = pathname.split("/");
if (pathList.length < 3)
{
return;
}
let curUserID = pathList[1];
addVisitorCountLayer();
let xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState === 4 && xmlHttp.status === 200) {
let highlights = JSON.parse(xmlHttp.responseText);
parseVisitorCount(highlights.highlight);
}
}
xmlHttp.open("GET", "https://story.kakao.com/a/profiles/" + curUserID + "/highlight");
xmlHttp.setRequestHeader("x-kakao-apilevel", "49");
xmlHttp.setRequestHeader("x-kakao-deviceinfo", "web:d;-;-");
xmlHttp.setRequestHeader("Accept", "application/json");
xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xmlHttp.send();
}
return {
viewVisitorChart: viewVisitorChart
}
})();
function EnableScroll() {
window.onscroll = function() {};
}
function DisableScroll() {
window.onscroll = function() {
window.scrollTo(0, 0);
};
}
function GetMyID() {
let userId = document.querySelector('a[data-kant-id="737"]')?.getAttribute('href')?.substring(1);
if (userId.charAt(0) === '_') {
myID = userId;
} else {
GetMySID(userId);
}
}
function GetMySID(val) {
let xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState === 4 && xmlHttp.status === 200) {
let jsonProf = JSON.parse(xmlHttp.responseText);
if (jsonProf.activities.length === 0) {
myID = '';
} else {
let tmpID = jsonProf.activities[0].id;
myID = tmpID.split(".")[0];
}
}
}
xmlHttp.open("GET", "https://story.kakao.com/a/profiles/" + val + "?with=activities");
xmlHttp.setRequestHeader("x-kakao-apilevel", "49");
xmlHttp.setRequestHeader("x-kakao-deviceinfo", "web:d;-;-");
xmlHttp.setRequestHeader("Accept", "application/json");
xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xmlHttp.send();
}
function HighlightCommentLikeDiscord() {
let comments = document.getElementsByClassName("_commentContent");
for (let i = 0; i < comments.length; i++) {
let tmpComment = comments[i].getElementsByClassName("txt")[0].getElementsByClassName("_decoratedProfile");
for ( let j = 0; j < tmpComment.length; j++) {
let tmpUserID = tmpComment[j].getAttribute("data-id");
if (myID === tmpUserID) {
tmpComment[j].style.cssText = "background-color:rgba(0,0,0,0) !important;";
comments[i].parentElement.style.cssText = 'background-color: rgba(250,166,26,0.1); border-left: 5px solid #f6a820; padding-left: 4px;';
}
}
}
}
function InitImagePasteEvent()
{
document.addEventListener('paste', async function (e) {
const items = e.clipboardData?.items;
if (!items) return;
for (let i = 0; i < items.length; i++)
{
const item = items[i];
if (item.kind === 'file' && item.type.startsWith('image/')) {
const file = item.getAsFile();