-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
2506 lines (2236 loc) · 118 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<!-- Title -->
<title>Clipboard Inserter HTML Enhanced</title>
<!-- Scary base64 encoded favicon (小) -->
<link href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAACXBIWXMAAAsTAAALEwEAmpwYAAAK9WlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNi4wLWMwMDUgNzkuMTY0NTkwLCAyMDIwLzEyLzA5LTExOjU3OjQ0ICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOnBob3Rvc2hvcD0iaHR0cDovL25zLmFkb2JlLmNvbS9waG90b3Nob3AvMS4wLyIgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RFdnQ9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZUV2ZW50IyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtbG5zOnRpZmY9Imh0dHA6Ly9ucy5hZG9iZS5jb20vdGlmZi8xLjAvIiB4bWxuczpleGlmPSJodHRwOi8vb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jgsik3tgxNcRih6Nm+yYmJkocgnZ0nL7L3w67N3lQtNdw1YsmFpRiClahxTpYKE5WSmLaWL1k2dm4YEcjoAmcsNkB8hnUmhxESEWZSsBuXLS+QseoC3rfRfFdaMVf83pn2F1VItNUMe7X/qtC1IJa2sWvho9Er+8ST+irIktV+NV6Hv8CoQSxebdkGb0AAAAASUVORK5CYII=" rel="icon" type="image/png" />
<script>
/*
/////////////////////////////////////////////////////////////////////////
////////// Downloadable HTML for Clipboard Inserter (Enhanced) //////////
///////// Version: 3.3.5 /////////
/////////////////////////////////////////////////////////////////////////
------ General Info ------
❗ The following Non-default Clipboard Inserter settings are NOT required but highly suggested:
- element name: pre
- container selector: #textlines
You can switch to prepending mode by setting the "Scroll" button to top (Up arrow: ↑)
(Or you can just use a modified Clipboard Inserter addon like: https://github.com/Onurtag/clipboard-inserter)
Hover buttons to read their descriptions.
Both appending and prepending should work for all buttons and functionality. (Even if you don't have a modified Clipboard Inserter)
This page was made piece by piece for personal use.
Keyboard shortcuts:
- Alt + S: Toggle Editing
- A few more shortcuts can be enabled using the options menu.
❗ All options can be changed using the top right mini buttons and the settings menu.
- ❗ If you are using private browsing mode (or clearing history/cache/localstorage etc.), your settings (button states and hidden options) might not get saved. Just edit below variables directly.
*/
//------ Default Options ------
//You don't have to modify these values unless your browser is in permanent private browsing mode
//All options can be changed using the top right mini buttons and the settings menu.
//Read below for more info
const settings = {
//Top right buttons
scrollOnNewline: "toBottom",
pinningEnabled: false,
editingEnabled: false,
copyOnPageEnabled: false,
//Settings menu
notifyOnNewline: false,
autoHideYomichan: true,
overlayHotkeyEnabled: false,
backlogHotkeyEnabled: false,
addNewLineHotkeyEnabled: false,
purge500LinesWhen: 0,
customFontSize: "30px",
customFontSizeEnabled: false,
customFontSizeOverlay: "40px",
customFontSizeOverlayEnabled: false,
//Regex
regexEnabled: false,
regexFilterMatch: "/.*onlykeep(.*)between.*/gim",
regexFilterReplace: "$1",
//Currently testing
bgHotkeyEnabled: false,
hoverScrollEnabled: false,
hoverScrollSpeed: 108,
};
//------ Explanation ------
/**
* autoHideYomichan
*
* true: Hides all yomichan/yomitan popups when your mouse leaves the window
* false: disabled
* ❗ This option requires the setting "Use a secure container around popups" to be off in yomichan's options.
*
* */
/**
* purge500LinesWhen
*
* Purges oldest 500 lines when you go over this amount (which can keep the page smooth).
*
* 0: disabled
* Any number other than 0: enabled
*
* */
/**
* notifyOnNewline
*
* Whenever a new line is added; the symbol ✔ will flash on the window's title for a short time
*
* */
/**
* overlayHotkeyEnabled
*
* Enables the "Toggle overlay mode" hotkey "Alt + 0", "Ctrl + Alt + 0" or "}"
*
* This setting just adds a hotkey for the overlay mode feature. You can still use the toggle overlay mode button without enabling this hotkey.
*
* */
/**
* backlogHotkeyEnabled (For Overlay mode)
*
* Enables the "Toggle backlog mode" hotkey "Alt + O"
*
* This setting just adds a hotkey for the backlog mode feature. You can still use the backlog mode button without enabling this hotkey.
*
* */
/**
* bgHotkeyEnabled (currently abandoned. It has no real use.)
*
* Enables the "Toggle background color" hotkey "|"
*
* */
/**
* hoverScrollEnabled (currently testing.)
*
* When enabled you can scroll within the same line when you hover the "Scroll Down" "Scroll Up" overlay mode buttons.
*
* */
/**
* pinningEnabled
*
* true: pinning is enabled by default, false: disabled
*
* */
/**
* editingEnabled
*
* true: editing is enabled by default, false: disabled
*
* */
//---------------------
const historystack = [];
const historystack_forward = [];
const purged_lines = [];
const maxhistorylength = 500;
let overlayModeEnabled = false;
let overlayModeBacklog = false;
let forgiveHistoryTimes = 0;
let linecount = 0;
let editPinnedButtons = false;
let textlinesTempVisible = false;
let isChromium = window.chrome ? true : false;
let regexMatchCompiled = null;
let hoverTarget = null;
let forgiveCopyArray = [];
let pageTitle = document.title;
//DOMContentLoaded Start (first load)
document.addEventListener("DOMContentLoaded", function (event) {
//Load settings from localstorage
loadSettings();
//Load scroll button state (to top/to bottom/disabled)
setScrollButton();
//Document Title is different for local and online pages. Timeout is for being able to notice page refreshes.
setTimeout(() => {
if (document.location.protocol.includes("http")) {
document.title = pageTitle = pageTitle + " (Online)";
} else {
document.title = pageTitle = pageTitle + " (Local)";
}
}, 150);
//load first states for top right buttons
if (settings.pinningEnabled) {
togglePinning(true);
}
if (settings.editingEnabled) {
toggleEditing(true);
}
if (settings.copyOnPageEnabled) {
toggleCopying(true);
}
//Create movable hover buttons
createHoverButtons();
//scroll_button
document.getElementById("scroll_button").addEventListener("click", function () {
switch (settings.scrollOnNewline) {
case "disabled":
settings.scrollOnNewline = "toBottom";
break;
case "toBottom":
settings.scrollOnNewline = "toTop";
break;
case "toTop":
settings.scrollOnNewline = "disabled";
break;
default:
settings.scrollOnNewline = "toBottom";
break;
}
setScrollButton();
saveSettings("scrollOnNewline");
});
document.getElementById("remove_button").addEventListener("click", function () {
//Check if there are any lines.
if (linecount > 0) {
historyPush();
//If in overlay mode, remove the hover target.
if (overlayModeEnabled && !overlayModeBacklog) {
removeLine(hoverTarget);
} else {
//Remove the first/last line.
switch (settings.scrollOnNewline) {
case "disabled":
document.querySelector("#textlines > pre:last-of-type").remove();
break;
case "toBottom":
document.querySelector("#textlines > pre:last-of-type").remove();
break;
case "toTop":
document.querySelector("#textlines > pre:first-of-type").remove();
break;
default:
break;
}
updateCounter();
}
}
});
document.getElementById("clear_button").addEventListener("click", function (e) {
//If shift is held, clear history as well.
if (e.shiftKey) {
historystack.length = 0;
historystack_forward.length = 0;
setHistoryButtons();
} else {
historyPush();
}
document.querySelector("#textlines").innerHTML = "";
//Update the counter.
updateCounter();
});
document.getElementById("go_to_last_button").addEventListener("click", function () {
//document.querySelector("#textlines > pre:last-of-type").scrollIntoView();
if (linecount > 0) {
doScroll(0, findPos(document.querySelector("#textlines > pre:last-of-type")).top - 200);
}
});
document.getElementById("go_bottom_button").addEventListener("click", function () {
if (linecount > 0) {
scrollTopBottom("bottom");
}
});
//Keyboard shortcuts
document.addEventListener("keydown", function (e) {
//Alt + S: Toggle Editing (enabled by default)
if (e.altKey && e.key.toLowerCase() == "s") {
toggleEditing();
e.preventDefault();
//Alt + O: Toggle Backlog mode when the overloy mode is on (disabled by default)
} else if (e.altKey && e.key.toLowerCase() == "o") {
if (overlayModeEnabled && settings.backlogHotkeyEnabled) {
toggleBacklogMode();
e.preventDefault();
}
//Alt + E: Add a new line (disabled by default)
} else if (e.altKey && e.key.toLowerCase() == "e") {
if (settings.addNewLineHotkeyEnabled) {
addNewLine();
e.preventDefault();
}
//Alt + 0, Ctrl + Alt + 0 or '}' key: Toggle Overlay mode (disabled by default)
} else if ((e.altKey && e.key.toLowerCase() == "0") || e.key == "}") {
if (settings.overlayHotkeyEnabled) {
toggleOverlayMode();
e.preventDefault();
}
//"|" key: Toggle background color (disabled by default)
} else if (e.key == "|") {
if (settings.bgHotkeyEnabled) {
toggleBackgroundColor();
e.preventDefault();
}
}
});
//Non-css hover method for the menu
document.getElementById("menucontainer").addEventListener("mouseenter", function (e) {
handleMenuState();
});
document.getElementById("toprightbuttons").addEventListener("mouseleave", function (e) {
if (!settings.pinningEnabled) {
//document.querySelector("#menucontainer").removeAttribute("style");
handleMenuState();
}
});
//start checking for mouse in/out
checkMouseInOut();
/**
* Start detecting hover targets so we can move the hover buttons
*/
document.addEventListener("mouseover", function (e) {
const textlines_Node = document.querySelector("#textlines");
let currentElement = e.target;
const closest = currentElement.closest("#textlines > pre");
//enter #textlines > pre *
if (closest) {
//Move hover buttons to target
moveHoverButtons(closest);
//enter anything except the hover buttons (or #textlines > pre * above)
} else if (!currentElement.closest(".hoverButtonsBackground")) {
//Hide hover buttons
moveHoverButtons(null);
}
});
/**
* Use the settings.copyOnPageEnabled variable to handle if we should insert text that was copied on this page into a new line
*/
const INSERTER_MAX_DELAY = 550;
function copyncutHandler(event) {
if (settings.copyOnPageEnabled == false) {
//Change selection color using css and remove after 100ms
document.body.classList.add("selectioncopied");
setTimeout(() => {
document.body.classList.remove("selectioncopied");
}, 150);
//We use the text content to detect this as a simpler system would make a mistake if some other automated text was inserted between the copy event and the insertion by the extension.
const selectedText = document.getSelection().toString();
const selectedTextTrimmed = selectedText.trim();
//Clipboard Inserter might or might not trim the copied text (depending on extension)
forgiveCopyArray.push(selectedText);
if (selectedText != selectedTextTrimmed) {
forgiveCopyArray.push(selectedTextTrimmed);
}
//The following is here to prevent the situation where the copy/cut event is ran; but the inserter doesn't insert the copied text (i.e. as it is identical to the current clipboard content)
//Also cleans up the remaining trimmed/non-trimmed text
setTimeout(() => {
if (forgiveCopyArray.length > 0) {
//Remove regular and trimmed text from the array
const strindex = forgiveCopyArray.indexOf(selectedText);
if (strindex !== -1) {
forgiveCopyArray.splice(strindex, 1);
}
const trimstrindex = forgiveCopyArray.indexOf(selectedTextTrimmed);
if (trimstrindex !== -1) {
forgiveCopyArray.splice(trimstrindex, 1);
}
}
}, INSERTER_MAX_DELAY);
}
}
//Listen to copy and cut events
document.addEventListener("copy", copyncutHandler);
document.addEventListener("cut", copyncutHandler);
/**
* Listen to paste event
* Non-Chromium only (Firefox doesn't have contenteditable="plaintext-only")
* (Note: this moves the caret)
* //TODO: Firefox 115 might have fixed this
*/
if (isChromium == false) {
document.querySelector("#textlines").addEventListener("paste", function (e) {
const target = e.target;
if (target.nodeName == "PRE" && target.hasAttribute("contenteditable")) {
//do action after the event is done
setTimeout(() => {
//If target has a child (i.e. html was pasted)
if (target.firstElementChild) {
//get innerText and set textContent (avoids <br>'s)
const text = target.innerText;
target.textContent = text;
}
}, 1);
}
});
}
//main mutation observer for new lines.
const textlinesMutationObserver = new MutationObserver(function (records) {
records.forEach(function (mutation) {
mutation.addedNodes.forEach(function (node) {
try {
let nodeText = node.textContent;
//If the inserted text was copied on this page, do not insert it. (depending on the current setting)
if (forgiveCopyArray.length > 0 && forgiveCopyArray.includes(nodeText)) {
const strindex = forgiveCopyArray.indexOf(nodeText);
if (strindex !== -1) {
forgiveCopyArray.splice(strindex, 1);
}
//Remove the node (never appears on the page)
node.remove();
return;
}
//Compatibility for prepending because most people aren't using an upgraded clipboard inserter add-on that allows prepending.
switch (settings.scrollOnNewline) {
case "toTop":
let nextSib = node.nextElementSibling;
//detect an append() (should have been a prepend)
if (nextSib == null && forgiveHistoryTimes == 0 && linecount > 0) {
document.querySelector("#textlines").prepend(node);
return;
}
default:
break;
}
//push history (clears forward history)
if (forgiveHistoryTimes == 0) {
historyPush();
} else {
--forgiveHistoryTimes;
}
//Why use inner pre? 1) Double/Triple click selection breaks without it. 2) Editable outlines look much better.
//Check if the node is a history node that already has the inner pre
let innerPre = node.querySelector("pre");
const contenteditableValue = isChromium ? "plaintext-only" : "true";
if (innerPre == null) {
//Not a history node
//check if editing is enabled
let preNodeOpen = settings.editingEnabled ? `<pre contenteditable="${contenteditableValue}">` : "<pre>";
//Regex replace if its enabled
if (settings.regexEnabled) {
//Use compiled regex
nodeText = nodeText.replace(regexMatchCompiled, settings.regexFilterReplace);
}
//put the added pre text into another pre so we can modify it later on.
node.innerHTML = preNodeOpen + "</pre>";
node.firstChild.textContent = nodeText;
} else {
//History node. No need to add inner pre.
if (settings.editingEnabled) {
innerPre.setAttribute("contenteditable", contenteditableValue);
}
}
//Skip some steps while loading history
if (forgiveHistoryTimes == 0) {
//Overlay mode
if (overlayModeEnabled) {
//If text lines were temporarily made visible, hide them.
if (textlinesTempVisible) {
toggleTextVisibility("temp_hide");
}
}
//update counter
updateCounter();
//purge 500 lines if its enabled.
if (settings.purge500LinesWhen && linecount > settings.purge500LinesWhen) {
purgeExtraLines();
}
//Notify on new line if its enabled (using document.title)
if (settings.notifyOnNewline && !overlayModeEnabled && document.querySelector("html:hover") == null) {
notifyUsingTitle();
}
//Scroll to the top/bottom based on the current setting
doScrollOnNewline();
}
} catch (error) {
console.error(error);
}
});
});
});
//mutation observer for compatibility. Because not everyone is willing to change their extension's options. (read the readme above)
const compatibilityMutationObserver = new MutationObserver(function (records) {
records.forEach(function (mutation) {
mutation.addedNodes.forEach(function (node) {
try {
//Everything other than "body > p" is ignored. (second part might be useless)
if (node.tagName != "P" || node.parentNode.tagName != "BODY") {
return;
}
//Get the new text
let newNode = document.createElement("pre");
newNode.textContent = node.textContent;
//Remove the node (never appears on the page)
node.remove();
//Append or prepend the new node depending on the current setting
switch (settings.scrollOnNewline) {
case "disabled":
document.querySelector("#textlines").append(newNode);
break;
case "toBottom":
document.querySelector("#textlines").append(newNode);
break;
case "toTop":
document.querySelector("#textlines").prepend(newNode);
break;
default:
document.querySelector("#textlines").append(newNode);
break;
}
} catch (error) {
console.error(error);
}
});
});
});
//start the textlines mutation observer
textlinesMutationObserver.observe(document.querySelector("#textlines"), {
childList: true,
subtree: false,
});
//start the default options compatibility mutation observer
compatibilityMutationObserver.observe(document.querySelector("body"), {
childList: true,
subtree: false,
});
});
//---DOMContentLoaded end---
//---DOMContentLoaded end---
//---DOMContentLoaded end---
//----------functions----------
/**
* Open settings menu.
* Input ids are used to save the new data to the settings object.
* */
function openSettingsMenu() {
const settingsHTML = `
<div id="settingsContainer">
<div id="settingsBackground" title="Close" onclick="menuClose(false)"></div>
<div id="settingsWindow">
<h2 style="text-align: center;margin-block: 0.4em;">Settings</h2>
<input type="checkbox" id="customFontSizeEnabled" ${settings.customFontSizeEnabled ? "checked" : ""}>
<label for="customFontSize">Custom font size:</label>
<input type="text" id="customFontSize" value="${settings.customFontSize}" style="width:40px;">
<span title="Custom font sizes. Some examples: 16pt, 22px, 2em etc...
Leave the field empty to use default font size." class="settingTooltip">?</span>
<br>
<input type="checkbox" id="customFontSizeOverlayEnabled" ${settings.customFontSizeOverlayEnabled ? "checked" : ""}>
<label for="customFontSizeOverlay">Overlay mode custom font size:</label>
<input type="text" id="customFontSizeOverlay" value="${settings.customFontSizeOverlay}" style="width:40px;">
<span title="Custom font sizes. Some examples: 16pt, 22px, 2em etc...
Leave the field empty to use default font size." class="settingTooltip">?</span>
<br>
<input type="checkbox" id="notifyOnNewline" ${settings.notifyOnNewline ? "checked" : ""}>
<label for="notifyOnNewline">Notify on new line</label>
<span title="Whenever a new line is added; the symbol ✔ will flash on the window's title for a short time.\nDisabled in Overlay Mode." class="settingTooltip">?</span>
<br>
<input type="checkbox" id="autoHideYomichan" ${settings.autoHideYomichan ? "checked" : ""}>
<label for="autoHideYomichan">Auto-hide Yomichan/Yomitan popups</label>
<span title="Hides all yomichan/yomitan popups when your mouse leaves the window.
!!! This option requires the setting 'Use a secure container around popups' to be off in yomichan/yomitan options." class="settingTooltip">?</span>
<br>
<br>
<input type="checkbox" id="overlayHotkeyEnabled" ${settings.overlayHotkeyEnabled ? "checked" : ""}>
<label for="overlayHotkeyEnabled">"Overlay mode" hotkey enabled</label>
<span title="Enables the 'Toggle overlay mode' hotkey 'Alt + 0', 'Ctrl + Alt + 0' or '}'" class="settingTooltip">?</span>
<br>
<input type="checkbox" id="backlogHotkeyEnabled" ${settings.backlogHotkeyEnabled ? "checked" : ""}>
<label for="backlogHotkeyEnabled">"Backlog mode" hotkey enabled</label>
<span title="Enables the 'Toggle backlog mode' hotkey 'Alt + O'" class="settingTooltip">?</span>
<br>
<input type="checkbox" id="addNewLineHotkeyEnabled" ${settings.addNewLineHotkeyEnabled ? "checked" : ""}>
<label for="addNewLineHotkeyEnabled">"Add a new line" hotkey enabled</label>
<span title="Enables the 'Add a new line' hotkey 'Alt + E'" class="settingTooltip">?</span>
<br>
<input type="checkbox" id="bgHotkeyEnabled" ${settings.bgHotkeyEnabled ? "checked" : ""}>
<label for="bgHotkeyEnabled">"Toggle BG color" hotkey enabled</label>
<span title="(Currently testing) Enables the 'Toggle background color' hotkey '|'" class="settingTooltip">?</span>
<br>
<input type="checkbox" id="hoverScrollEnabled" ${settings.hoverScrollEnabled ? "checked" : ""}>
<label for="hoverScrollEnabled">Overlay mode hover scroll enabled.</label>
<label for="hoverScrollSpeed">Speed:</label>
<input type="number" id="hoverScrollSpeed" min="1" max="1000" value="${settings.hoverScrollSpeed}" style="width:80px;">
<span title="(Currently testing) When enabled you can scroll within the same line when you hover the 'Scroll Down' 'Scroll Up' overlay mode buttons." class="settingTooltip">?</span>
<br>
<br>
<input type="checkbox" id="regexEnabled" ${settings.regexEnabled ? "checked" : ""}>
<label for="regexEnabled">Enable regex replacer</label>
<span title="Enables the regex replacer which uses below two inputs." class="settingTooltip">?</span>
<br>
<label for="regexFilterMatch">Regex match string:</label>
<input type="text" id="regexFilterMatch" value="${settings.regexFilterMatch}" style="width:220px;">
<span title="Regex match string. Example: /your_regex/gim
For testing use https://regex101.com and select javascript flavor and turn on substitution mode." class="settingTooltip">?</span>
<br>
<label for="regexFilterReplace">Regex replace string:</label>
<input type="text" id="regexFilterReplace" value="${settings.regexFilterReplace}" style="width:220px;">
<span title="Regex replace string. Example: $1
For testing use https://regex101.com and select javascript flavor and turn on substitution mode." class="settingTooltip">?</span>
<br>
<br>
<label for="purge500LinesWhen">Purge 500 lines when over:</label>
<input type="number" id="purge500LinesWhen" min="0" max="10000" value="${settings.purge500LinesWhen}" style="width:80px;">
<span title="Purges oldest 500 lines when you go over this amount (which can keep the page smooth). I use 1500.
Setting this to 0 disables purging lines.
You can access the list of purged lines by typing 'purged_lines' in your browser console." class="settingTooltip">?</span>
<br>
<br>
<!--
<div style="font-size: 10pt;opacity:0.7;text-align: center;line-height: 10pt;">Settings will be reset if you clear browser data.</div>
-->
<button onclick="menuClose()">Save & Close</button>
</div>
</div>`;
document.body.insertAdjacentHTML("beforeend", settingsHTML);
}
function menuClose(save = true) {
let settingsContainer = document.querySelector("#settingsContainer");
if (save) {
//Save each type of setting
settingsContainer.querySelectorAll("input").forEach((input) => {
switch (input.type) {
case "checkbox":
settings[input.id] = input.checked;
break;
case "number":
settings[input.id] = input.valueAsNumber;
break;
//string inputs
default:
settings[input.id] = input.value;
break;
}
});
//Save settings to localStorage
saveSettings();
//Apply the newly saved settings
loadSettings(true);
}
settingsContainer.remove();
}
/**
* Set scroll button state
* */
function setScrollButton() {
switch (settings.scrollOnNewline) {
case "disabled":
document.querySelector("#scroll_button").classList.value = ["no_scroll"];
break;
case "toBottom":
document.querySelector("#scroll_button").classList.value = ["to_bottom"];
break;
case "toTop":
document.querySelector("#scroll_button").classList.value = ["to_top"];
break;
default:
settings.scrollOnNewline = "toBottom";
break;
}
}
/**
* Set hover target and Move Hover buttons
* */
function moveHoverButtons(newTarget) {
let hoverButtonsNode = getHoverButtons();
if (newTarget != null) {
//Set new target
hoverTarget = newTarget;
//Move hover buttons (except for overlaymode)
if (!overlayModeEnabled || overlayModeBacklog) {
let targetXY = findPos(hoverTarget);
hoverButtonsNode.style.setProperty("left", `${targetXY.left}px`);
hoverButtonsNode.style.setProperty("top", `${targetXY.top}px`);
}
//Unhide hover buttons (except when textlines are hidden)
if (!document.querySelector("#textlines").classList.contains("hidden")) {
hoverButtonsNode.classList.remove("hidden");
}
} else {
//Don't hide in overlay mode
if (!overlayModeEnabled || overlayModeBacklog) {
hoverButtonsNode.classList.add("hidden");
}
}
}
/**
* Compile regex
* */
function compileRegex() {
if (settings.regexFilterMatch != "") {
//If the regex doesn't match the /str/gim format (== null), use the string itself to create an identical array.
let matches = settings.regexFilterMatch.match("\/(.*)\/(.*)") || ["", settings.regexFilterMatch, ""];
regexMatchCompiled = new RegExp(matches[1], matches[2]);
}
}
/**
* Set custom font sizes from options
* */
function setCustomFontSizes() {
//Use a giga template
const customStyleHTML = `
<style id="customFontSizes">
${settings.customFontSizeEnabled ? `
body {
font-size: ${settings.customFontSize};
}
` : ""}
${settings.customFontSizeOverlayEnabled ? `
html.overlaymode #textlines > pre > pre {
font-size: ${settings.customFontSizeOverlay};
}
` : ""}
</style>
`;
let styleNode = document.querySelector("#customFontSizes");
if (styleNode) {
styleNode.remove();
}
document.head.insertAdjacentHTML("beforeend", customStyleHTML);
}
/**
* Load settings from localstorage
* */
function loadSettings(useCurrent = false) {
if (!useCurrent) {
Object.entries(settings).forEach(([key, value]) => {
settings[key] = getIfInLocalStorage(key, value);
});
//parse integers (i.e. handle everything that isn't a string or a boolean)
settings.purge500LinesWhen = parseInt(settings.purge500LinesWhen);
}
//Compile regex
compileRegex();
//Set custom font sizes
setCustomFontSizes();
}
/**
* Saves setting to localstorage
* */
function saveSettings(keyString = null) {
//save all or just a specific setting
if (keyString == null) {
Object.entries(settings).forEach(([key, value]) => {
localStorage.setItem(key, value);
});
} else {
localStorage.setItem(keyString, settings[keyString]);
}
}
/**
* Load setting from localstorage if it exists, otherwise keep current value.
* Parses "true" and "false".
* */
function getIfInLocalStorage(itemName, currentVal) {
let storedVal = localStorage.getItem(itemName);
if (storedVal != null) {
//If the stored value is true or false return the boolean value.
switch (storedVal.toLowerCase()) {
case "true":
return true;
case "false":
return false;
default:
return storedVal;
}
} else {
//No stored value
return currentVal;
}
}
/**
* Inserts dummy lines for testing.
* amount (optional): number
* method (optional): insertAdjacentHTML method. Default "afterbegin"
* */
function debugInsertLines(amount = 50, method = null) {
let textlines = document.querySelector("#textlines");
for (let index = 0; index < amount; index++) {
setTimeout(() => {
textlines.insertAdjacentHTML(method || "afterbegin", `<pre>${index + 1} 華鳥風月</pre>`);
}, index * 10);
}
}
//Modified from https://stackoverflow.com/a/24989958/5050478
//Used for "auto hide yomichan popup" (with shadow dom disabled in settings)
//Also used to hide hover buttons automatically
function checkMouseInOut() {
var theTimer;
var aFrameWasHidden = false;
//Reset or clear the timer on mouse in/out events
window.onmouseout = resetTimer;
window.onmouseover = clearTimer;
function doAction() {
try {
//Hide any visible yomichan popups
let yomichanFrames = document.querySelectorAll("iframe.yomichan-popup, iframe.yomitan-popup");
yomichanFrames.forEach((currFrame) => {
if (currFrame.style.getPropertyValue("visibility") == "visible") {
//Use display property (yomichan uses visibility)
currFrame.style.setProperty("display", "none");
currFrame.classList.add("thisFrameWasHidden");
aFrameWasHidden = true;
}
});
} catch (error) {
console.error(error);
}
}
function clearTimer(e) {
//Mouse entered the window or any element
clearTimeout(theTimer);
try {
//Unhide yomichan popups after 350ms (give the popup some time to hide)
if (aFrameWasHidden) {
setTimeout(() => {
let hiddenFrames = document.querySelectorAll("iframe.yomichan-popup.thisFrameWasHidden, iframe.yomitan-popup.thisFrameWasHidden");
hiddenFrames.forEach((currFrame) => {
currFrame.style.removeProperty("display");
currFrame.classList.remove("thisFrameWasHidden");
});
aFrameWasHidden = false;
}, 350);
}
} catch (error) {
console.error(error);
}
}
function resetTimer(e) {
clearTimeout(theTimer);
let reltarget = e.relatedTarget || e.toElement;
if (!reltarget || (reltarget.nodeName == "HTML" && e.target == document.firstChild)) {
//Cursor left the window.
//If not in overlay mode: Hide hover buttons
if (!overlayModeEnabled) {
getHoverButtons().classList.add("hidden");
}
//Hide yomichan popups N ms after the cursor leaves the window
if (settings.autoHideYomichan) {
theTimer = setTimeout(doAction, 300);
}
}
}
}
//handle top right menu container hover state manually (required to support keybindings and transparency)
function handleMenuState() {
var menuStyles = window.getComputedStyle(document.querySelector("#menucontainer"));
var buttonsStyles = window.getComputedStyle(document.querySelector("#toprightbuttons"));
var menuDisplay = menuStyles.getPropertyValue("display");
var buttonsDisplay = buttonsStyles.getPropertyValue("display");
if (menuDisplay == "block" && buttonsDisplay == "block") {
document.querySelector("#menucontainer").setAttribute("style", "display:none;");
} else if (menuDisplay == "none" && buttonsDisplay == "none") {
document.querySelector("#menucontainer").removeAttribute("style");
}
}
//Firefox hover bug workaround: Recheck the menu state when its hidden to prevent it from being hidden permanently.
let menustateInterval = setInterval(() => {
//Check when not pinned and hidden manually
if (!settings.pinningEnabled && document.querySelector('#menucontainer[style="display:none;"]')) {
handleMenuState();
}
}, 175);
//Create hover buttons (then we move it)
function createHoverButtons() {
let hoverButtons = document.createElement("div");
document.body.append(hoverButtons);
//Basicons svg from https://basicons.xyz/, License: MIT
hoverButtons.outerHTML = `
<div class="hoverButtonsBackground hidden">
<div class="hoverButtons hoverButtonDelete" title="Remove line"><svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M5 5L19 19M5 19L19 5"></path>
</svg></div>
<div class="hoverButtons hoverButtonReduceNewlines" title="Reduce newlines and spaces
(Alt+Click: Remove all spaces & tabs as well)"><svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M 3 3 L 21 3"></path>
<path class="middle" d="M 3 9 L 21 9 "></path>
<path d="M 3 15 L 21 15"></path>
</svg></div>
<div class="hoverButtons hoverButtonCopy" title="Copy to clipboard"><svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M 8 6 H 16 M 8 10 H 16 M 8 14 H 12 M 6 22 H 18 C 20 22 20 22 20 20 V 4 C 20 2 20 2 19 2 H 6 C 4 2 4 2 4 4 V 20 C 4 22 4 22 6 22 Z"></path>
</svg></div>
<div class="hoverButtons hoverButtonDown" title="Scroll down one line"><svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12 21V3M12 3L5 10M12 3L19 10"></path>
</svg></div>
<div class="hoverButtons hoverButtonUp" title="Scroll up one line"><svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12 21V3M12 3L5 10M12 3L19 10"></path>
</svg></div>
</div>`;
document.querySelector(".hoverButtonsBackground .hoverButtonDelete").addEventListener("click", function (event) {
historyPush();
removeLine(hoverTarget);
});
document.querySelector(".hoverButtonsBackground .hoverButtonReduceNewlines").addEventListener("click", function (event) {
historyPush();
reduceNewlines(hoverTarget, event);
});
document.querySelector(".hoverButtonsBackground .hoverButtonUp").addEventListener("click", function (event) {
scrollUpDown(hoverTarget, event.clientY, true);
});
document.querySelector(".hoverButtonsBackground .hoverButtonDown").addEventListener("click", function (event) {
scrollUpDown(hoverTarget, event.clientY, false);
});
document.querySelector(".hoverButtonsBackground .hoverButtonCopy").addEventListener("click", function (event) {
let elementInner = hoverTarget.querySelector("pre");
/**
* Copy Methods comparison:
* Copy Method 1: e.clipboardData.setData
* - Chrome & Firefox can't copy newlines
* Copy Method 2: navigator.clipboard.writeText
* - Firefox can't copy newlines
* Copy Method 3: range and document.execCommand("copy")
* - Chrome can't copy contenteditable nodes
*
* Solution: use Method 2 on chromium and Method 3 on others (Firefox)
*
* */
//Use innerText as it converts <br>'s that were manually added with Enter into \n's. (not necessary on chrome when using display: inline-block)
if (isChromium) {
//Copy Method 2
navigator.clipboard.writeText(elementInner.innerText).then((result) => {
return;
});
} else {
//Copy Method 3
elementInner.focus();
window.getSelection().removeAllRanges();
let range = document.createRange();
range.selectNode(elementInner);
window.getSelection().addRange(range);
document.execCommand("copy");
window.getSelection().removeAllRanges();
}
/*
//Copy Method 1
//Add a temporary copy event listener
function clipListener(e) {
e.clipboardData.setData("text/plain", elementInner.innerText);
e.preventDefault();
}
document.addEventListener("copy", clipListener);
document.execCommand("copy");
document.removeEventListener("copy", clipListener);
*/
});
//Return the created node
return document.querySelector(".hoverButtonsBackground");
}
//get hoverButtonsBackground (or recreate it)