// ==UserScript== // @name 【SillyTavern / ST酒馆】html代码注入器-改 // @name:zh 【ST酒馆】html代码注入器-改 // @name:zh-CN 【ST酒馆】html代码注入器-改 // @name:zh-TW 【ST酒館】html程式碼注入器-改 // @name:ja 【SillyTavern】 HTMLコードインジェクター-改 // @name:ko 【SillyTavern】 HTML코드 삽입기-수정 // @name:en 【SillyTavern】 HTML Code Injector - Modified // @name:fr 【SillyTavern】 Injecteur de code HTML - Modifié // @name:de 【SillyTavern】 HTML-Code-Injektor - Modifiziert // @namespace https://greasyfork.org/users/590339-miaotouy // @version 1.1.6.1 // @description 可以让ST酒馆独立运行html代码 (Inject HTML code into SillyTavern pages.) // @description:zh 可以让ST酒馆独立运行html代码 // @description:zh-CN 可以让ST酒馆独立运行html代码 // @description:zh-TW 讓SillyTavern獨立運行html程式碼 // @description:ja SillyTavernでhtmlコードを独立して実行できるようにします // @description:ko SillyTavern에서 HTML 코드를 독립적으로 실행할 수 있습니다. // @description:en Inject HTML code into SillyTavern pages. // @description:fr Permet d'exécuter du code HTML de manière indépendante dans SillyTavern. // @description:de Ermöglicht die unabhängige Ausführung von HTML-Code in SillyTavern. // @author Qianzhuo // @match *://localhost:8000/* // @match *://127.0.0.1:8000/* // @match *://192.168.*.*:*/* // @match *://*/*:8000/* // @match *://frp-kit.top:*/* // @include /^https?:\/\/.*:8000\// // @grant GM_setValue // @grant GM_getValue // @require https://code.jquery.com/jquery-3.6.0.min.js // @license CC BY-NC 4.0 // @downloadURL none // ==/UserScript== /* 原作者:Qianzhuo 修改者:miaotouy 【SillyTavern / ST酒馆】html代码注入器 © 2024 by Qianzhuo is licensed under CC BY-NC 4.0. To view a copy of this license, visit https://creativecommons.org/licenses/by-nc/4.0/ */ (function () { 'use strict'; // ---------------------------------------- 全局变量 ---------------------------------------- let isInjectionEnabled, displayMode, lastMesTextContent, activationMode, customStartFloor, customEndFloor, savedPosition, isEdgeControlsCollapsed; let edgeControls, settingsPanel; // ---------------------------------------- 初始化函数 ---------------------------------------- function initScript() { if (!document.title.includes('SillyTavern')) { console.log('页面标题不是 "SillyTavern",脚本未运行。'); return; } initVariables(); createUI(); addEventListeners(); addDragFunctionality(); startObservers(); console.log('HTML注入器脚本已初始化'); } function initVariables() { isInjectionEnabled = false; displayMode = parseInt(GM_getValue('displayMode', 1)); lastMesTextContent = ''; activationMode = GM_getValue('activationMode', 'all'); customStartFloor = GM_getValue('customStartFloor', 1); customEndFloor = GM_getValue('customEndFloor', -1); savedPosition = GM_getValue('edgeControlsPosition', 'top-right'); isEdgeControlsCollapsed = GM_getValue('isEdgeControlsCollapsed', true); } // ---------------------------------------- UI 创建函数 ---------------------------------------- function createUI() { createSettingsPanel(); createEdgeControls(); addStyles(); } function createSettingsPanel() { settingsPanel = document.createElement('div'); settingsPanel.id = 'html-injector-settings'; settingsPanel.classList.add('drawer'); settingsPanel.style.display = 'none'; settingsPanel.innerHTML = `