sillytavern 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dockerignore +4 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +35 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- package/.github/workflows/npm-publish.yml +32 -0
- package/Dockerfile +49 -0
- package/Start.bat +3 -0
- package/colab/GPU.ipynb +339 -0
- package/colab/extras_server.py +40 -0
- package/colab/globals.py +2 -0
- package/colab/models.py +77 -0
- package/docker/docker-compose.yml +12 -0
- package/docker/docker-entrypoint.sh +28 -0
- package/faq.md +208 -0
- package/package.json +49 -0
- package/poe-client.js +638 -0
- package/poe-test.js +21 -0
- package/poe_graphql/AddHumanMessageMutation.graphql +52 -0
- package/poe_graphql/AddMessageBreakMutation.graphql +17 -0
- package/poe_graphql/AutoSubscriptionMutation.graphql +7 -0
- package/poe_graphql/BioFragment.graphql +8 -0
- package/poe_graphql/ChatAddedSubscription.graphql +5 -0
- package/poe_graphql/ChatFragment.graphql +6 -0
- package/poe_graphql/ChatListPaginationQuery.graphql +316 -0
- package/poe_graphql/ChatPaginationQuery.graphql +26 -0
- package/poe_graphql/ChatViewQuery.graphql +8 -0
- package/poe_graphql/DeleteHumanMessagesMutation.graphql +7 -0
- package/poe_graphql/DeleteMessageMutation.graphql +7 -0
- package/poe_graphql/HandleFragment.graphql +8 -0
- package/poe_graphql/LoginWithVerificationCodeMutation.graphql +13 -0
- package/poe_graphql/MessageAddedSubscription.graphql +115 -0
- package/poe_graphql/MessageDeletedSubscription.graphql +8 -0
- package/poe_graphql/MessageFragment.graphql +13 -0
- package/poe_graphql/MessageRemoveVoteMutation.graphql +7 -0
- package/poe_graphql/MessageSetVoteMutation.graphql +7 -0
- package/poe_graphql/SendVerificationCodeForLoginMutation.graphql +12 -0
- package/poe_graphql/ShareMessagesMutation.graphql +9 -0
- package/poe_graphql/SignupWithVerificationCodeMutation.graphql +13 -0
- package/poe_graphql/StaleChatUpdateMutation.graphql +7 -0
- package/poe_graphql/SubscriptionsMutation.graphql +9 -0
- package/poe_graphql/SummarizePlainPostQuery.graphql +3 -0
- package/poe_graphql/SummarizeQuotePostQuery.graphql +3 -0
- package/poe_graphql/SummarizeSharePostQuery.graphql +3 -0
- package/poe_graphql/UserSnippetFragment.graphql +14 -0
- package/poe_graphql/ViewerInfoQuery.graphql +21 -0
- package/poe_graphql/ViewerMessageLimitUpdatedSubscription.graphql +81 -0
- package/poe_graphql/ViewerStateFragment.graphql +30 -0
- package/poe_graphql/ViewerStateUpdatedSubscription.graphql +63 -0
- package/public/KoboldAI Settings/Ace of Spades 13B.settings +22 -0
- package/public/KoboldAI Settings/Adventurer-NeoX-20B-Erebus.settings +54 -0
- package/public/KoboldAI Settings/Basic Coherence 13B.settings +22 -0
- package/public/KoboldAI Settings/Best Guess 6B.settings +22 -0
- package/public/KoboldAI Settings/Calibrated-Pygmalion-6b.settings +47 -0
- package/public/KoboldAI Settings/Classic-Pygmalion-2.7b.settings +46 -0
- package/public/KoboldAI Settings/Classic-Pygmalion-6b.settings +47 -0
- package/public/KoboldAI Settings/Coherent Creativity 6B.settings +22 -0
- package/public/KoboldAI Settings/Default-TavernAI.settings +22 -0
- package/public/KoboldAI Settings/DragonSlayer-Pygmalion-6b.settings +47 -0
- package/public/KoboldAI Settings/GPU-Pygmalion-6b.settings +47 -0
- package/public/KoboldAI Settings/Genesis 13B.settings +22 -0
- package/public/KoboldAI Settings/Godlike.settings +22 -0
- package/public/KoboldAI Settings/Good Winds.settings +22 -0
- package/public/KoboldAI Settings/Lancer-OPT-2.7B-Erebus.settings +54 -0
- package/public/KoboldAI Settings/Liminal Drift.settings +22 -0
- package/public/KoboldAI Settings/Low Rider 13B.settings +22 -0
- package/public/KoboldAI Settings/Luna Moth 6B.settings +22 -0
- package/public/KoboldAI Settings/Mayday.settings +22 -0
- package/public/KoboldAI Settings/Ouroboros.settings +22 -0
- package/public/KoboldAI Settings/Pleasing Results 6B.settings +22 -0
- package/public/KoboldAI Settings/Pro Writer 13B.settings +22 -0
- package/public/KoboldAI Settings/RA - Pygmalion-1.3b.settings +46 -0
- package/public/KoboldAI Settings/Storywriter 6B.settings +22 -0
- package/public/NovelAI Settings/Classic-Euterpe.settings +14 -0
- package/public/NovelAI Settings/Classic-Krake.settings +14 -0
- package/public/OpenAI Settings/Default.settings +15 -0
- package/public/TextGen Settings/Beam Search.settings +15 -0
- package/public/TextGen Settings/Contrastive Search.settings +15 -0
- package/public/TextGen Settings/Default.settings +15 -0
- package/public/TextGen Settings/Deterministic.settings +15 -0
- package/public/TextGen Settings/Kobold (Godlike).settings +15 -0
- package/public/TextGen Settings/Kobold (Liminal Drift).settings +15 -0
- package/public/TextGen Settings/Naive.settings +15 -0
- package/public/TextGen Settings/NovelAI (Best Guess).settings +15 -0
- package/public/TextGen Settings/NovelAI (Decadence).settings +15 -0
- package/public/TextGen Settings/NovelAI (Genesis).settings +15 -0
- package/public/TextGen Settings/NovelAI (Lycaenidae).settings +15 -0
- package/public/TextGen Settings/NovelAI (Ouroboros).settings +15 -0
- package/public/TextGen Settings/NovelAI (Pleasing Results).settings +15 -0
- package/public/TextGen Settings/NovelAI (Sphinx Moth).settings +15 -0
- package/public/TextGen Settings/NovelAI (Storywriter).settings +15 -0
- package/public/TextGen Settings/Pygmalion.settings +15 -0
- package/public/css/fontawesome.css +8488 -0
- package/public/css/notes.css +46 -0
- package/public/css/solid.css +24 -0
- package/public/favicon.ico +0 -0
- package/public/img/No-Image-Placeholder.svg +309 -0
- package/public/img/addbg3.png +0 -0
- package/public/img/ai4.png +0 -0
- package/public/img/apple-icon-114x114.png +0 -0
- package/public/img/apple-icon-144x144.png +0 -0
- package/public/img/apple-icon-57x57.png +0 -0
- package/public/img/apple-icon-72x72.png +0 -0
- package/public/img/book2.png +0 -0
- package/public/img/default-expressions/admiration.png +0 -0
- package/public/img/default-expressions/amusement.png +0 -0
- package/public/img/default-expressions/anger.png +0 -0
- package/public/img/default-expressions/annoyance.png +0 -0
- package/public/img/default-expressions/approval.png +0 -0
- package/public/img/default-expressions/caring.png +0 -0
- package/public/img/default-expressions/confusion.png +0 -0
- package/public/img/default-expressions/curiosity.png +0 -0
- package/public/img/default-expressions/desire.png +0 -0
- package/public/img/default-expressions/desire1.png +0 -0
- package/public/img/default-expressions/desire2.png +0 -0
- package/public/img/default-expressions/disappointment.png +0 -0
- package/public/img/default-expressions/disapproval.png +0 -0
- package/public/img/default-expressions/disgust.png +0 -0
- package/public/img/default-expressions/embarrassment.png +0 -0
- package/public/img/default-expressions/excitement.png +0 -0
- package/public/img/default-expressions/fear.png +0 -0
- package/public/img/default-expressions/gratitude.png +0 -0
- package/public/img/default-expressions/grief.png +0 -0
- package/public/img/default-expressions/joy.png +0 -0
- package/public/img/default-expressions/love.png +0 -0
- package/public/img/default-expressions/nervousness.png +0 -0
- package/public/img/default-expressions/neutral.png +0 -0
- package/public/img/default-expressions/optimism.png +0 -0
- package/public/img/default-expressions/pride.png +0 -0
- package/public/img/default-expressions/realization.png +0 -0
- package/public/img/default-expressions/relief.png +0 -0
- package/public/img/default-expressions/remorse.png +0 -0
- package/public/img/default-expressions/sadness.png +0 -0
- package/public/img/default-expressions/surprise.png +0 -0
- package/public/img/five.png +0 -0
- package/public/img/times-circle.svg +1 -0
- package/public/img/you.png +0 -0
- package/public/index.html +1899 -0
- package/public/notes/1.html +44 -0
- package/public/notes/1.png +0 -0
- package/public/notes/10.html +20 -0
- package/public/notes/11.html +33 -0
- package/public/notes/12.html +27 -0
- package/public/notes/13.html +29 -0
- package/public/notes/13_1.html +24 -0
- package/public/notes/13_2.html +25 -0
- package/public/notes/13_3.html +89 -0
- package/public/notes/14.html +30 -0
- package/public/notes/2.html +37 -0
- package/public/notes/2.png +0 -0
- package/public/notes/3.html +37 -0
- package/public/notes/4.html +105 -0
- package/public/notes/6.html +33 -0
- package/public/notes/7.html +40 -0
- package/public/notes/8.html +19 -0
- package/public/notes/9.html +46 -0
- package/public/notes/advanced_formatting.html +91 -0
- package/public/notes/group_reply_strategy.html +63 -0
- package/public/notes/message_sound.html +33 -0
- package/public/notes/multigen.html +36 -0
- package/public/notes/oai_api_key.html +37 -0
- package/public/notes/textgen_streaming.html +29 -0
- package/public/notes/token-limits.html +68 -0
- package/public/script.js +5131 -0
- package/public/scripts/RossAscends-mods.js +750 -0
- package/public/scripts/bookmarks.js +130 -0
- package/public/scripts/extensions/backgrounds/index.js +129 -0
- package/public/scripts/extensions/backgrounds/manifest.json +11 -0
- package/public/scripts/extensions/backgrounds/style.css +45 -0
- package/public/scripts/extensions/caption/index.js +117 -0
- package/public/scripts/extensions/caption/manifest.json +13 -0
- package/public/scripts/extensions/caption/style.css +23 -0
- package/public/scripts/extensions/dice/droll.js +108 -0
- package/public/scripts/extensions/dice/index.js +96 -0
- package/public/scripts/extensions/dice/manifest.json +11 -0
- package/public/scripts/extensions/dice/style.css +26 -0
- package/public/scripts/extensions/expressions/index.js +387 -0
- package/public/scripts/extensions/expressions/manifest.json +13 -0
- package/public/scripts/extensions/expressions/style.css +115 -0
- package/public/scripts/extensions/floating-prompt/index.js +151 -0
- package/public/scripts/extensions/floating-prompt/manifest.json +11 -0
- package/public/scripts/extensions/floating-prompt/style.css +19 -0
- package/public/scripts/extensions/memory/index.js +358 -0
- package/public/scripts/extensions/memory/manifest.json +13 -0
- package/public/scripts/extensions/memory/style.css +34 -0
- package/public/scripts/extensions.js +288 -0
- package/public/scripts/f-localStorage.js +27 -0
- package/public/scripts/gpt-2-3-tokenizer/README.md +28 -0
- package/public/scripts/gpt-2-3-tokenizer/encoder.js +1 -0
- package/public/scripts/gpt-2-3-tokenizer/mod.js +169 -0
- package/public/scripts/gpt-2-3-tokenizer/vocab.bpe.js +1 -0
- package/public/scripts/gpt-3-tokenizer/array-keyed-map.js +210 -0
- package/public/scripts/gpt-3-tokenizer/gpt3-tokenizer.js +271 -0
- package/public/scripts/gpt-3-tokenizer/gpt3-tokenizer.js.map +1 -0
- package/public/scripts/group-chats.js +899 -0
- package/public/scripts/horde.js +214 -0
- package/public/scripts/jquery-3.5.1.min.js +2 -0
- package/public/scripts/jquery-cookie-1.4.1.min.js +2 -0
- package/public/scripts/jquery.transit.min.js +1 -0
- package/public/scripts/kai-settings.js +179 -0
- package/public/scripts/nai-settings.js +108 -0
- package/public/scripts/openai.js +973 -0
- package/public/scripts/poe.js +360 -0
- package/public/scripts/popper.js +2008 -0
- package/public/scripts/popper.js.map +1 -0
- package/public/scripts/power-user.js +571 -0
- package/public/scripts/purify.min.js +3 -0
- package/public/scripts/purify.min.js.map +1 -0
- package/public/scripts/showdown.min.js +3 -0
- package/public/scripts/showdown.min.js.map +1 -0
- package/public/scripts/swiped-events.js +165 -0
- package/public/scripts/textgen-settings.js +194 -0
- package/public/scripts/toolcool-color-picker.js +87 -0
- package/public/scripts/utils.js +109 -0
- package/public/scripts/world-info.js +661 -0
- package/public/sounds/message.mp3 +0 -0
- package/public/style.css +3633 -0
- package/public/webfonts/NotoSans/NotoSans-Black.woff +0 -0
- package/public/webfonts/NotoSans/NotoSans-Black.woff2 +0 -0
- package/public/webfonts/NotoSans/NotoSans-BlackItalic.woff +0 -0
- package/public/webfonts/NotoSans/NotoSans-BlackItalic.woff2 +0 -0
- package/public/webfonts/NotoSans/NotoSans-Bold.woff +0 -0
- package/public/webfonts/NotoSans/NotoSans-Bold.woff2 +0 -0
- package/public/webfonts/NotoSans/NotoSans-BoldItalic.woff +0 -0
- package/public/webfonts/NotoSans/NotoSans-BoldItalic.woff2 +0 -0
- package/public/webfonts/NotoSans/NotoSans-ExtraBold.woff +0 -0
- package/public/webfonts/NotoSans/NotoSans-ExtraBold.woff2 +0 -0
- package/public/webfonts/NotoSans/NotoSans-ExtraBoldItalic.woff +0 -0
- package/public/webfonts/NotoSans/NotoSans-ExtraBoldItalic.woff2 +0 -0
- package/public/webfonts/NotoSans/NotoSans-ExtraLight.woff +0 -0
- package/public/webfonts/NotoSans/NotoSans-ExtraLight.woff2 +0 -0
- package/public/webfonts/NotoSans/NotoSans-ExtraLightItalic.woff +0 -0
- package/public/webfonts/NotoSans/NotoSans-ExtraLightItalic.woff2 +0 -0
- package/public/webfonts/NotoSans/NotoSans-Italic.woff +0 -0
- package/public/webfonts/NotoSans/NotoSans-Italic.woff2 +0 -0
- package/public/webfonts/NotoSans/NotoSans-Light.woff +0 -0
- package/public/webfonts/NotoSans/NotoSans-Light.woff2 +0 -0
- package/public/webfonts/NotoSans/NotoSans-LightItalic.woff +0 -0
- package/public/webfonts/NotoSans/NotoSans-LightItalic.woff2 +0 -0
- package/public/webfonts/NotoSans/NotoSans-Medium.woff +0 -0
- package/public/webfonts/NotoSans/NotoSans-Medium.woff2 +0 -0
- package/public/webfonts/NotoSans/NotoSans-MediumItalic.woff +0 -0
- package/public/webfonts/NotoSans/NotoSans-MediumItalic.woff2 +0 -0
- package/public/webfonts/NotoSans/NotoSans-Regular.woff +0 -0
- package/public/webfonts/NotoSans/NotoSans-Regular.woff2 +0 -0
- package/public/webfonts/NotoSans/NotoSans-SemiBold.woff +0 -0
- package/public/webfonts/NotoSans/NotoSans-SemiBold.woff2 +0 -0
- package/public/webfonts/NotoSans/NotoSans-SemiBoldItalic.woff +0 -0
- package/public/webfonts/NotoSans/NotoSans-SemiBoldItalic.woff2 +0 -0
- package/public/webfonts/NotoSans/NotoSans-Thin.woff +0 -0
- package/public/webfonts/NotoSans/NotoSans-Thin.woff2 +0 -0
- package/public/webfonts/NotoSans/NotoSans-ThinItalic.woff +0 -0
- package/public/webfonts/NotoSans/NotoSans-ThinItalic.woff2 +0 -0
- package/public/webfonts/NotoSans/stylesheet.css +162 -0
- package/public/webfonts/fa-solid-900.ttf +0 -0
- package/public/webfonts/fa-solid-900.woff2 +0 -0
- package/readme.md +187 -0
- package/server.js +2593 -0
- package/start.sh +24 -0
- package/tools/charaverter/main.mjs +110 -0
- package/tools/charaverter/package.json +10 -0
|
@@ -0,0 +1,571 @@
|
|
|
1
|
+
import {
|
|
2
|
+
saveSettingsDebounced,
|
|
3
|
+
scrollChatToBottom,
|
|
4
|
+
characters,
|
|
5
|
+
callPopup,
|
|
6
|
+
token,
|
|
7
|
+
getStatus,
|
|
8
|
+
} from "../script.js";
|
|
9
|
+
import { delay } from "./utils.js";
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
loadPowerUserSettings,
|
|
14
|
+
collapseNewlines,
|
|
15
|
+
playMessageSound,
|
|
16
|
+
sortCharactersList,
|
|
17
|
+
power_user,
|
|
18
|
+
pygmalion_options,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const avatar_styles = {
|
|
22
|
+
ROUND: 0,
|
|
23
|
+
RECTANGULAR: 1,
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const chat_styles = {
|
|
27
|
+
DEFAULT: 0,
|
|
28
|
+
BUBBLES: 1,
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const sheld_width = {
|
|
32
|
+
DEFAULT: 0,
|
|
33
|
+
w1000px: 1,
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const pygmalion_options = {
|
|
37
|
+
DISABLED: -1,
|
|
38
|
+
AUTO: 0,
|
|
39
|
+
ENABLED: 1,
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
let power_user = {
|
|
43
|
+
collapse_newlines: false,
|
|
44
|
+
pygmalion_formatting: pygmalion_options.AUTO,
|
|
45
|
+
pin_examples: false,
|
|
46
|
+
disable_description_formatting: false,
|
|
47
|
+
disable_scenario_formatting: false,
|
|
48
|
+
disable_personality_formatting: false,
|
|
49
|
+
disable_examples_formatting: false,
|
|
50
|
+
disable_start_formatting: false,
|
|
51
|
+
always_force_name2: false,
|
|
52
|
+
multigen: false,
|
|
53
|
+
multigen_first_chunk: 50,
|
|
54
|
+
multigen_next_chunks: 30,
|
|
55
|
+
custom_chat_separator: '',
|
|
56
|
+
fast_ui_mode: true,
|
|
57
|
+
avatar_style: avatar_styles.ROUND,
|
|
58
|
+
chat_display: chat_styles.DEFAULT,
|
|
59
|
+
sheld_width: sheld_width.DEFAULT,
|
|
60
|
+
play_message_sound: false,
|
|
61
|
+
play_sound_unfocused: true,
|
|
62
|
+
auto_save_msg_edits: false,
|
|
63
|
+
sort_field: 'name',
|
|
64
|
+
sort_order: 'asc',
|
|
65
|
+
font_scale: 1,
|
|
66
|
+
blur_strength: 10,
|
|
67
|
+
|
|
68
|
+
main_text_color: `${getComputedStyle(document.documentElement).getPropertyValue('--SmartThemeBodyColor').trim()}`,
|
|
69
|
+
italics_text_color: `${getComputedStyle(document.documentElement).getPropertyValue('--SmartThemeEmColor').trim()}`,
|
|
70
|
+
fastui_bg_color: `${getComputedStyle(document.documentElement).getPropertyValue('--SmartThemeFastUIBGColor').trim()}`,
|
|
71
|
+
blur_tint_color: `${getComputedStyle(document.documentElement).getPropertyValue('--SmartThemeBlurTintColor').trim()}`,
|
|
72
|
+
|
|
73
|
+
waifuMode: false,
|
|
74
|
+
movingUI: false,
|
|
75
|
+
theme: 'Default (Dark)',
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
let themes = [];
|
|
79
|
+
|
|
80
|
+
const storage_keys = {
|
|
81
|
+
fast_ui_mode: "TavernAI_fast_ui_mode",
|
|
82
|
+
avatar_style: "TavernAI_avatar_style",
|
|
83
|
+
chat_display: "TavernAI_chat_display",
|
|
84
|
+
sheld_width: "TavernAI_sheld_width",
|
|
85
|
+
font_scale: "TavernAI_font_scale",
|
|
86
|
+
|
|
87
|
+
main_text_color: "TavernAI_main_text_color",
|
|
88
|
+
italics_text_color: "TavernAI_italics_text_color",
|
|
89
|
+
fastui_bg_color: "TavernAI_fastui_bg_color",
|
|
90
|
+
blur_tint_color: "TavernAI_blur_tint_color",
|
|
91
|
+
blur_strength: "TavernAI_blur_strength",
|
|
92
|
+
|
|
93
|
+
waifuMode: "TavernAI_waifuMode",
|
|
94
|
+
movingUI: "TavernAI_movingUI",
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const chat = document.getElementById('chat');
|
|
98
|
+
let browser_has_focus = true;
|
|
99
|
+
|
|
100
|
+
function playMessageSound() {
|
|
101
|
+
if (!power_user.play_message_sound) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (power_user.play_sound_unfocused && browser_has_focus) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const audio = document.getElementById('audio_message_sound');
|
|
110
|
+
audio.volume = 0.8;
|
|
111
|
+
audio.pause();
|
|
112
|
+
audio.currentTime = 0;
|
|
113
|
+
audio.play();
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function collapseNewlines(x) {
|
|
117
|
+
return x.replaceAll(/\n+/g, "\n");
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function switchUiMode() {
|
|
121
|
+
const fastUi = localStorage.getItem(storage_keys.fast_ui_mode);
|
|
122
|
+
power_user.fast_ui_mode = fastUi === null ? true : fastUi == "true";
|
|
123
|
+
$("body").toggleClass("no-blur", power_user.fast_ui_mode);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function switchWaifuMode() {
|
|
127
|
+
const waifuMode = localStorage.getItem(storage_keys.waifuMode);
|
|
128
|
+
power_user.waifuMode = waifuMode === null ? false : waifuMode == "true";
|
|
129
|
+
$("body").toggleClass("waifuMode", power_user.waifuMode);
|
|
130
|
+
scrollChatToBottom();
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function switchMovingUI() {
|
|
134
|
+
const movingUI = localStorage.getItem(storage_keys.movingUI);
|
|
135
|
+
power_user.movingUI = movingUI === null ? false : movingUI == "true";
|
|
136
|
+
$("body").toggleClass("movingUI", power_user.movingUI);
|
|
137
|
+
scrollChatToBottom();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function applyAvatarStyle() {
|
|
141
|
+
power_user.avatar_style = Number(localStorage.getItem(storage_keys.avatar_style) ?? avatar_styles.ROUND);
|
|
142
|
+
$("body").toggleClass("big-avatars", power_user.avatar_style === avatar_styles.RECTANGULAR);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function applyChatDisplay() {
|
|
146
|
+
power_user.chat_display = Number(localStorage.getItem(storage_keys.chat_display) ?? chat_styles.DEFAULT);
|
|
147
|
+
$("body").toggleClass("bubblechat", power_user.chat_display === chat_styles.BUBBLES);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function applySheldWidth() {
|
|
151
|
+
power_user.sheld_width = Number(localStorage.getItem(storage_keys.sheld_width) ?? chat_styles.DEFAULT);
|
|
152
|
+
$("body").toggleClass("w1000px", power_user.sheld_width === sheld_width.w1000px);
|
|
153
|
+
let r = document.documentElement;
|
|
154
|
+
if (power_user.sheld_width === 1) {
|
|
155
|
+
r.style.setProperty('--sheldWidth', '1000px');
|
|
156
|
+
} else {
|
|
157
|
+
r.style.setProperty('--sheldWidth', '800px');
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
async function applyThemeColor(type) {
|
|
162
|
+
if (type === 'main') {
|
|
163
|
+
document.documentElement.style.setProperty('--SmartThemeBodyColor', power_user.main_text_color);
|
|
164
|
+
}
|
|
165
|
+
if (type === 'italics') {
|
|
166
|
+
document.documentElement.style.setProperty('--SmartThemeEmColor', power_user.italics_text_color);
|
|
167
|
+
}
|
|
168
|
+
if (type === 'fastUIBG') {
|
|
169
|
+
document.documentElement.style.setProperty('--SmartThemeFastUIBGColor', power_user.fastui_bg_color);
|
|
170
|
+
}
|
|
171
|
+
if (type === 'blurTint') {
|
|
172
|
+
document.documentElement.style.setProperty('--SmartThemeBlurTintColor', power_user.blur_tint_color);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
async function applyBlurStrength() {
|
|
177
|
+
power_user.blur_strength = Number(localStorage.getItem(storage_keys.blur_strength) ?? 1);
|
|
178
|
+
document.documentElement.style.setProperty('--blurStrength', power_user.blur_strength);
|
|
179
|
+
$("#blur_strength_counter").text(power_user.blur_strength);
|
|
180
|
+
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
async function applyFontScale() {
|
|
185
|
+
power_user.font_scale = Number(localStorage.getItem(storage_keys.font_scale) ?? 1);
|
|
186
|
+
document.documentElement.style.setProperty('--fontScale', power_user.font_scale);
|
|
187
|
+
$("#font_scale_counter").text(power_user.font_scale);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
async function applyTheme(name) {
|
|
191
|
+
const theme = themes.find(x => x.name == name);
|
|
192
|
+
|
|
193
|
+
if (!theme) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const themeProperties = [
|
|
198
|
+
{ key: 'main_text_color', selector: '#main-text-color-picker', type: 'main' },
|
|
199
|
+
{ key: 'italics_text_color', selector: '#italics-color-picker', type: 'italics' },
|
|
200
|
+
{ key: 'fastui_bg_color', selector: '#fastui-bg-color-picker', type: 'fastUIBG' },
|
|
201
|
+
{ key: 'blur_tint_color', selector: '#blur-tint-color-picker', type: 'blurTint' },
|
|
202
|
+
{
|
|
203
|
+
key: 'blur_strength',
|
|
204
|
+
action: async () => {
|
|
205
|
+
localStorage.setItem(storage_keys.blur_strength, power_user.blur_strength);
|
|
206
|
+
await applyBlurStrength();
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
];
|
|
210
|
+
|
|
211
|
+
for (const { key, selector, type, action } of themeProperties) {
|
|
212
|
+
if (theme[key] !== undefined) {
|
|
213
|
+
power_user[key] = theme[key];
|
|
214
|
+
if (selector) $(selector).attr('color', power_user[key]);
|
|
215
|
+
if (type) await applyThemeColor(type);
|
|
216
|
+
if (action) await action();
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
console.log('theme applied: ' + name);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
switchUiMode();
|
|
224
|
+
applyFontScale();
|
|
225
|
+
applyThemeColor();
|
|
226
|
+
applySheldWidth();
|
|
227
|
+
applyAvatarStyle();
|
|
228
|
+
applyBlurStrength();
|
|
229
|
+
applyChatDisplay();
|
|
230
|
+
switchWaifuMode()
|
|
231
|
+
switchMovingUI();
|
|
232
|
+
|
|
233
|
+
function loadPowerUserSettings(settings, data) {
|
|
234
|
+
// Load from settings.json
|
|
235
|
+
if (settings.power_user !== undefined) {
|
|
236
|
+
Object.assign(power_user, settings.power_user);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if (data.themes !== undefined) {
|
|
240
|
+
themes = data.themes;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// These are still local storage
|
|
244
|
+
const fastUi = localStorage.getItem(storage_keys.fast_ui_mode);
|
|
245
|
+
const waifuMode = localStorage.getItem(storage_keys.waifuMode);
|
|
246
|
+
const movingUI = localStorage.getItem(storage_keys.movingUI);
|
|
247
|
+
power_user.fast_ui_mode = fastUi === null ? true : fastUi == "true";
|
|
248
|
+
power_user.waifuMode = waifuMode === null ? false : waifuMode == "true";
|
|
249
|
+
power_user.movingUI = movingUI === null ? false : movingUI == "true";
|
|
250
|
+
power_user.avatar_style = Number(localStorage.getItem(storage_keys.avatar_style) ?? avatar_styles.ROUND);
|
|
251
|
+
power_user.chat_display = Number(localStorage.getItem(storage_keys.chat_display) ?? chat_styles.DEFAULT);
|
|
252
|
+
power_user.sheld_width = Number(localStorage.getItem(storage_keys.sheld_width) ?? sheld_width.DEFAULT);
|
|
253
|
+
power_user.font_scale = Number(localStorage.getItem(storage_keys.font_scale) ?? 1);
|
|
254
|
+
power_user.blur_strength = Number(localStorage.getItem(storage_keys.blur_strength) ?? 10);
|
|
255
|
+
|
|
256
|
+
$(`#pygmalion_formatting option[value=${power_user.pygmalion_formatting}]`).attr("selected", true);
|
|
257
|
+
$("#collapse-newlines-checkbox").prop("checked", power_user.collapse_newlines);
|
|
258
|
+
$("#pin-examples-checkbox").prop("checked", power_user.pin_examples);
|
|
259
|
+
$("#disable-description-formatting-checkbox").prop("checked", power_user.disable_description_formatting);
|
|
260
|
+
$("#disable-scenario-formatting-checkbox").prop("checked", power_user.disable_scenario_formatting);
|
|
261
|
+
$("#disable-personality-formatting-checkbox").prop("checked", power_user.disable_personality_formatting);
|
|
262
|
+
$("#always-force-name2-checkbox").prop("checked", power_user.always_force_name2);
|
|
263
|
+
$("#disable-examples-formatting-checkbox").prop("checked", power_user.disable_examples_formatting);
|
|
264
|
+
$('#disable-start-formatting-checkbox').prop("checked", power_user.disable_start_formatting);
|
|
265
|
+
$("#custom_chat_separator").val(power_user.custom_chat_separator);
|
|
266
|
+
$("#fast_ui_mode").prop("checked", power_user.fast_ui_mode);
|
|
267
|
+
$("#waifuMode").prop("checked", power_user.waifuMode);
|
|
268
|
+
$("#movingUImode").prop("checked", power_user.movingUI);
|
|
269
|
+
$("#multigen").prop("checked", power_user.multigen);
|
|
270
|
+
$("#multigen_first_chunk").val(power_user.multigen_first_chunk);
|
|
271
|
+
$("#multigen_next_chunks").val(power_user.multigen_next_chunks);
|
|
272
|
+
$("#play_message_sound").prop("checked", power_user.play_message_sound);
|
|
273
|
+
$("#play_sound_unfocused").prop("checked", power_user.play_sound_unfocused);
|
|
274
|
+
$("#auto_save_msg_edits").prop("checked", power_user.auto_save_msg_edits);
|
|
275
|
+
$(`input[name="avatar_style"][value="${power_user.avatar_style}"]`).prop("checked", true);
|
|
276
|
+
$(`input[name="chat_display"][value="${power_user.chat_display}"]`).prop("checked", true);
|
|
277
|
+
$(`input[name="sheld_width"][value="${power_user.sheld_width}"]`).prop("checked", true);
|
|
278
|
+
$("#font_scale").val(power_user.font_scale);
|
|
279
|
+
$("#font_scale_counter").text(power_user.font_scale);
|
|
280
|
+
|
|
281
|
+
$("#blur_strength").val(power_user.blur_strength);
|
|
282
|
+
$("#blur_strength_counter").text(power_user.blur_strength);
|
|
283
|
+
|
|
284
|
+
$("#main-text-color-picker").attr('color', power_user.main_text_color);
|
|
285
|
+
$("#italics-color-picker").attr('color', power_user.italics_text_color);
|
|
286
|
+
$("#fastui-bg-color-picker").attr('color', power_user.fastui_bg_color);
|
|
287
|
+
$("#blur-tint-color-picker").attr('color', power_user.blur_tint_color);
|
|
288
|
+
|
|
289
|
+
for (const theme of themes) {
|
|
290
|
+
const option = document.createElement('option');
|
|
291
|
+
option.value = theme.name;
|
|
292
|
+
option.innerText = theme.name;
|
|
293
|
+
option.selected = theme.name == power_user.theme;
|
|
294
|
+
$("#themes").append(option);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
$(`#character_sort_order option[data-order="${power_user.sort_order}"][data-field="${power_user.sort_field}"]`).prop("selected", true);
|
|
298
|
+
sortCharactersList();
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
function sortCharactersList(selector = '.character_select') {
|
|
302
|
+
const sortFunc = (a, b) => power_user.sort_order == 'asc' ? compareFunc(a, b) : compareFunc(b, a);
|
|
303
|
+
const compareFunc = (first, second) => typeof first[power_user.sort_field] == "string"
|
|
304
|
+
? first[power_user.sort_field].localeCompare(second[power_user.sort_field])
|
|
305
|
+
: first[power_user.sort_field] - second[power_user.sort_field];
|
|
306
|
+
|
|
307
|
+
if (power_user.sort_field == undefined || characters.length === 0) {
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
let orderedList = characters.slice().sort(sortFunc);
|
|
312
|
+
|
|
313
|
+
for (let i = 0; i < characters.length; i++) {
|
|
314
|
+
$(`${selector}[chid="${i}"]`).css({ 'order': orderedList.indexOf(characters[i]) });
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
$(document).ready(() => {
|
|
319
|
+
// Settings that go to settings.json
|
|
320
|
+
$("#collapse-newlines-checkbox").change(function () {
|
|
321
|
+
power_user.collapse_newlines = !!$(this).prop("checked");
|
|
322
|
+
saveSettingsDebounced();
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
$("#pygmalion_formatting").change(function (e) {
|
|
326
|
+
power_user.pygmalion_formatting = Number($(this).find(":selected").val());
|
|
327
|
+
getStatus();
|
|
328
|
+
saveSettingsDebounced();
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
$("#pin-examples-checkbox").change(function () {
|
|
332
|
+
power_user.pin_examples = !!$(this).prop("checked");
|
|
333
|
+
saveSettingsDebounced();
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
$("#disable-description-formatting-checkbox").change(function () {
|
|
337
|
+
power_user.disable_description_formatting = !!$(this).prop('checked');
|
|
338
|
+
saveSettingsDebounced();
|
|
339
|
+
})
|
|
340
|
+
|
|
341
|
+
$("#disable-scenario-formatting-checkbox").change(function () {
|
|
342
|
+
power_user.disable_scenario_formatting = !!$(this).prop('checked');
|
|
343
|
+
saveSettingsDebounced();
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
$("#disable-personality-formatting-checkbox").change(function () {
|
|
347
|
+
power_user.disable_personality_formatting = !!$(this).prop('checked');
|
|
348
|
+
saveSettingsDebounced();
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
$("#disable-examples-formatting-checkbox").change(function () {
|
|
352
|
+
power_user.disable_examples_formatting = !!$(this).prop('checked');
|
|
353
|
+
saveSettingsDebounced();
|
|
354
|
+
})
|
|
355
|
+
|
|
356
|
+
$("#disable-start-formatting-checkbox").change(function () {
|
|
357
|
+
power_user.disable_start_formatting = !!$(this).prop('checked');
|
|
358
|
+
saveSettingsDebounced();
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
$("#always-force-name2-checkbox").change(function () {
|
|
362
|
+
power_user.always_force_name2 = !!$(this).prop("checked");
|
|
363
|
+
saveSettingsDebounced();
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
$("#custom_chat_separator").on('input', function () {
|
|
367
|
+
power_user.custom_chat_separator = $(this).val();
|
|
368
|
+
saveSettingsDebounced();
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
$("#multigen").change(function () {
|
|
372
|
+
power_user.multigen = $(this).prop("checked");
|
|
373
|
+
saveSettingsDebounced();
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
// Settings that go to local storage
|
|
377
|
+
$("#fast_ui_mode").change(function () {
|
|
378
|
+
power_user.fast_ui_mode = $(this).prop("checked");
|
|
379
|
+
localStorage.setItem(storage_keys.fast_ui_mode, power_user.fast_ui_mode);
|
|
380
|
+
switchUiMode();
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
$("#waifuMode").change(function () {
|
|
384
|
+
power_user.waifuMode = $(this).prop("checked");
|
|
385
|
+
localStorage.setItem(storage_keys.waifuMode, power_user.waifuMode);
|
|
386
|
+
switchWaifuMode();
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
$("#movingUImode").change(function () {
|
|
390
|
+
power_user.movingUI = $(this).prop("checked");
|
|
391
|
+
localStorage.setItem(storage_keys.movingUI, power_user.movingUI);
|
|
392
|
+
switchMovingUI();
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
$("#movingUIreset").on('click', function () {
|
|
396
|
+
|
|
397
|
+
document.getElementById("sheld").style.top = '';
|
|
398
|
+
document.getElementById("sheld").style.left = '';
|
|
399
|
+
document.getElementById("sheld").style.height = '';
|
|
400
|
+
document.getElementById("sheld").style.width = '';
|
|
401
|
+
|
|
402
|
+
document.getElementById("left-nav-panel").style.top = '';
|
|
403
|
+
document.getElementById("left-nav-panel").style.left = '';
|
|
404
|
+
document.getElementById("left-nav-panel").style.height = '';
|
|
405
|
+
document.getElementById("left-nav-panel").style.width = '';
|
|
406
|
+
|
|
407
|
+
document.getElementById("right-nav-panel").style.top = '';
|
|
408
|
+
document.getElementById("right-nav-panel").style.left = '';
|
|
409
|
+
document.getElementById("right-nav-panel").style.right = '';
|
|
410
|
+
document.getElementById("right-nav-panel").style.height = '';
|
|
411
|
+
document.getElementById("right-nav-panel").style.width = '';
|
|
412
|
+
|
|
413
|
+
document.getElementById("expression-holder").style.top = '';
|
|
414
|
+
document.getElementById("expression-holder").style.left = '';
|
|
415
|
+
document.getElementById("expression-holder").style.right = '';
|
|
416
|
+
document.getElementById("expression-holder").style.bottom = '';
|
|
417
|
+
document.getElementById("expression-holder").style.height = '';
|
|
418
|
+
document.getElementById("expression-holder").style.width = '';
|
|
419
|
+
|
|
420
|
+
})
|
|
421
|
+
|
|
422
|
+
$(`input[name="avatar_style"]`).on('input', function (e) {
|
|
423
|
+
power_user.avatar_style = Number(e.target.value);
|
|
424
|
+
localStorage.setItem(storage_keys.avatar_style, power_user.avatar_style);
|
|
425
|
+
applyAvatarStyle();
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
$(`input[name="chat_display"]`).on('input', function (e) {
|
|
429
|
+
power_user.chat_display = Number(e.target.value);
|
|
430
|
+
localStorage.setItem(storage_keys.chat_display, power_user.chat_display);
|
|
431
|
+
applyChatDisplay();
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
$(`input[name="sheld_width"]`).on('input', function (e) {
|
|
435
|
+
power_user.sheld_width = Number(e.target.value);
|
|
436
|
+
localStorage.setItem(storage_keys.sheld_width, power_user.sheld_width);
|
|
437
|
+
console.log("sheld width changing now");
|
|
438
|
+
applySheldWidth();
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
$(`input[name="font_scale"]`).on('input', async function (e) {
|
|
442
|
+
power_user.font_scale = Number(e.target.value);
|
|
443
|
+
$("#font_scale_counter").text(power_user.font_scale);
|
|
444
|
+
localStorage.setItem(storage_keys.font_scale, power_user.font_scale);
|
|
445
|
+
await applyFontScale();
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
$(`input[name="blur_strength"]`).on('input', async function (e) {
|
|
449
|
+
power_user.blur_strength = Number(e.target.value);
|
|
450
|
+
$("#blur_strength_counter").text(power_user.blur_strength);
|
|
451
|
+
localStorage.setItem(storage_keys.blur_strength, power_user.blur_strength);
|
|
452
|
+
await applyBlurStrength();
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
$("#main-text-color-picker").on('change', (evt) => {
|
|
456
|
+
power_user.main_text_color = evt.detail.rgba;
|
|
457
|
+
applyThemeColor('main');
|
|
458
|
+
saveSettingsDebounced();
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
$("#italics-color-picker").on('change', (evt) => {
|
|
462
|
+
power_user.italics_text_color = evt.detail.rgba;
|
|
463
|
+
applyThemeColor('italics');
|
|
464
|
+
saveSettingsDebounced();
|
|
465
|
+
});
|
|
466
|
+
|
|
467
|
+
$("#fastui-bg-color-picker").on('change', (evt) => {
|
|
468
|
+
power_user.fastui_bg_color = evt.detail.rgba;
|
|
469
|
+
applyThemeColor('fastUIBG');
|
|
470
|
+
saveSettingsDebounced();
|
|
471
|
+
});
|
|
472
|
+
|
|
473
|
+
$("#blur-tint-color-picker").on('change', (evt) => {
|
|
474
|
+
power_user.blur_tint_color = evt.detail.rgba;
|
|
475
|
+
applyThemeColor('blurTint');
|
|
476
|
+
saveSettingsDebounced();
|
|
477
|
+
});
|
|
478
|
+
|
|
479
|
+
$("#themes").on('change', function () {
|
|
480
|
+
const themeSelected = $(this).find(':selected').val();
|
|
481
|
+
power_user.theme = themeSelected;
|
|
482
|
+
applyTheme(themeSelected);
|
|
483
|
+
saveSettingsDebounced();
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
$("#ui-preset-save-button").on('click', async function () {
|
|
487
|
+
const name = await callPopup('Enter a theme preset name:', 'input');
|
|
488
|
+
|
|
489
|
+
if (!name) {
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
const theme = {
|
|
494
|
+
name,
|
|
495
|
+
blur_strength: power_user.blur_strength,
|
|
496
|
+
main_text_color: power_user.main_text_color,
|
|
497
|
+
italics_text_color: power_user.italics_text_color,
|
|
498
|
+
fastui_bg_color: power_user.fastui_bg_color,
|
|
499
|
+
blur_tint_color: power_user.blur_tint_color,
|
|
500
|
+
};
|
|
501
|
+
|
|
502
|
+
const response = await fetch('/savetheme', {
|
|
503
|
+
method: 'POST', headers: {
|
|
504
|
+
'X-CSRF-Token': token,
|
|
505
|
+
'Content-Type': 'application/json',
|
|
506
|
+
},
|
|
507
|
+
body: JSON.stringify(theme)
|
|
508
|
+
});
|
|
509
|
+
|
|
510
|
+
if (response.ok) {
|
|
511
|
+
const themeIndex = themes.findIndex(x => x.name == name);
|
|
512
|
+
|
|
513
|
+
if (themeIndex == -1) {
|
|
514
|
+
themes.push(theme);
|
|
515
|
+
const option = document.createElement('option');
|
|
516
|
+
option.selected = true;
|
|
517
|
+
option.value = name;
|
|
518
|
+
option.innerText = name;
|
|
519
|
+
$('#themes').append(option);
|
|
520
|
+
}
|
|
521
|
+
else {
|
|
522
|
+
themes[themeIndex] = theme;
|
|
523
|
+
$(`#themes option[value="${name}"]`).attr('selected', true);
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
power_user.theme = name;
|
|
527
|
+
saveSettingsDebounced();
|
|
528
|
+
}
|
|
529
|
+
});
|
|
530
|
+
|
|
531
|
+
$("#play_message_sound").on('input', function () {
|
|
532
|
+
power_user.play_message_sound = !!$(this).prop('checked');
|
|
533
|
+
saveSettingsDebounced();
|
|
534
|
+
});
|
|
535
|
+
|
|
536
|
+
$("#play_sound_unfocused").on('input', function () {
|
|
537
|
+
power_user.play_sound_unfocused = !!$(this).prop('checked');
|
|
538
|
+
saveSettingsDebounced();
|
|
539
|
+
});
|
|
540
|
+
|
|
541
|
+
$("#auto_save_msg_edits").on('input', function () {
|
|
542
|
+
power_user.auto_save_msg_edits = !!$(this).prop('checked');
|
|
543
|
+
saveSettingsDebounced();
|
|
544
|
+
});
|
|
545
|
+
|
|
546
|
+
$("#character_sort_order").on('change', function () {
|
|
547
|
+
power_user.sort_field = $(this).find(":selected").data('field');
|
|
548
|
+
power_user.sort_order = $(this).find(":selected").data('order');
|
|
549
|
+
sortCharactersList();
|
|
550
|
+
saveSettingsDebounced();
|
|
551
|
+
});
|
|
552
|
+
|
|
553
|
+
$("#multigen_first_chunk").on('input', function () {
|
|
554
|
+
power_user.multigen_first_chunk = Number($(this).val());
|
|
555
|
+
saveSettingsDebounced();
|
|
556
|
+
});
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
$("#multigen_next_chunks").on('input', function () {
|
|
560
|
+
power_user.multigen_next_chunks = Number($(this).val());
|
|
561
|
+
saveSettingsDebounced();
|
|
562
|
+
});
|
|
563
|
+
|
|
564
|
+
$(window).on('focus', function () {
|
|
565
|
+
browser_has_focus = true;
|
|
566
|
+
});
|
|
567
|
+
|
|
568
|
+
$(window).on('blur', function () {
|
|
569
|
+
browser_has_focus = false;
|
|
570
|
+
});
|
|
571
|
+
});
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/*! @license DOMPurify 3.0.1 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.0.1/LICENSE */
|
|
2
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).DOMPurify=t()}(this,(function(){"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e,n){return t=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},t(e,n)}function n(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function r(e,o,a){return r=n()?Reflect.construct:function(e,n,r){var o=[null];o.push.apply(o,n);var a=new(Function.bind.apply(e,o));return r&&t(a,r.prototype),a},r.apply(null,arguments)}function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==n)return;var r,o,a=[],i=!0,l=!1;try{for(n=n.call(e);!(i=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);i=!0);}catch(e){l=!0,o=e}finally{try{i||null==n.return||n.return()}finally{if(l)throw o}}return a}(e,t)||i(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e){return function(e){if(Array.isArray(e))return l(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||i(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t){if(e){if("string"==typeof e)return l(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?l(e,t):void 0}}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var c=Object.entries,u=Object.setPrototypeOf,s=Object.isFrozen,f=Object.getPrototypeOf,m=Object.getOwnPropertyDescriptor,p=Object.freeze,d=Object.seal,h=Object.create,y="undefined"!=typeof Reflect&&Reflect,g=y.apply,b=y.construct;g||(g=function(e,t,n){return e.apply(t,n)}),p||(p=function(e){return e}),d||(d=function(e){return e}),b||(b=function(e,t){return r(e,a(t))});var v,T=R(Array.prototype.forEach),N=R(Array.prototype.pop),A=R(Array.prototype.push),E=R(String.prototype.toLowerCase),w=R(String.prototype.toString),S=R(String.prototype.match),_=R(String.prototype.replace),x=R(String.prototype.indexOf),k=R(String.prototype.trim),O=R(RegExp.prototype.test),D=(v=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return b(v,t)});function R(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return g(e,t,r)}}function C(e,t,n){n=n||E,u&&u(e,null);for(var r=t.length;r--;){var o=t[r];if("string"==typeof o){var a=n(o);a!==o&&(s(t)||(t[r]=a),o=a)}e[o]=!0}return e}function L(e){var t,n=h(null),r=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=i(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,l=!0,c=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return l=e.done,e},e:function(e){c=!0,a=e},f:function(){try{l||null==n.return||n.return()}finally{if(c)throw a}}}}(c(e));try{for(r.s();!(t=r.n()).done;){var a=o(t.value,2),l=a[0],u=a[1];n[l]=u}}catch(e){r.e(e)}finally{r.f()}return n}function M(e,t){for(;null!==e;){var n=m(e,t);if(n){if(n.get)return R(n.get);if("function"==typeof n.value)return R(n.value)}e=f(e)}return function(e){return console.warn("fallback value for",e),null}}var I=p(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),U=p(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),F=p(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),z=p(["animate","color-profile","cursor","discard","fedropshadow","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),H=p(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover"]),j=p(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),P=p(["#text"]),B=p(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","xmlns","slot"]),G=p(["accent-height","accumulate","additive","alignment-baseline","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),W=p(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),q=p(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Y=d(/\{\{[\w\W]*|[\w\W]*\}\}/gm),$=d(/<%[\w\W]*|[\w\W]*%>/gm),K=d(/\${[\w\W]*}/gm),V=d(/^data-[\-\w.\u00B7-\uFFFF]/),X=d(/^aria-[\-\w]+$/),Z=d(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),J=d(/^(?:\w+script|data):/i),Q=d(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),ee=d(/^html$/i),te=function(){return"undefined"==typeof window?null:window},ne=function(t,n){if("object"!==e(t)||"function"!=typeof t.createPolicy)return null;var r=null,o="data-tt-policy-suffix";n.currentScript&&n.currentScript.hasAttribute(o)&&(r=n.currentScript.getAttribute(o));var a="dompurify"+(r?"#"+r:"");try{return t.createPolicy(a,{createHTML:function(e){return e},createScriptURL:function(e){return e}})}catch(e){return console.warn("TrustedTypes policy "+a+" could not be created."),null}};var re=function t(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:te(),r=function(e){return t(e)};if(r.version="3.0.1",r.removed=[],!n||!n.document||9!==n.document.nodeType)return r.isSupported=!1,r;var o=n.document,i=n.document,l=n.DocumentFragment,u=n.HTMLTemplateElement,s=n.Node,f=n.Element,m=n.NodeFilter,d=n.NamedNodeMap,h=void 0===d?n.NamedNodeMap||n.MozNamedAttrMap:d,y=n.HTMLFormElement,g=n.DOMParser,b=n.trustedTypes,v=f.prototype,R=M(v,"cloneNode"),re=M(v,"nextSibling"),oe=M(v,"childNodes"),ae=M(v,"parentNode");if("function"==typeof u){var ie=i.createElement("template");ie.content&&ie.content.ownerDocument&&(i=ie.content.ownerDocument)}var le=ne(b,o),ce=le?le.createHTML(""):"",ue=i,se=ue.implementation,fe=ue.createNodeIterator,me=ue.createDocumentFragment,pe=ue.getElementsByTagName,de=o.importNode,he={};r.isSupported="function"==typeof c&&"function"==typeof ae&&se&&void 0!==se.createHTMLDocument;var ye,ge,be=Y,ve=$,Te=K,Ne=V,Ae=X,Ee=J,we=Q,Se=Z,_e=null,xe=C({},[].concat(a(I),a(U),a(F),a(H),a(P))),ke=null,Oe=C({},[].concat(a(B),a(G),a(W),a(q))),De=Object.seal(Object.create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Re=null,Ce=null,Le=!0,Me=!0,Ie=!1,Ue=!0,Fe=!1,ze=!1,He=!1,je=!1,Pe=!1,Be=!1,Ge=!1,We=!0,qe=!1,Ye="user-content-",$e=!0,Ke=!1,Ve={},Xe=null,Ze=C({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),Je=null,Qe=C({},["audio","video","img","source","image","track"]),et=null,tt=C({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),nt="http://www.w3.org/1998/Math/MathML",rt="http://www.w3.org/2000/svg",ot="http://www.w3.org/1999/xhtml",at=ot,it=!1,lt=null,ct=C({},[nt,rt,ot],w),ut=["application/xhtml+xml","text/html"],st="text/html",ft=null,mt=i.createElement("form"),pt=function(e){return e instanceof RegExp||e instanceof Function},dt=function(t){ft&&ft===t||(t&&"object"===e(t)||(t={}),t=L(t),ye=ye=-1===ut.indexOf(t.PARSER_MEDIA_TYPE)?st:t.PARSER_MEDIA_TYPE,ge="application/xhtml+xml"===ye?w:E,_e="ALLOWED_TAGS"in t?C({},t.ALLOWED_TAGS,ge):xe,ke="ALLOWED_ATTR"in t?C({},t.ALLOWED_ATTR,ge):Oe,lt="ALLOWED_NAMESPACES"in t?C({},t.ALLOWED_NAMESPACES,w):ct,et="ADD_URI_SAFE_ATTR"in t?C(L(tt),t.ADD_URI_SAFE_ATTR,ge):tt,Je="ADD_DATA_URI_TAGS"in t?C(L(Qe),t.ADD_DATA_URI_TAGS,ge):Qe,Xe="FORBID_CONTENTS"in t?C({},t.FORBID_CONTENTS,ge):Ze,Re="FORBID_TAGS"in t?C({},t.FORBID_TAGS,ge):{},Ce="FORBID_ATTR"in t?C({},t.FORBID_ATTR,ge):{},Ve="USE_PROFILES"in t&&t.USE_PROFILES,Le=!1!==t.ALLOW_ARIA_ATTR,Me=!1!==t.ALLOW_DATA_ATTR,Ie=t.ALLOW_UNKNOWN_PROTOCOLS||!1,Ue=!1!==t.ALLOW_SELF_CLOSE_IN_ATTR,Fe=t.SAFE_FOR_TEMPLATES||!1,ze=t.WHOLE_DOCUMENT||!1,Pe=t.RETURN_DOM||!1,Be=t.RETURN_DOM_FRAGMENT||!1,Ge=t.RETURN_TRUSTED_TYPE||!1,je=t.FORCE_BODY||!1,We=!1!==t.SANITIZE_DOM,qe=t.SANITIZE_NAMED_PROPS||!1,$e=!1!==t.KEEP_CONTENT,Ke=t.IN_PLACE||!1,Se=t.ALLOWED_URI_REGEXP||Se,at=t.NAMESPACE||ot,De=t.CUSTOM_ELEMENT_HANDLING||{},t.CUSTOM_ELEMENT_HANDLING&&pt(t.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(De.tagNameCheck=t.CUSTOM_ELEMENT_HANDLING.tagNameCheck),t.CUSTOM_ELEMENT_HANDLING&&pt(t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(De.attributeNameCheck=t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),t.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(De.allowCustomizedBuiltInElements=t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Fe&&(Me=!1),Be&&(Pe=!0),Ve&&(_e=C({},a(P)),ke=[],!0===Ve.html&&(C(_e,I),C(ke,B)),!0===Ve.svg&&(C(_e,U),C(ke,G),C(ke,q)),!0===Ve.svgFilters&&(C(_e,F),C(ke,G),C(ke,q)),!0===Ve.mathMl&&(C(_e,H),C(ke,W),C(ke,q))),t.ADD_TAGS&&(_e===xe&&(_e=L(_e)),C(_e,t.ADD_TAGS,ge)),t.ADD_ATTR&&(ke===Oe&&(ke=L(ke)),C(ke,t.ADD_ATTR,ge)),t.ADD_URI_SAFE_ATTR&&C(et,t.ADD_URI_SAFE_ATTR,ge),t.FORBID_CONTENTS&&(Xe===Ze&&(Xe=L(Xe)),C(Xe,t.FORBID_CONTENTS,ge)),$e&&(_e["#text"]=!0),ze&&C(_e,["html","head","body"]),_e.table&&(C(_e,["tbody"]),delete Re.tbody),p&&p(t),ft=t)},ht=C({},["mi","mo","mn","ms","mtext"]),yt=C({},["foreignobject","desc","title","annotation-xml"]),gt=C({},["title","style","font","a","script"]),bt=C({},U);C(bt,F),C(bt,z);var vt=C({},H);C(vt,j);var Tt=function(e){var t=ae(e);t&&t.tagName||(t={namespaceURI:at,tagName:"template"});var n=E(e.tagName),r=E(t.tagName);return!!lt[e.namespaceURI]&&(e.namespaceURI===rt?t.namespaceURI===ot?"svg"===n:t.namespaceURI===nt?"svg"===n&&("annotation-xml"===r||ht[r]):Boolean(bt[n]):e.namespaceURI===nt?t.namespaceURI===ot?"math"===n:t.namespaceURI===rt?"math"===n&&yt[r]:Boolean(vt[n]):e.namespaceURI===ot?!(t.namespaceURI===rt&&!yt[r])&&(!(t.namespaceURI===nt&&!ht[r])&&(!vt[n]&&(gt[n]||!bt[n]))):!("application/xhtml+xml"!==ye||!lt[e.namespaceURI]))},Nt=function(e){A(r.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){e.remove()}},At=function(e,t){try{A(r.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){A(r.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e&&!ke[e])if(Pe||Be)try{Nt(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},Et=function(e){var t,n;if(je)e="<remove></remove>"+e;else{var r=S(e,/^[\r\n\t ]+/);n=r&&r[0]}"application/xhtml+xml"===ye&&at===ot&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");var o=le?le.createHTML(e):e;if(at===ot)try{t=(new g).parseFromString(o,ye)}catch(e){}if(!t||!t.documentElement){t=se.createDocument(at,"template",null);try{t.documentElement.innerHTML=it?ce:o}catch(e){}}var a=t.body||t.documentElement;return e&&n&&a.insertBefore(i.createTextNode(n),a.childNodes[0]||null),at===ot?pe.call(t,ze?"html":"body")[0]:ze?t.documentElement:a},wt=function(e){return fe.call(e.ownerDocument||e,e,m.SHOW_ELEMENT|m.SHOW_COMMENT|m.SHOW_TEXT,null,!1)},St=function(e){return e instanceof y&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof h)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},_t=function(t){return"object"===e(s)?t instanceof s:t&&"object"===e(t)&&"number"==typeof t.nodeType&&"string"==typeof t.nodeName},xt=function(e,t,n){he[e]&&T(he[e],(function(e){e.call(r,t,n,ft)}))},kt=function(e){var t;if(xt("beforeSanitizeElements",e,null),St(e))return Nt(e),!0;var n=ge(e.nodeName);if(xt("uponSanitizeElement",e,{tagName:n,allowedTags:_e}),e.hasChildNodes()&&!_t(e.firstElementChild)&&(!_t(e.content)||!_t(e.content.firstElementChild))&&O(/<[/\w]/g,e.innerHTML)&&O(/<[/\w]/g,e.textContent))return Nt(e),!0;if(!_e[n]||Re[n]){if(!Re[n]&&Dt(n)){if(De.tagNameCheck instanceof RegExp&&O(De.tagNameCheck,n))return!1;if(De.tagNameCheck instanceof Function&&De.tagNameCheck(n))return!1}if($e&&!Xe[n]){var o=ae(e)||e.parentNode,a=oe(e)||e.childNodes;if(a&&o)for(var i=a.length-1;i>=0;--i)o.insertBefore(R(a[i],!0),re(e))}return Nt(e),!0}return e instanceof f&&!Tt(e)?(Nt(e),!0):"noscript"!==n&&"noembed"!==n||!O(/<\/no(script|embed)/i,e.innerHTML)?(Fe&&3===e.nodeType&&(t=e.textContent,t=_(t,be," "),t=_(t,ve," "),t=_(t,Te," "),e.textContent!==t&&(A(r.removed,{element:e.cloneNode()}),e.textContent=t)),xt("afterSanitizeElements",e,null),!1):(Nt(e),!0)},Ot=function(e,t,n){if(We&&("id"===t||"name"===t)&&(n in i||n in mt))return!1;if(Me&&!Ce[t]&&O(Ne,t));else if(Le&&O(Ae,t));else if(!ke[t]||Ce[t]){if(!(Dt(e)&&(De.tagNameCheck instanceof RegExp&&O(De.tagNameCheck,e)||De.tagNameCheck instanceof Function&&De.tagNameCheck(e))&&(De.attributeNameCheck instanceof RegExp&&O(De.attributeNameCheck,t)||De.attributeNameCheck instanceof Function&&De.attributeNameCheck(t))||"is"===t&&De.allowCustomizedBuiltInElements&&(De.tagNameCheck instanceof RegExp&&O(De.tagNameCheck,n)||De.tagNameCheck instanceof Function&&De.tagNameCheck(n))))return!1}else if(et[t]);else if(O(Se,_(n,we,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==x(n,"data:")||!Je[e]){if(Ie&&!O(Ee,_(n,we,"")));else if(n)return!1}else;return!0},Dt=function(e){return e.indexOf("-")>0},Rt=function(t){var n,o,a,i;xt("beforeSanitizeAttributes",t,null);var l=t.attributes;if(l){var c={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ke};for(i=l.length;i--;){var u=n=l[i],s=u.name,f=u.namespaceURI;if(o="value"===s?n.value:k(n.value),a=ge(s),c.attrName=a,c.attrValue=o,c.keepAttr=!0,c.forceKeepAttr=void 0,xt("uponSanitizeAttribute",t,c),o=c.attrValue,!c.forceKeepAttr&&(At(s,t),c.keepAttr))if(Ue||!O(/\/>/i,o)){Fe&&(o=_(o,be," "),o=_(o,ve," "),o=_(o,Te," "));var m=ge(t.nodeName);if(Ot(m,a,o)){if(!qe||"id"!==a&&"name"!==a||(At(s,t),o=Ye+o),le&&"object"===e(b)&&"function"==typeof b.getAttributeType)if(f);else switch(b.getAttributeType(m,a)){case"TrustedHTML":o=le.createHTML(o);break;case"TrustedScriptURL":o=le.createScriptURL(o)}try{f?t.setAttributeNS(f,s,o):t.setAttribute(s,o),N(r.removed)}catch(e){}}}else At(s,t)}xt("afterSanitizeAttributes",t,null)}},Ct=function e(t){var n,r=wt(t);for(xt("beforeSanitizeShadowDOM",t,null);n=r.nextNode();)xt("uponSanitizeShadowNode",n,null),kt(n)||(n.content instanceof l&&e(n.content),Rt(n));xt("afterSanitizeShadowDOM",t,null)};return r.sanitize=function(e){var t,n,a,i,c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if((it=!e)&&(e="\x3c!--\x3e"),"string"!=typeof e&&!_t(e)){if("function"!=typeof e.toString)throw D("toString is not a function");if("string"!=typeof(e=e.toString()))throw D("dirty is not a string, aborting")}if(!r.isSupported)return e;if(He||dt(c),r.removed=[],"string"==typeof e&&(Ke=!1),Ke){if(e.nodeName){var u=ge(e.nodeName);if(!_e[u]||Re[u])throw D("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof s)1===(n=(t=Et("\x3c!----\x3e")).ownerDocument.importNode(e,!0)).nodeType&&"BODY"===n.nodeName||"HTML"===n.nodeName?t=n:t.appendChild(n);else{if(!Pe&&!Fe&&!ze&&-1===e.indexOf("<"))return le&&Ge?le.createHTML(e):e;if(!(t=Et(e)))return Pe?null:Ge?ce:""}t&&je&&Nt(t.firstChild);for(var f=wt(Ke?e:t);a=f.nextNode();)kt(a)||(a.content instanceof l&&Ct(a.content),Rt(a));if(Ke)return e;if(Pe){if(Be)for(i=me.call(t.ownerDocument);t.firstChild;)i.appendChild(t.firstChild);else i=t;return(ke.shadowroot||ke.shadowrootmod)&&(i=de.call(o,i,!0)),i}var m=ze?t.outerHTML:t.innerHTML;return ze&&_e["!doctype"]&&t.ownerDocument&&t.ownerDocument.doctype&&t.ownerDocument.doctype.name&&O(ee,t.ownerDocument.doctype.name)&&(m="<!DOCTYPE "+t.ownerDocument.doctype.name+">\n"+m),Fe&&(m=_(m,be," "),m=_(m,ve," "),m=_(m,Te," ")),le&&Ge?le.createHTML(m):m},r.setConfig=function(e){dt(e),He=!0},r.clearConfig=function(){ft=null,He=!1},r.isValidAttribute=function(e,t,n){ft||dt({});var r=ge(e),o=ge(t);return Ot(r,o,n)},r.addHook=function(e,t){"function"==typeof t&&(he[e]=he[e]||[],A(he[e],t))},r.removeHook=function(e){if(he[e])return N(he[e])},r.removeHooks=function(e){he[e]&&(he[e]=[])},r.removeAllHooks=function(){he={}},r}();return re}));
|
|
3
|
+
//# sourceMappingURL=purify.min.js.map
|