-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
content.js
1571 lines (1553 loc) · 100 KB
/
content.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
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
const prototype_version = false;
//
console.log("Welcome to Open-Deck!");
if(prototype_version){
console.log("%cOpen-Deck Prototype", "background:#a1f4ff;padding:5px;border-radius:5px", `Version:${chrome.runtime.getManifest().version}`);
}else{
console.log("%cOpen-Deck", "background:#a1f4ff;padding:5px;border-radius:5px", `Version:${chrome.runtime.getManifest().version}`);
}
//
const url_path = new URL(location.href);
let profile_store;
let last_load_profile = 0;
const ui_icon_define = {
banner_hide:"icon/banner_hide.svg",
top_bar_hide:"icon/top_hide.svg",
column_move:"icon/column_move.svg",
column_close:"icon/column_close.svg",
column_settings: "icon/settings.svg",
column_pin:"icon/pin.svg",
column_pinned:"icon/pinned.svg",
column_widesize:"icon/column_w_size.svg",
column_add_1:"icon/column_add_1st.svg",
column_add_2:"icon/column_add_2nd.svg",
add_timeline_column:"icon/tl_column.svg",
add_notification_column:"icon/notice_column.svg",
add_explore_column:"icon/exp_column.svg",
column_single_rack:"icon/single_view.svg",
column_second_rack:"icon/second_view.svg",
profile_save:"icon/profile_save.svg",
profile_delete:"icon/profile_delete.svg"
}
//UNIX時間分秒変換
function unix_time_mmss(input){
const date = new Date(input * 1000);
return date.toLocaleTimeString();
}
//ストレージの書き込み監視(主にAPIリミット監視に使う)
let api_limit_obj = null;
let api_limit_dsc_obj = {time_line:"", recommend_timeline:"", search:""};
chrome.storage.onChanged.addListener((changes, namespace) => {
if(changes.api_access_limit != undefined){
//console.log(changes)
api_limit_obj = changes.api_access_limit.newValue;
const api_linit_status_btn = document.querySelector("#api_limit_status");
if(api_linit_status_btn != null){
let timeline_limit_percentage = 99999;
let recommend_timeline_limit_percentage = 99999;
let search_limit_percentage = 99999;
if(api_limit_obj.time_line.remaining != null){
timeline_limit_percentage = api_limit_obj.time_line.remaining / api_limit_obj.time_line.limit * 100;
api_limit_dsc_obj.time_line = `タイムライン:${api_limit_obj.time_line.remaining}/${api_limit_obj.time_line.limit}-${unix_time_mmss(api_limit_obj.time_line.reset_unix_time)}\r\n`;
}else{
//初期状態
}
if(api_limit_obj.recommend_timeline.remaining != null){
recommend_timeline_limit_percentage = api_limit_obj.recommend_timeline.remaining / api_limit_obj.recommend_timeline.limit * 100;
api_limit_dsc_obj.recommend_timeline = `タイムライン(おすすめ):${api_limit_obj.recommend_timeline.remaining}/${api_limit_obj.recommend_timeline.limit}-${unix_time_mmss(api_limit_obj.recommend_timeline.reset_unix_time)}\r\n`;
}else{
//初期状態
}
if(api_limit_obj.search.remaining != null){
search_limit_percentage = api_limit_obj.search.remaining / api_limit_obj.search.limit * 100;
api_limit_dsc_obj.search = `検索:${api_limit_obj.search.remaining}/${api_limit_obj.search.limit}-${unix_time_mmss(api_limit_obj.search.reset_unix_time)}`;
}else{
//初期状態
}
api_linit_status_btn.textContent = `${Math.floor(Math.min(timeline_limit_percentage, recommend_timeline_limit_percentage, search_limit_percentage))}%`;
api_linit_status_btn.title = `API使用状況\r\n${api_limit_dsc_obj.time_line}${api_limit_dsc_obj.recommend_timeline}${api_limit_dsc_obj.search}`;
}
}
});
//
if(location.href == "https://twitter.com/run-opdeck" || location.href == "https://x.com/run-opdeck"){
//testmode
if(url_path.pathname == "/run-opdeck_test.html"){
//init();
console.log("testmode")
chrome.runtime.sendMessage({message: "dnr_upd_internal_dsp"}).then((value)=>{
init();
});
}else{
if(navigator.brave != undefined){
chrome.runtime.sendMessage({message: "dnr_upd"}).then((value)=>{
init();
});
//init();
}else{
chrome.runtime.sendMessage({message: "dnr_upd"}).then((value)=>{
init();
});
}
}
//chrome.runtime.sendMessage({message: "dnr_upd"});
function init(){
//console.log("Welcome to Open-Deck!");
chrome.storage.local.get("opd_settings", function(value){
if(value.opd_settings == undefined){
last_load_profile = 0;
settings_init();
}else{
if(JSON.parse(value.opd_settings).last_load_profile == undefined){
if(confirm("プロファイルデータが壊れています。\r\n初期化するにはOKを押してください。\r\n初期化せずに続行する場合はキャンセルを押してください。")){
chrome.storage.local.remove("opd_settings", function(){
alert("初期化が完了しました");
});
}else{
last_load_profile = 0;
}
}else{
last_load_profile = JSON.parse(value.opd_settings).last_load_profile;
}
//console.log(last_load_profile);
}
chrome.storage.local.get("opd_profile_store", function(store_value){
//console.log(store_value)
//console.log(JSON.parse(store_value.opd_profile_store))
profile_store = JSON.parse(store_value.opd_profile_store);
//RUN
let ext_update_flag = null;
let ext_settings = null;
if(value.opd_settings != undefined){
if(JSON.parse(value.opd_settings).version != chrome.runtime.getManifest().version){
ext_update_flag = true;
}else{
ext_update_flag = false;
}
}
if(value.opd_settings == undefined || ext_update_flag == true){
//settings_init();
//ext_settings = JSON.parse(value.opd_settings);
if(profile_store[last_load_profile]?.profile == undefined){
let recovery_setting = JSON.parse(value.opd_settings);
recovery_setting.last_load_profile = 0;
chrome.storage.local.set({'opd_settings': JSON.stringify(recovery_setting)}, function(){
alert("破損した設定データの自動修復を行いました\r\n再読み込みします");
last_load_profile = 0;
window.reload();
});
}
ext_settings = {column_settings:profile_store[last_load_profile].profile};
}else{
//ext_settings = JSON.parse(value.opd_settings);
if(profile_store[last_load_profile]?.profile == undefined){
let recovery_setting = JSON.parse(value.opd_settings);
recovery_setting.last_load_profile = 0;
chrome.storage.local.set({'opd_settings': JSON.stringify(recovery_setting)}, function(){
alert("破損した設定データの自動修復を行いました\r\n再読み込みします");
last_load_profile = 0;
window.reload();
});
}
ext_settings = {column_settings:profile_store[last_load_profile].profile};
}
//console.log(ext_settings);
run(ext_settings);
});
});
}
}
function run(settings){
//console.log(settings)
let profile_list_html;
let profile_list_btn_html = "";
//プロファイルリスト初期化
for (let index = 0; index < profile_store.length; index++) {
profile_list_btn_html += `<div class="dsp_btn_parent" title="プロファイルを切り替える" id="userProfile-${index}"><div class="dsp_btn_change_profile_btn">P${index}</div></div>`;//<div class="profile_list"><input type="button" id="userProfile-${index}" value="P${index}"></div>
}
profile_list_html = `<div class="profile_val_now" title="使用中のプロファイル">${last_load_profile}</div><div class="dsp_profile_list"><div id="profile_btn_list">${profile_list_btn_html}</div>`;
//console.log(profile_list_btn_html)
//CSSタグ追加
document.querySelector("head").insertAdjacentHTML("afterbegin", `<style second_column_css></style>
<style opd_default_css>
html{
overflow-y:hidden !important;
}
.main_bar_functions{
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
margin-top: 0.5rem;
}
.main_bar_functions hr{
width: 80%;
margin: 0;
}
.opd_version_span{
cursor: pointer;
}
.opd_debug_menu{
display: none;
}
#opd_main_element{
background: #e4e4e4 !important;
}
div[opd_column_type="dsp_column"]{
overflow-x: scroll;
scrollbar-width: none;
}
#main_bar_empty_column{
background-color: white;
}
#api_limit_status{
border-radius: 100px;
width: 50px;
}
#api_limit_status:hover{
background-color: #d5d5d5;
cursor: help;
}
.opd_ui_logo_parent{
overflow: hidden;
display: flex;
width: 50px;
align-content: center;
justify-content: center;
align-items: center;
flex-direction: column;
}
.opd_ui_logo{
background-size: cover;
background-repeat: no-repeat;
background-image: url(${chrome.runtime.getURL("icon/logo_icon.svg")});
height: 50px;
width: 50px;
cursor: pointer;
}
.profile_val_now{
border-radius: 100px;
width: 55px;
}
.profile_val_now:hover{
background-color: #d5d5d5;
}
#main_rack_element{
position: fixed;
left:60px;
height:100vh;
max-width:calc(100vw - 60px);
width:calc(100vw - 60px);
overflow:scroll hidden;
}
#first_rack_element{
/*overflow: hidden;*/
}
#second_rack_element{
/*overflow: hidden;*/
}
.dsp_column_emptycolumn p{
text-align: center;
}
.dsp_column_second_emptycolumn p{
text-align: center;
}
.dsp_btn_parent{
overflow: hidden;
border-radius: 100px;
display: flex;
width: 50px;
height: 50px;
align-content: center;
justify-content: center;
align-items: center;
}
.dsp_btn_parent:hover{
background: #d5d5d5;
cursor: pointer;
}
.dsp_btn_add_tl_img{
filter: brightness(0) saturate(100%) invert(11%) sepia(16%) saturate(13%) hue-rotate(322deg) brightness(107%) contrast(80%);
background-size: cover;
background-repeat: no-repeat;
background-image: url(${chrome.runtime.getURL(ui_icon_define.add_timeline_column)});
height: 69%;
width: 69%;
}
.dsp_btn_add_ntfc_img{
filter: brightness(0) saturate(100%) invert(11%) sepia(16%) saturate(13%) hue-rotate(322deg) brightness(107%) contrast(80%);
background-size: cover;
background-repeat: no-repeat;
background-image: url(${chrome.runtime.getURL(ui_icon_define.add_notification_column)});
height: 69%;
width: 69%;
}
.dsp_btn_add_explr_img{
filter: brightness(0) saturate(100%) invert(11%) sepia(16%) saturate(13%) hue-rotate(322deg) brightness(107%) contrast(80%);
background-size: cover;
background-repeat: no-repeat;
background-image: url(${chrome.runtime.getURL(ui_icon_define.add_explore_column)});
height: 69%;
width: 69%;
}
.dsp_btn_second_rack_img{
filter: brightness(0) saturate(100%) invert(11%) sepia(16%) saturate(13%) hue-rotate(322deg) brightness(107%) contrast(80%);
background-size: cover;
background-repeat: no-repeat;
background-image: url(${chrome.runtime.getURL(ui_icon_define.column_second_rack)});
height: 69%;
width: 69%;
}
.dsp_btn_profile_add_img{
filter: brightness(0) saturate(100%) invert(11%) sepia(16%) saturate(13%) hue-rotate(322deg) brightness(107%) contrast(80%);
background-size: cover;
background-repeat: no-repeat;
background-image: url(${chrome.runtime.getURL(ui_icon_define.profile_save)});
height: 69%;
width: 69%;
}
.dsp_btn_profile_delete_img{
filter: brightness(0) saturate(100%) invert(11%) sepia(16%) saturate(13%) hue-rotate(322deg) brightness(107%) contrast(80%);
background-size: cover;
background-repeat: no-repeat;
background-image: url(${chrome.runtime.getURL(ui_icon_define.profile_delete)});
height: 69%;
width: 69%;
}
.dsp_btn_change_profile_btn{
display: flex;
font-size: 1.2rem;
justify-content: center;
align-items: center;
height: 69%;
width: 69%;
}
.dsp_profile_list{
max-height: 1000px;
overflow-y: scroll;
scrollbar-width: none;
}
.dsp_column_draggable_true{
border-left: solid 3px #0000002e;
border-right: solid 3px #0000002e;
border-bottom: solid 3px #0000002e;
/*overflow: hidden;*/
background-color: white;
border-radius: 6px 6px;
}
.dsp_column_draggable_true div[opd_column_type]{
display: flex;
flex-direction: column;
}
.dsp_column iframe{
border: 0;
}
.dsp_column_btn{
width: 20px;
min-width: 20px;
border-radius: 2px;
overflow: hidden;
margin-right: 5px;
}
.dsp_column_btn:hover{
background: #d5d5d5;
cursor: pointer;
}
.column_bar{
display: flex;
flex-direction: row;
width: 100%;
min-height: 20px;
overflow: hidden;
border-top: solid #a0a0a073 1px !important;
border-bottom: solid #a0a0a073 1px !important;
border-radius: 4px 4px 0 0;
}
.dsp_column_title{
width: auto;
background-color: white;
margin-right: 5px;
}
.dsp_column_move_icon_parent{
max-height: 20px;
display: flex;
flex-direction: row;
align-items: center;
}
.dsp_column_move_icon{
display: block;
filter: brightness(0) saturate(100%) invert(61%) sepia(13%) saturate(13%) hue-rotate(335deg) brightness(89%) contrast(79%);
background-image: url(${chrome.runtime.getURL(ui_icon_define.column_move)});
background-size: cover;
width: 15px;
height: 15px;
}
.dsp_column_settings_btn{
display: block;
background-image: url(${chrome.runtime.getURL(ui_icon_define.column_settings)});
background-size: cover;
width: 20px;
height: 20px;
}
.dsp_column_settings_btn:hover{
cursor: pointer;
}
.dsp_column_settings_btn input{
display: none;
}
.dsp_column_close_btn{
display: block;
background-image: url(${chrome.runtime.getURL(ui_icon_define.column_close)});
background-size: 15px;
background-repeat: no-repeat;
background-position: center;
width: 20px;
height: 20px;
}
.dsp_column_close_btn:hover{
cursor: pointer;
}
.dsp_column_close_btn input{
display: none;
}
.dsp_column_banner_btn{
display: block;
background-image: url(${chrome.runtime.getURL(ui_icon_define.banner_hide)});
transform: rotate(180deg);
background-size: cover;
width: 20px;
height: 20px;
}
input:checked + .dsp_column_banner_btn{
transform: rotate(0deg);
}
.dsp_column_btn input{
opacity: 0;
position: absolute;
z-index: 10;
margin: 0;
width: 20px;
height: 20px;
cursor: pointer;
}
.dsp_column_top_btn{
display: block;
background-image: url(${chrome.runtime.getURL(ui_icon_define.top_bar_hide)});
transform: rotate(180deg);
background-size: cover;
width: 20px;
height: 20px;
cursor: pointer;
}
input:checked + .dsp_column_top_btn{
transform: rotate(0deg);
}
.dsp_column_top_btn input{
opacity: 0;
position: absolute;
z-index: 10;
margin: 0;
width: 20px;
height: 20px;
}
.dsp_column_close_btn_wrap{
display: flex;
width: 100%;
justify-content: flex-end;
}
.dsp_column_close_btn input{
display: none;
}
.dsp_column_pin_btn{
display: block;
background-image: url(${chrome.runtime.getURL(ui_icon_define.column_pin)});
background-size: cover;
width: 20px;
height: 20px;
}
input:checked + .dsp_column_pin_btn{
background-image: url(${chrome.runtime.getURL(ui_icon_define.column_pinned)});
}
.dsp_column_pin_btn input{
opacity: 0;
position: absolute;
z-index: 10;
margin: 0;
width: 20px;
height: 20px;
}
.dsp_column_settings_panel{
display: none;
position: relative;
width: inherit;
height: auto;
background: #efefefeb;
border: 1px solid #a9a9a9eb;
flex-direction: column;
}
.dsp_column_settings_panel h2{
/*margin: 0 0 0.2rem;*/
margin: 0;
}
.dsp_column_settings_panel_content{
margin-left: 0.5rem;
}
.dsp_column_settings_panel_content h2{
font-size: 1.2rem;
}
.opd_column_settings_input_text{
width: 5rem;
margin-right: 0.2rem;
}
.dsp_column_settings_list{
background: white;
border-radius: 5px;
margin: 0 0.5rem 0.5rem 0;
padding: 0.5rem;
}
.dsp_column_settings_content_div{
margin-bottom: 0.1rem;
display: flex;
justify-content: space-between;
}
.dsp_column_settings_panel_close_btn_wrap{
display: flex;
flex-direction: row;
justify-content: center;
margin: 0 0.5rem 0.5rem 0;
}
.opd_ui_icon_color{
filter: brightness(0) saturate(100%) invert(11%) sepia(16%) saturate(13%) hue-rotate(322deg) brightness(107%) contrast(80%);
}
/*#main_rack_element section:first-child{
margin-left:110px
}*/
@media (prefers-color-scheme: dark) {
#main_rack_element{
background-color: black !important;
}
.dsp_column_draggable_false, #first_rack_element, #second_rack_element, #second_rack_element, #main_bar_empty_column{
background-color: black !important;
}
.dsp_column_draggable_true, .dsp_column_title{
background-color: #2e2e2e !important;
}
.dsp_btn_add_tl_img, .dsp_btn_add_ntfc_img, .dsp_btn_add_explr_img, .dsp_btn_second_rack_img, .dsp_btn_profile_add_img, .dsp_btn_profile_delete_img, .dsp_column_move_icon, .opd_ui_icon_color{
filter: brightness(0) saturate(100%) invert(48%) sepia(0%) saturate(93%) hue-rotate(266deg) brightness(93%) contrast(86%);
}
#api_limit_status:hover {
background: #555555;
}
.dsp_btn_parent:hover{
background: #555555;
}
.dsp_column_btn:hover {
background: #555555;
}
.profile_val_now:hover {
background: #555555;
}
.dsp_column_settings_panel {
background: #2e2e2e;
border: 1px solid #5d5d5d;
}
.dsp_column_settings_list {
background: #474747
}
}
</style>`);
//カラム要素作成-挿入
let default_element_bar = `<span class="dsp_column_btn"><label class="dsp_column_settings_btn opd_ui_icon_color" title="カラム設定"><input class="opd_settings_btn" type="button" value="S"></label></span><span class="dsp_column_btn"><input class="opd_banner" type="checkbox" title="バナー表示切り替え" %column_banner_ch%><label class="dsp_column_banner_btn opd_ui_icon_color"></label></span><span class="dsp_column_btn"><input class="opd_top_bar" type="checkbox" title="トップ表示切り替え" %column_top_bar_ch%><label class="dsp_column_top_btn opd_ui_icon_color"></label></span>`;
let othersns_default_element_bar = `<span class="dsp_column_btn"><label class="dsp_column_settings_btn opd_ui_icon_color" title="カラム設定"><input class="opd_settings_btn" type="button" value="S"></label></span>`;
let column_settings_panel = `<div class="dsp_column_settings_panel"><div class="dsp_column_settings_panel_content"><h2>設定</h2><div class="dsp_column_settings_list"><div class="dsp_column_settings_content_div">表示モード<span><select class="opd_tw_view_mode" column_tw_view_mode_val="%column_tw_view_mode%"><option value="0">すべて</option><option value="1">テキストのみ</option><option value="2">画像・動画付のみ</option></select></span></div><div class="dsp_column_settings_content_div">カラム幅<span><select class="opd_column_size_preset"><option value="0">小</option><option value="1">中</option><option value="2">大</option><option value="3">カスタム</option></select></span></div><div class="dsp_column_settings_content_div">カラム幅カスタム<span><input type="button" class="column_width_btn" value="カスタム設定" style="vertical-align: text-top;font-size: 0.8rem;"/></span></div><div class="dsp_column_settings_content_div">自動更新<span><input class="opd_a_reload_bar" type="checkbox" %column_auto_reload_ch%></span></div><div class="dsp_column_settings_content_div">自動更新間隔<span><input class="opd_column_settings_input_text opd_a_reload_time_setting" type="number" value="%column_auto_reload_time%">秒</span></div></div><div class="dsp_column_settings_panel_close_btn_wrap"><input type="button" class="dsp_column_settings_panel_close_btn" value="設定を閉じる" style="vertical-align: text-top;font-size: 0.8rem;"/></div></div></div>` ;
let column_settings_panel_no_auto = `<div class="dsp_column_settings_panel"><div class="dsp_column_settings_panel_content"><h2>設定</h2><div class="dsp_column_settings_list"><div class="dsp_column_settings_content_div">表示モード<span><select class="opd_tw_view_mode" column_tw_view_mode_val="%column_tw_view_mode%"><option value="0">すべて</option><option value="1">テキストのみ</option><option value="2">画像・動画付のみ</option></select></span></div><div class="dsp_column_settings_content_div">カラム幅<span><select class="opd_column_size_preset"><option value="0">小</option><option value="1">中</option><option value="2">大</option><option value="3">カスタム</option></select></span></div><div class="dsp_column_settings_content_div">カラム幅カスタム<span><input type="button" class="column_width_btn" value="カスタム設定" style="vertical-align: text-top;font-size: 0.8rem;"/></span></div></div><div class="dsp_column_settings_panel_close_btn_wrap"><input type="button" class="dsp_column_settings_panel_close_btn" value="設定を閉じる" style="vertical-align: text-top;font-size: 0.8rem;"/></div></div></div>` ;
let column_settings_panel_othersns = `<div class="dsp_column_settings_panel"><div class="dsp_column_settings_panel_content"><h2>設定</h2><div class="dsp_column_settings_list"><div class="dsp_column_settings_content_div">カラム幅<span><select class="opd_column_size_preset"><option value="0">小</option><option value="1">中</option><option value="2">大</option><option value="3">カスタム</option></select></span></div><div class="dsp_column_settings_content_div">カラム幅カスタム<span><input type="button" class="column_width_btn" value="カスタム設定" style="vertical-align: text-top;font-size: 0.8rem;"/></span></div></div><div class="dsp_column_settings_panel_close_btn_wrap"><input type="button" class="dsp_column_settings_panel_close_btn" value="設定を閉じる" style="vertical-align: text-top;font-size: 0.8rem;"/></div></div></div>` ;
let default_element = {
/*main_bar_empty_column:{html:`<!--<section draggable="false" class="dsp_column"><div opd_column_type="main_bar_empty_column" opd_column_width="%column_width_num%" id="main_bar_empty_column" style="height:100%;min-width: 70px;"></div></section>-->`},*/
empty_column:{html:`<section draggable="false" id="column_%column_num%" class="dsp_column_draggable_false dsp_column dsp_column_emptycolumn"><div opd_column_type="empty_column" opd_column_width="%column_width_num%" style="height: 100%;min-width: 30rem;display: flex;align-items: center;justify-content: center;"><div><img src="${chrome.runtime.getURL(ui_icon_define.column_add_1)}" style="filter: brightness(0) saturate(100%) invert(61%) sepia(13%) saturate(13%) hue-rotate(335deg) brightness(89%) contrast(79%);"><p>左のバーからカラムを追加</p></div></div></section>`},
second_empty_column:{html:`<section draggable="false" id="column_%column_num%" class="dsp_column_draggable_false dsp_column dsp_column_second_emptycolumn"><div opd_column_type="second_empty_column" opd_column_width="%column_width_num%" style="height:100%;min-width: 30rem;overflow: hidden;display: flex;align-items: center;justify-content: center;"><div><img src="${chrome.runtime.getURL(ui_icon_define.column_add_2)}" style="filter: brightness(0) saturate(100%) invert(61%) sepia(13%) saturate(13%) hue-rotate(335deg) brightness(89%) contrast(79%);"><p>1段目のカラムが配置できます</p></div></div></section>`},
home:{html:`<section draggable="true" id="column_%column_num%" class="dsp_column_draggable_true dsp_column"><div opd_column_type="home" opd_column_width="%column_width_num%" style="height: 100%;width: %column_width_num%rem;min-width: 1rem;"><div class="column_bar" style="height: 20px;"><span class="dsp_column_title"><div class="dsp_column_move_icon_parent"><span class="dsp_column_move_icon"></span><span>Timeline</span></div></span>${default_element_bar}<div class="dsp_column_close_btn_wrap"><span class="dsp_column_btn"><label class="dsp_column_close_btn opd_ui_icon_color" title="カラムを閉じる"><input type="button" class="column_close_btn" value="X"/></label></span></div></div>${column_settings_panel}<iframe auto_reload_mouse_hover="false" allow="fullscreen" src="https://x.com/home" type="text/html" style="width: 100%;height: 100%;"></iframe></div></section>`},
notification:{html:`<section draggable="true" id="column_%column_num%" class="dsp_column_draggable_true dsp_column"><div opd_column_type="notification" opd_column_width="%column_width_num%" style="height: 100%;width: %column_width_num%rem;min-width: 1rem;"><div class="column_bar" style="height: 20px;"><span class="dsp_column_title"><div class="dsp_column_move_icon_parent"><span class="dsp_column_move_icon"></span><span>Notifications</span></div></span>${default_element_bar}<div class="dsp_column_close_btn_wrap"><span class="dsp_column_btn"><label class="dsp_column_close_btn opd_ui_icon_color" title="カラムを閉じる"><input type="button" class="column_close_btn" value="X"/></label></span></div></div>${column_settings_panel_no_auto}<iframe allow="fullscreen" src="https://x.com/notifications" type="text/html" style="width: 100%;height: 100%;"></iframe></div></section>`},
explore:{html:`<section draggable="true" id="column_%column_num%" class="dsp_column_draggable_true dsp_column"><div opd_column_type="explore" opd_column_width="%column_width_num%" opd_explore_path="%column_save_path%" opd_explore_title="%column_save_title%" opd_pinned_path="%column_pinned_save_path%" style="height: 100%;width: %column_width_num%rem;min-width: 1rem;"><div class="column_bar" style="height: 20px;"><span class="dsp_column_title"><div class="dsp_column_move_icon_parent"><span class="dsp_column_move_icon"></span><span>Explore</span></div></span>${default_element_bar}<span class="dsp_column_btn"><input class="opd_pinned_btn" type="checkbox" title="ピン止め切り替え" %column_pinned_ch%><label class="dsp_column_pin_btn opd_ui_icon_color"></label></span><div class="dsp_column_close_btn_wrap"><span class="dsp_column_btn"><label class="dsp_column_close_btn opd_ui_icon_color" title="カラムを閉じる"><input type="button" class="column_close_btn" value="X"/></label></span></div></div>${column_settings_panel}<iframe auto_reload_mouse_hover="false" allow="fullscreen" src="https://x.com%column_save_path%" type="text/html" style="width: 100%;height: 100%;"></iframe></div></section>`}
};
let ins_html = document.createElement("div");
ins_html.id = "opd_main_element";
ins_html.style = "position: fixed;z-index: 999999;top:0;width: 100%;height: 100%;background: white;display: flex;flex-direction: row;overflow: hidden;";
let side_bar = `<section class="dsp_column" style="position:fixed;z-index:999;height:98%;"><div draggable="false" class="dsp_column_draggable_false" opd_column_type="dsp_column" opd_column_width="%column_width_num%" style="height:100%;min-width: 60px;max-width: 60px;text-align: center;background-color: white;"><div class="main_bar_functions"><div class="opd_ui_logo_parent" title="Open-Deck\r\nv${chrome.runtime.getManifest().version}"><div class="opd_ui_logo"></div><span class="opd_version_span">${chrome.runtime.getManifest().version}</span></div><hr><p class="opd_debug_menu">Debug<br><input type="button" id="init_settings" value="初期化" /><br><input type="button" id="profile_load_save" value="プロファイルローダー" /><br><input type="button" id="dnr_reload" value="dNR_Reload" /><br><input type="button" id="ext_reload" value="拡張機能再読み込み" /><br><div id="api_limit_status">API</div><hr><div class="dsp_btn_parent" id="add_timeline" title="タイムラインカラム追加"><div class="dsp_btn_add_tl_img"></div></div><div class="dsp_btn_parent" id="add_notify" title="通知カラム追加"><div class="dsp_btn_add_ntfc_img"></div></div><div class="dsp_btn_parent" id="add_explore" title="Explore(ユニバーサル)カラム追加"><div class="dsp_btn_add_explr_img"></div></div><hr><div class="dsp_btn_parent" title="カラム段切り替え" id="second_rack"><div class="dsp_btn_second_rack_img"></div></div><hr><div class="dsp_btn_parent" title="プロファイル保存" id="profile_save"><div class="dsp_btn_profile_add_img"></div></div><div class="dsp_btn_parent" title="プロファイル削除" id="profile_delete"><div class="dsp_btn_profile_delete_img"></div></div>${profile_list_html}</p></div></div></section><section draggable="false" class="dsp_column_draggable_false dsp_column"><div opd_column_type="main_bar_empty_column" id="main_bar_empty_column" style="height:100%;min-width: 60px;max-width: 60px;"></div></section>`;
//let side_bar = `<section class="dsp_column" style="position:fixed;z-index:999;height:98%;"><div draggable="false" opd_column_type="dsp_column" opd_column_width="%column_width_num%" style="height:100%;min-width: 100px;text-align: center;background-color: white;"><div><p style="margin-top:0;padding-top:1em;">Open-Deck<br>Prototype<br>v${chrome.runtime.getManifest().version}</p><hr><p>Debug<br><input type="button" id="init_settings" value="init settings"/><br><input type="button" id="profile_load_save" value="Profile Load"/><br><input type="button" id="dnr_reload" value="dNR_Reload"/><br><input type="button" id="ext_reload" value="Ext_Reload"/></p><hr><p><input type="button" id="add_timeline" value="Add TimeLine"/> <div class="dsp_btn_parent"><div class="dsp_btn_add_tl_img"></div></div><div class="dsp_btn_parent"><div class="dsp_btn_add_ntfc_img"></div></div><div class="dsp_btn_parent"><div class="dsp_btn_add_explr_img"></div></div> </p><p><input type="button" id="add_notify" value="Add Notification"/></p><p><input type="button" id="add_explore" value="Add Explore"/><hr><input type="button" id="second_rack" value="Second Rack"/><hr><input type="button" id="profile_save" value="Profile_Save"/><br><input type="button" id="profile_delete" value="Profile_Delete"/><br>${profile_list_html}</p></div></div></section><section draggable="false" class="dsp_column"><div opd_column_type="main_bar_empty_column" id="main_bar_empty_column" style="height:100%;min-width: 110px;"></div></section>`;
let main_column_html = ``;
let second_column_html = ``;
//設定2段
let first_column_end = false;
let second_column_end = false;
let second_rack_mode = false;
//カラム横幅
let column_width_init = "30";
//スクロール検出用
let scroll_block = true;
//
//console.log(settings.column_settings.length)
for (let index = 0; index < settings.column_settings.length; index++) {
//console.log(default_element)
for (let default_index = 0; default_index < Object.keys(default_element).length; default_index++) {
//console.log(settings.column_settings[index].type+"-"+Object.keys(default_element))
if(settings.column_settings[index].type == Object.keys(default_element)[default_index]){
//console.log(default_element[Object.keys(default_element)[default_index]]["html"])
let banner_checked = "";
let init_top_visible_checked = "";
let init_pinned_checked = "";
let init_pinned_path = "";
let init_auto_reload_checked = "";
let init_column_save_path = settings.column_settings[index].column_save_path;
let init_column_save_title = settings.column_settings[index].column_save_title;
let tw_view_type = settings.column_settings[index].tw_view_mode;
let auto_reload_time = settings.column_settings[index].auto_reload_time / 1000;
if(settings.column_settings[index].banner == true){
banner_checked = "checked";
}
//トップ検索など
if(settings.column_settings[index].top_visible == true){
init_top_visible_checked = "checked";
}
//カラム横幅
if(settings.column_settings[index].column_width != null){
column_width_init = settings.column_settings[index].column_width;
}
//Exproleピン止め
if(settings.column_settings[index].type == "explore"){
if(settings.column_settings[index].column_pinned_path != ""){
init_pinned_checked = "checked";
init_pinned_path = settings.column_settings[index].column_pinned_path;
init_column_save_path = settings.column_settings[index].column_pinned_path;
//%column_pinned_ch%
}else{
init_column_save_path = settings.column_settings[index].column_save_path;
}
}
//自動更新
if(settings.column_settings[index].type == "explore" || settings.column_settings[index].type == "home"){
if(settings.column_settings[index].auto_reload){
init_auto_reload_checked = "checked";
//%column_pinned_ch%
}else{
}
}
//一段目終了検出にもかかわらず設定が存在していた場合2段目の変数に保存
if(first_column_end == true){
second_column_html += default_element[Object.keys(default_element)[default_index]]["html"].replaceAll("%column_save_path%", init_column_save_path).replaceAll("%column_num%", create_random_id()).replace("%column_banner_ch%", banner_checked).replace("%column_top_bar_ch%", init_top_visible_checked).replace("%column_tw_view_mode%", tw_view_type).replace("%column_pinned_ch%", init_pinned_checked).replaceAll("%column_pinned_save_path%", init_pinned_path).replaceAll("%column_save_title%", init_column_save_title).replaceAll("%column_width_num%", column_width_init).replaceAll("%column_auto_reload_ch%", init_auto_reload_checked).replaceAll("%column_auto_reload_time%", auto_reload_time);
}else{
main_column_html += default_element[Object.keys(default_element)[default_index]]["html"].replaceAll("%column_save_path%", init_column_save_path).replaceAll("%column_num%", create_random_id()).replace("%column_banner_ch%", banner_checked).replace("%column_top_bar_ch%", init_top_visible_checked).replace("%column_tw_view_mode%", tw_view_type).replace("%column_pinned_ch%", init_pinned_checked).replaceAll("%column_pinned_save_path%", init_pinned_path).replaceAll("%column_save_title%", init_column_save_title).replaceAll("%column_width_num%", column_width_init).replaceAll("%column_auto_reload_ch%", init_auto_reload_checked).replaceAll("%column_auto_reload_time%", auto_reload_time);
}
//一段目読込終了検出
if(first_column_end == false && settings.column_settings[index].type == "empty_column"){
first_column_end = true;
}
//二段目読込終了検出
if(second_column_end == false && settings.column_settings[index].type == "second_empty_column"){
second_column_end = true;
}
}
}
}
//初期挿入HTML作成
ins_html.innerHTML = `${side_bar}<div id="main_rack_element" style=""><div id="first_rack_element" style="height: 100%;display:flex;flex-direction:row;">${main_column_html}</div><div id="second_rack_element" style="display:flex;flex-direction:row;">${second_column_html}</div></div>`;
//HTML挿入
document.body.insertAdjacentElement("afterbegin", ins_html);
//APIリミット表示用
document.querySelector("#api_limit_status").addEventListener("click", function(){
if(api_limit_obj != null){
alert(`現在のAPIリミット状況\r\n回数(使用回数/総使用可能数)-完全回復時間\r\n${api_limit_dsc_obj.time_line}${api_limit_dsc_obj.recommend_timeline}${api_limit_dsc_obj.search}`);
}
});
//Open-Deckについて表示
document.querySelector(".opd_ui_logo").addEventListener("click", function(){
window.open(chrome.runtime.getURL("about_opd.html"), "About Open-Deck", 'width=720, height=280');
});
//デバッグメニュー表示
let debug_menu_click_counter = 0;
document.querySelector(".opd_version_span").addEventListener("click", function(){
if(debug_menu_click_counter >= 7){
alert("デバッグメニューが利用できます!");
document.querySelector(".opd_debug_menu").style.display = "block";
}else{
debug_menu_click_counter += 1;
}
});
//2段目が存在する場合の処理
if(first_column_end == true && second_column_end == true){
second_rack_mode = true;
document.querySelector("#first_rack_element").style.height = "50vh";
document.querySelector("#second_rack_element").style.height = "50vh";
/*for (let index = 0; index < document.querySelectorAll('.dsp_column[draggable="true"]').length; index++) {
document.querySelectorAll('.dsp_column[draggable="true"]')[index].style.height = "calc(100% - 25px)";
}*/
//document.querySelector("style[second_column_css]").textContent = `#second_rack_element .dsp_column[draggable="true"]{height:calc(100% - 25px)}`;
document.querySelector("#second_rack").value = "Single Rack";
document.querySelector(".dsp_btn_second_rack_img").style.backgroundImage = `url(${chrome.runtime.getURL(ui_icon_define.column_single_rack)})`;
}
//
create_profile_list_btn();
column_dd();
column_close();
append_object_css();
//プロファイルリスト切替イベント作成関数
function create_profile_list_btn(){
//プロファイルリスト切替イベント初期化
for (let index = 0; index < profile_store.length; index++) {
document.querySelector(`#userProfile-${index}`).addEventListener("click",function(){
//console.log(profile_store[index].profile)
const preload_array = profile_store[index].profile;
let preload_desc_array = new Array();
let preload_desc_count = 0;
for (let preload_index = 0; preload_index < preload_array.length; preload_index++) {
switch (preload_array[preload_index].type) {
case "dsp_column":
preload_desc_count = 0;
break;
case "main_bar_empty_column":
preload_desc_count = 0;
break;
case "empty_column":
preload_desc_array.push("<!-1段目終了-!>");
preload_desc_count = 0;
break;
case "second_empty_column":
preload_desc_array.push("<!-2段目終了-!>");
preload_desc_count = 0;
break;
case "home":
preload_desc_array.push(`${preload_desc_count}-タイムラインカラム`);
break;
case "notification":
preload_desc_array.push(`${preload_desc_count}-通知カラム`);
break;
case "explore":
preload_desc_array.push(`${preload_desc_count}-[${preload_array[preload_index].column_save_title}]-ユニバーサル(Explore)カラム`);
break;
case "misskey":
preload_desc_array.push(`Misskeyカラム`);
break;
case "bsky":
preload_desc_array.push(`Blueskyカラム`);
break;
default:
preload_desc_count = 0;
break;
}
preload_desc_count += 1;
}
//console.log(preload_desc_array)
if(confirm(`プロファイル「${index}」を読み込みますか?\r\nカラム構成\r\n${preload_desc_array.join("\r\n")}`)){
document.querySelector("#opd_main_element").remove();
last_load_profile = index;
chrome.storage.local.get("opd_settings", function(value){
let load_setting = JSON.parse(value.opd_settings);
load_setting.last_load_profile = index;
chrome.storage.local.set({'opd_settings': JSON.stringify(load_setting)}, function () {
});
});
const column_settings = {column_settings:profile_store[index].profile};
//console.log(column_settings)
run(column_settings, profile_store);
}
})
}
}
//CSS適用(追加/変更の時に呼び出し)
function append_object_css(){
let column_object = document.querySelectorAll('.dsp_column:not([opd_column_type="dsp_column"], [opd_column_type="empty_column"], [opd_column_type="main_bar_empty_column"]) iframe');
for (let index = 0; index < column_object.length; index++) {
//バナー/表示モード変更
column_object[index].addEventListener("load", function(){
console.log(this.getAttribute("opd_iframe_width_only"))
if(this.getAttribute("opd_iframe_width_only") != ''){
//console.log(this)
let opd_column_div = this.closest("div[opd_column_type]");
let opd_column_banner_checkbox = opd_column_div.querySelector(".opd_banner");
let opd_column_top_visible_checkbox = opd_column_div.querySelector(".opd_top_bar");
let opd_column_tw_view_mode_opt = opd_column_div.querySelector(".opd_tw_view_mode");
//バナー表示設定読み込み適用
/*if(opd_column_banner_checkbox.checked == true){
this.contentWindow.document.querySelector("head").insertAdjacentHTML("beforeend", `<style opd_banner_css></style>`);
}else{
this.contentWindow.document.querySelector("head").insertAdjacentHTML("beforeend", `<style opd_banner_css>header[role="banner"]{content-visibility:hidden; }</style>`);
}*/
//バナー表示ロード
if(this.contentWindow.document.querySelector('head style[opd_banner_css]') == null){
this.contentWindow.document.querySelector("head").insertAdjacentHTML("beforeend", `<style opd_banner_css></style>`);
}
if(opd_column_banner_checkbox.checked != true){
//console.log(this)
this.contentWindow.document.querySelector('head style[opd_banner_css]').textContent = `header[role="banner"]{display:none};`;
}else{
//console.log("else")
this.contentWindow.document.querySelector('head style[opd_banner_css]').textContent = ``;
}
//トップ検索欄等削除適用
if(this.contentWindow.document.querySelector('head style[opd_top_visible_css]') == null){
this.contentWindow.document.querySelector("head").insertAdjacentHTML("beforeend", `<style opd_top_visible_css></style>`);
}
if(opd_column_top_visible_checkbox.checked != true){
if(this.closest("div[opd_column_type]").getAttribute("opd_column_type") == "explore"){
//div[data-testid="primaryColumn"] div[tabindex="0"][aria-label] div:has(form[role="search"]){display:none;}
this.contentWindow.document.querySelector('head style[opd_top_visible_css]').textContent = `div[data-testid="primaryColumn"]>[tabindex="0"][aria-label]>div:nth-child(1)div[data-testid="primaryColumn"]>[tabindex="0"][aria-label]>div:nth-child(1)`;
}else{
if(this.closest("div[opd_column_type]").getAttribute("opd_column_type") == "home"){
this.contentWindow.document.querySelector('head style[opd_top_visible_css]').textContent = `div[data-testid="primaryColumn"]>[tabindex="0"][aria-label]>div:nth-child(1){display:none;} div[role="progressbar"] + div{display:none;}`;
}else{
this.contentWindow.document.querySelector('head style[opd_top_visible_css]').textContent = `div[data-testid="primaryColumn"]>[tabindex="0"][aria-label]>div:nth-child(1){display:none;}`;
}
}
}else{
//console.log("else")
this.contentWindow.document.querySelector('head style[opd_top_visible_css]').textContent = ``;
}
//ツイート表示項目設定読み込み適用
if(this.contentWindow.document.querySelector("head style[opd_tw_view_mode_css]") == null){
this.contentWindow.document.querySelector("head").insertAdjacentHTML("beforeend", `<style opd_tw_view_mode_css></style>`);
}
switch (opd_column_tw_view_mode_opt.value) {
case "0":
this.contentWindow.document.querySelector('head style[opd_tw_view_mode_css]').textContent = ``;
break;
case "1":
this.contentWindow.document.querySelector('head style[opd_tw_view_mode_css]').textContent = `div[data-testid="cellInnerDiv"]:has(div[aria-labelledby]){visibility: hidden; height: 0;}`;
break;
case "2":
this.contentWindow.document.querySelector('head style[opd_tw_view_mode_css]').textContent = `div[data-testid="cellInnerDiv"]:not(:has(div[aria-labelledby])){visibility: hidden; height: 0;}`;
break;
default:
this.contentWindow.document.querySelector('head style[opd_tw_view_mode_css]').textContent = ``;
break;
}
//console.log(opd_column_div.querySelector(".opd_banner").checked)
}
})
//各カラム読み込み後の動作(init)
column_object[index].addEventListener("load", function(){
//console.log(this)
let opd_column_div = this.closest("div[opd_column_type]");
let opd_column_width_btn = opd_column_div.querySelector(".column_width_btn");
let opd_column_width_select = opd_column_div.querySelector(".opd_column_size_preset");
let opd_column_banner_checkbox = opd_column_div.querySelector(".opd_banner");
let opd_column_top_visible_checkbox = opd_column_div.querySelector(".opd_top_bar");
let opd_column_pinned_checkbox = opd_column_div.querySelector(".opd_pinned_btn");
let opd_column_auto_reload_checkbox = opd_column_div.querySelector(".opd_a_reload_bar");
let opd_column_auto_reload_time_reload = opd_column_div.querySelector(".opd_a_reload_time_setting");
let opd_column_tw_view_mode_opt = opd_column_div.querySelector(".opd_tw_view_mode");
//設定パネルイベント
opd_column_div.querySelector(".opd_settings_btn").addEventListener("click", function(){
const settings_panel = this.closest("div[opd_column_type]").querySelector(".dsp_column_settings_panel");
if(settings_panel.getAttribute("open") == null){
settings_panel.setAttribute("open", "");
settings_panel.style.display = "flex";
}else{
settings_panel.removeAttribute("open");
settings_panel.style.display = "none";
}
});
opd_column_div.querySelector(".dsp_column_settings_panel_close_btn").addEventListener("click", function(){
const settings_panel = this.closest("div[opd_column_type]").querySelector(".dsp_column_settings_panel");
settings_panel.removeAttribute("open");
settings_panel.style.display = "none";
})
//設定パネル&ホバー時動作
opd_column_div.querySelector(".dsp_column_settings_panel").addEventListener("mouseover", function(){
opd_column_div.closest(".dsp_column").setAttribute("draggable", "false");
});
opd_column_div.querySelector(".dsp_column_settings_panel").addEventListener("mouseleave", function(){
opd_column_div.closest(".dsp_column").setAttribute("draggable", "true");
});
//設定パネルカラム幅設定
if(opd_column_width_select != null){
switch (opd_column_div.getAttribute("opd_column_width")){
case '15':
opd_column_width_select.value = 0;
break;
case '20':
opd_column_width_select.value = 1;
break;
case '30':
opd_column_width_select.value = 2;
break;
default:
opd_column_width_select.value = 3;
break;
}
opd_column_width_select.addEventListener("change", function(){
let preset_rem = null;
switch (this.value){
case '0':
preset_rem = 15;
break;
case '1':
preset_rem = 20;
break;
case '2':
preset_rem = 30;
break;
default:
preset_rem = 30;
break;
}
this.closest("div[opd_column_type]").setAttribute("opd_column_width", preset_rem);
this.closest("div[opd_column_type]").style.width = `${preset_rem}rem`;
column_settings_save("", last_load_profile);
})
}
//カラム横幅設定イベント
opd_column_width_btn.addEventListener("click", function(){
const now_width = this.closest("div[opd_column_type]").getAttribute("opd_column_width");
let column_width_preset = this.closest("div[opd_column_type]").querySelector(".opd_column_size_preset");
let setting_width = prompt("カラム横幅のremを半角数字で入力\r\n目安 小:15 中:20 大:30 初期値:30\r\n11以下は入力できません", now_width);
//console.log(setting_width);
if(setting_width != null){
const setting_width_num = Number(setting_width);
if(setting_width_num != NaN && setting_width_num > 11){
this.closest("div[opd_column_type]").setAttribute("opd_column_width", setting_width_num);
this.closest("div[opd_column_type]").style.width = `${setting_width_num}rem`;
column_settings_save("", last_load_profile);
switch (setting_width_num){
case 15:
column_width_preset.value = 0;
break;
case 20:
column_width_preset.value = 1;
break;
case 30:
column_width_preset.value = 2;
break;
default:
column_width_preset.value = 3;
break;
}
}else{
alert("正しい値を入力してください");
}
}
});
//他SNSカラム対応
if(this.getAttribute("opd_iframe_width_only") != ''){
//バナー表示設定読み込み適用
/*if(opd_column_banner_checkbox.checked == true){
this.contentWindow.document.querySelector("head").insertAdjacentHTML("beforeend", `<style opd_banner_css></style>`);
}else{
this.contentWindow.document.querySelector("head").insertAdjacentHTML("beforeend", `<style opd_banner_css>header[role="banner"]{content-visibility:hidden; }</style>`);
}*/
if(this.contentWindow.document.querySelector('head style[opd_banner_css]') == null){
this.contentWindow.document.querySelector("head").insertAdjacentHTML("beforeend", `<style opd_banner_css></style>`);
}
if(opd_column_banner_checkbox.checked != true){
//console.log(this)
this.contentWindow.document.querySelector('head style[opd_banner_css]').textContent = `header[role="banner"]{display:none};`;
}else{
//console.log("else")
this.contentWindow.document.querySelector('head style[opd_banner_css]').textContent = ``;
}
//トップ検索欄等削除適用
if(this.contentWindow.document.querySelector('head style[opd_top_visible_css]') == null){
this.contentWindow.document.querySelector("head").insertAdjacentHTML("beforeend", `<style opd_top_visible_css></style>`);
}
if(opd_column_top_visible_checkbox.checked != true){
//console.log("home_notcheck")
if(this.closest("div[opd_column_type]").getAttribute("opd_column_type") == "explore"){
this.contentWindow.document.querySelector('head style[opd_top_visible_css]').textContent = `div[data-testid="primaryColumn"]>[tabindex="0"][aria-label]>div:nth-child(1){visibility: hidden; height: 0;top: calc(100vh - 60px);position: sticky;backdrop-filter: blur(0px) !important;}[data-testid="app-bar-back"]{visibility: visible; filter: none;}`;
}else{
if(this.closest("div[opd_column_type]").getAttribute("opd_column_type") == "home"){
this.contentWindow.document.querySelector('head style[opd_top_visible_css]').textContent = `div[data-testid="primaryColumn"]>[tabindex="0"][aria-label]>div:nth-child(1){visibility: hidden; height: 0;top: calc(100vh - 60px);position: sticky;backdrop-filter: blur(0px) !important;}[data-testid="app-bar-back"]{visibility: visible; filter: none;} div[role="progressbar"] + div{display:none;}`;
}else{
this.contentWindow.document.querySelector('head style[opd_top_visible_css]').textContent = `div[data-testid="primaryColumn"]>[tabindex="0"][aria-label]>div:nth-child(1){visibility: hidden; height: 0;top: calc(100vh - 60px);position: sticky;backdrop-filter: blur(0px) !important;}[data-testid="app-bar-back"]{visibility: visible; filter: none;}`;
}
}
}else{
//console.log("else")
this.contentWindow.document.querySelector('head style[opd_top_visible_css]').textContent = ``;
}
//ツイート表示項目設定読み込み適用
if(this.contentWindow.document.querySelector("head style[opd_tw_view_mode_css]") == null){
this.contentWindow.document.querySelector("head").insertAdjacentHTML("beforeend", `<style opd_tw_view_mode_css></style>`);
}
opd_column_tw_view_mode_opt.value = opd_column_tw_view_mode_opt.getAttribute("column_tw_view_mode_val")
switch (opd_column_tw_view_mode_opt.getAttribute("column_tw_view_mode_val")) {
case "0":
this.contentWindow.document.querySelector('head style[opd_tw_view_mode_css]').textContent = ``;
break;
case "1":
this.contentWindow.document.querySelector('head style[opd_tw_view_mode_css]').textContent = `div[data-testid="cellInnerDiv"]:has(div[aria-labelledby]){visibility: hidden; height: 0;}`;
break;
case "2":
this.contentWindow.document.querySelector('head style[opd_tw_view_mode_css]').textContent = `div[data-testid="cellInnerDiv"]:not(:has(div[aria-labelledby])){visibility: hidden; height: 0;}`;
break;
default:
this.contentWindow.document.querySelector('head style[opd_tw_view_mode_css]').textContent = ``;
break;
}
//自動更新初期適用
let reload_test = 0;
let auto_reload_int = null;//チェックボックスイベントにも再利用
if(opd_column_auto_reload_checkbox != null){
//Home, Exproleカラムホバー中 自動更新上部遷移停止
opd_column_div.querySelector("iframe").addEventListener("mouseover", function(){