性能优化 · G网格 T性能 H隐藏 L连线 C全链 F搜索 P提示词 X专注 R直角 ?帮助 · AI增强 · 标签 · 提示词模板 · 模板变量 · 主题(画布配色DIY)
// ==UserScript==
// @name LibTV Canvas Boost
// @version 1.9.7
// @icon https://raw.githubusercontent.com/lonely814/Messy/refs/heads/main/libtv-boost/libtv-boost-icon.png
// @license MIT
// @author oocc00
// @description 性能优化 · G网格 T性能 H隐藏 L连线 C全链 F搜索 P提示词 X专注 R直角 ?帮助 · AI增强 · 标签 · 提示词模板 · 模板变量 · 主题(画布配色DIY)
// @match *://*.iblib.tv/canvas*
// @match *://*.liblib.tv/canvas*
// @match https://www.liblib.tv/*
// @run-at document-idle
// @grant GM_registerMenuCommand
// @grant unsafeWindow
// @namespace https://github.com/hero8152/Infinite-Canvas
// ==/UserScript==
(function(){
'use strict';
/* =========================================================
* 1. CSS 注入
* ========================================================= */
var style = document.createElement('style');
style.id = 'libtv-boost-css';
style.textContent = [
/* 主题变量 */
':root {',
' --accent: #6366f1;',
' --accent-light: #818cf8;',
' --accent-dark: #4f46e5;',
' --accent-rgb: 99,102,241;',
' --accent-light-rgb: 129,140,248;',
' --canvas-bg: #0f0f0f;',
' --node-bg: #1a1a2e;',
' --border-color: rgba(255,255,255,0.12);',
' --edge-color: rgba(255,255,255,0.08);',
'}',
/* 节点过渡 */
'.react-flow__node {',
' transition: box-shadow 0.25s ease, opacity 0.2s ease !important;',
' border-radius: 12px;',
'}',
/* 选中节点 — 发光轮廓 + 底部光晕 */
'.react-flow__node.selected {',
' outline: none !important;',
' box-shadow:',
' 0 0 0 2px rgba(255,255,255,0.7),',
' 0 0 0 5px var(--accent, #6366f1),',
' 0 0 16px var(--accent, #6366f1),',
' 0 0 48px rgba(var(--accent-rgb),0.4) !important;',
'}',
'.react-flow__node.selected::after {',
' content: ""; position: absolute;',
' left: 10%; right: 10%; bottom: -4px; height: 3px;',
' border-radius: 2px; opacity: 1;',
' background: linear-gradient(90deg,transparent,var(--accent,#818cf8),transparent);',
' box-shadow: 0 0 10px var(--accent,#818cf8),',
' 0 0 20px rgba(var(--accent-light-rgb),0.4);',
'}',
/* 网格背景隐藏 */
'.react-flow__background.perf-no-grid { display: none !important; }',
/* 隐藏连线 */
'.react-flow__edges.perf-hide-edges { display: none !important; }',
/* 连线美化 */
'.react-flow__edge-path {',
' stroke: var(--faint, rgba(255,255,255,0.15)) !important;',
' stroke-width: 1.8 !important;',
' transition: stroke 0.15s, stroke-width 0.15s !important;',
'}',
'.react-flow__edge.libtv-edge-active .react-flow__edge-path {',
' stroke: var(--strong, #818cf8) !important;',
' stroke-width: 2.5 !important;',
'}',
'body.libtv-chain .react-flow__edge.libtv-chain-edge .react-flow__edge-path {',
' stroke: var(--accent, #818cf8) !important;',
' stroke-width: 2.5 !important;',
' filter: drop-shadow(0 0 6px rgba(var(--accent-light-rgb),0.6));',
'}',
'body.perf-mode .react-flow__edge-path {',
' stroke-width: 0.8 !important;',
' transition: none !important;',
' filter: none !important;',
'}',
'body.libtv-step-edges .react-flow__edge-path {',
' transition: none !important;',
'}',
/* 隐藏图片 */
'body.perf-hide-imgs .react-flow__node img {',
' display: none !important;',
'}',
/* 性能模式 */
'body.perf-mode .react-flow__node {',
' box-shadow: none !important; border-radius: 0 !important;',
' backdrop-filter: none !important;',
' border-color: rgba(255,255,255,0.06) !important;',
' opacity: 0.85;',
' transition: none !important;',
' animation: none !important;',
'}',
'body.perf-mode .react-flow__node [class*="rounded"] { border-radius: 0 !important; }',
'body.perf-mode .react-flow__node:hover {',
' opacity: 1;',
'}',
'body.perf-mode .react-flow {',
' backdrop-filter: none !important;',
'}',
'body.perf-mode * {',
' animation-duration: 0s !important;',
' animation-delay: 0s !important;',
' transition-duration: 0s !important;',
' backdrop-filter: none !important;',
'}',
'body.perf-mode #libtv-glow { display: none !important; }',
/* FPS 面板 — 紧凑小药丸 */
'#libtv-fps {',
' position: fixed; right: 14px; bottom: 14px; z-index: 99999;',
' padding: 5px 12px; border-radius: 10px;',
' background: rgba(10,10,15,0.55); color: rgba(255,255,255,0.5);',
' font: 11px/1.5 -apple-system, "SF Mono", monospace;',
' user-select: none;',
' backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);',
' border: 1px solid rgba(255,255,255,0.06);',
' white-space: nowrap;',
' display: inline-flex; align-items: center; gap: 5px;',
' cursor: grab;',
' transition: all 0.2s ease;',
' box-shadow: 0 2px 12px rgba(0,0,0,0.2);',
'}',
'#libtv-fps:hover {',
' background: rgba(10,10,15,0.75);',
' border-color: rgba(129,140,248,0.15);',
' padding: 5px 14px;',
' box-shadow: 0 4px 16px rgba(0,0,0,0.3);',
'}',
'#libtv-fps:active { cursor: grabbing; }',
'#libtv-fps .fps-val { color: #4ade80; font-weight: 600; }',
'#libtv-fps .fps-flag { color: #fbbf24; }',
'#libtv-fps .fps-sep { color: rgba(255,255,255,0.08); }',
'#libtv-fps .fps-zoom { color: #818cf8; }',
'#libtv-fps .fps-cnt { color: rgba(255,255,255,0.35); }',
/* 快捷键提示 — 右下角卡片,悬停 FPS 面板出现 */
'#libtv-help {',
' position:fixed; right:14px; bottom:118px; z-index:99997;',
' max-width:260px; padding:10px 12px;',
' background:rgba(18,18,28,0.92);',
' border:1px solid rgba(129,140,248,0.25); border-radius:10px;',
' color:rgba(255,255,255,0.6);',
' font:11px/1.8 -apple-system,"SF Mono",monospace;',
' pointer-events:none; user-select:none;',
' white-space:pre-line; text-align:left;',
' box-shadow:0 8px 24px rgba(0,0,0,0.4);',
' transition: opacity 0.3s ease, transform 0.3s ease;',
'}',
'#libtv-help.libtv-hide {',
' opacity:0;',
' transform:translateY(8px);',
' pointer-events:none;',
'}',
/* 链高亮模式 */
'body.libtv-chain .react-flow__node { opacity: 0.08 !important; }',
'body.libtv-chain .react-flow__node.selected,',
'body.libtv-chain .react-flow__node.libtv-chain-node',
' { opacity: 1 !important; }',
'body.libtv-chain .react-flow__edge { opacity: 0.03 !important; }',
'body.libtv-chain .react-flow__edge.libtv-chain-edge',
' { opacity: 0.6 !important; }',
/* 专注模式 — 隐藏工具栏/侧栏/顶栏/头像等 */
'body.libtv-focus [data-toolbar-collapsed],' +
'body.libtv-focus [data-sidebar-container],' +
'body.libtv-focus header,' +
'body.libtv-focus nav,' +
'body.libtv-focus aside {',
' display: none !important;',
'}',
/* 专注模式时放大画布区域 */
'body.libtv-focus .react-flow {',
' width: 100vw !important;',
' height: 100vh !important;',
' max-width: none !important;',
'}',
/* 搜索框玻璃效果 */
'#libtv-search {',
' backdrop-filter: blur(20px) !important;',
' -webkit-backdrop-filter: blur(20px) !important;',
' border: 1px solid rgba(255,255,255,0.08) !important;',
'}',
/* 提示词面板 — 霓虹玻璃风格 */
'#libtv-prompt {',
' position:fixed; z-index:99999;',
' width:440px; max-width:88vw; max-height:68vh;',
' background:rgba(12,12,20,0.88);',
' backdrop-filter:blur(32px) saturate(1.4); -webkit-backdrop-filter:blur(32px) saturate(1.4);',
' border:1px solid rgba(129,140,248,0.25);',
' border-radius:16px; padding:0; overflow:hidden;',
' display:flex; flex-direction:column;',
' font:13px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif; color:#d4d4d8;',
' box-shadow:',
' 0 0 1px rgba(129,140,248,0.6),',
' 0 0 8px rgba(129,140,248,0.15),',
' 0 0 24px rgba(129,140,248,0.08),',
' 0 16px 48px rgba(0,0,0,0.5);',
' animation: libtv-panel-glow 4s ease-in-out infinite alternate;',
'}',
'@keyframes libtv-panel-glow {',
' 0% { border-color:rgba(129,140,248,0.2); box-shadow:0 0 1px rgba(129,140,248,0.5),0 0 8px rgba(129,140,248,0.1),0 0 20px rgba(129,140,248,0.05),0 16px 48px rgba(0,0,0,0.5); }',
' 100% { border-color:rgba(129,140,248,0.4); box-shadow:0 0 1px rgba(129,140,248,0.8),0 0 12px rgba(129,140,248,0.25),0 0 32px rgba(129,140,248,0.12),0 16px 48px rgba(0,0,0,0.5); }',
'}',
'#libtv-prompt::before {',
' content:""; position:absolute; top:-1px; left:20%; right:20%; height:1px;',
' background:linear-gradient(90deg,transparent,rgba(129,140,248,0.6),transparent);',
' pointer-events:none;',
'}',
'#libtv-prompt .ltp-head {',
' display:flex; align-items:center; justify-content:space-between;',
' padding:14px 18px 10px; border-bottom:1px solid rgba(129,140,248,0.12);',
' flex-shrink:0;',
'}',
'#libtv-prompt .ltp-head h3 { margin:0; font-size:13px; color:#e0e7ff; font-weight:600; letter-spacing:0.02em; text-shadow:0 0 12px rgba(129,140,248,0.4); }',
'#libtv-prompt .ltp-close { cursor:pointer; font-size:16px; color:rgba(255,255,255,0.25); transition:all .15s; line-height:1; }',
'#libtv-prompt .ltp-close:hover { color:#818cf8; text-shadow:0 0 8px rgba(129,140,248,0.5); }',
'#libtv-prompt .ltp-tabs { display:flex; gap:0; padding:0 18px; border-bottom:1px solid rgba(129,140,248,0.12); flex-shrink:0; }',
'#libtv-prompt .ltp-tab { padding:10px 16px; cursor:pointer; color:rgba(255,255,255,0.3); font-size:12px; border-bottom:1.5px solid transparent; transition:all .15s; letter-spacing:0.02em; user-select:none; }',
'#libtv-prompt .ltp-tab:hover { color:rgba(224,231,255,0.7); }',
'#libtv-prompt .ltp-tab.active { color:#818cf8; border-bottom-color:#818cf8; text-shadow:0 0 8px rgba(129,140,248,0.5); }',
'#libtv-prompt .ltp-body { padding:14px 18px; overflow-y:auto; flex:1; max-height:42vh; position:relative; }',
'#libtv-prompt .ltp-body textarea { width:100%; box-sizing:border-box; min-height:80px; padding:10px 12px; border-radius:10px; border:1px solid rgba(129,140,248,0.2); background:rgba(129,140,248,0.04); color:#e0e7ff; font:12px/1.5 ui-monospace,SFMono-Regular,monospace; outline:none; resize:vertical; transition:border-color .15s, box-shadow .15s; }',
'#libtv-prompt .ltp-body textarea:focus { border-color:#818cf8; box-shadow:0 0 12px rgba(129,140,248,0.2); }',
'#libtv-prompt .ltp-body input[type="text"],#libtv-prompt .ltp-body input[type="password"] { width:100%; box-sizing:border-box; padding:8px 12px; border-radius:8px; border:1px solid rgba(129,140,248,0.2); background:rgba(129,140,248,0.04); color:#e0e7ff; font:12px/1.5 ui-monospace,SFMono-Regular,monospace; outline:none; transition:border-color .15s, box-shadow .15s; }',
'#libtv-prompt .ltp-body input:focus { border-color:#818cf8; box-shadow:0 0 12px rgba(129,140,248,0.2); }',
'#libtv-prompt .ltp-btn { display:inline-flex; align-items:center; gap:5px; padding:6px 14px; border-radius:8px; border:none; cursor:pointer; font:12px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif; transition:all .15s; }',
'#libtv-prompt .ltp-btn-primary { background:linear-gradient(135deg,#6366f1,#818cf8); color:#fff; box-shadow:0 0 12px rgba(129,140,248,0.3); }',
'#libtv-prompt .ltp-btn-primary:hover { background:linear-gradient(135deg,#818cf8,#a5b4fc); box-shadow:0 0 16px rgba(129,140,248,0.4); }',
'#libtv-prompt .ltp-btn-sm { padding:4px 12px; font-size:11px; border-radius:6px; }',
'#libtv-prompt .ltp-btn-danger { background:rgba(239,68,68,0.12); color:#f87171; }',
'#libtv-prompt .ltp-btn-danger:hover { background:rgba(239,68,68,0.22); }',
'#libtv-prompt .ltp-btn-ghost { background:rgba(255,255,255,0.04); color:#aaa; }',
'#libtv-prompt .ltp-btn-ghost:hover { background:rgba(255,255,255,0.08); color:#fff; }',
'#libtv-prompt .ltp-cat { display:flex; gap:6px; flex-wrap:wrap; margin-bottom:12px; }',
'#libtv-prompt .ltp-cat-btn { padding:3px 12px; border-radius:14px; border:1px solid rgba(129,140,248,0.2); cursor:pointer; font:11px/1.6 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif; color:rgba(255,255,255,0.4); background:transparent; transition:all .15s; }',
'#libtv-prompt .ltp-cat-btn:hover { border-color:rgba(129,140,248,0.4); color:#818cf8; }',
'#libtv-prompt .ltp-cat-btn.active { background:rgba(129,140,248,0.2); border-color:#818cf8; color:#a5b4fc; box-shadow:0 0 8px rgba(129,140,248,0.2); }',
'#libtv-prompt .ltp-item { display:flex; align-items:center; justify-content:space-between; padding:7px 10px; border-radius:8px; cursor:pointer; transition:background .12s; position:relative; overflow:hidden; }',
'#libtv-prompt .ltp-item::before { content:""; position:absolute; inset:0; border-radius:8px; opacity:0; transition:opacity .25s; background:radial-gradient(300px circle at var(--mx,50%) var(--my,50%),rgba(129,140,248,0.18),transparent 55%); pointer-events:none; }',
'#libtv-prompt .ltp-item:hover::before { opacity:1; }',
'#libtv-prompt .ltp-item:hover { background:rgba(255,255,255,0.04); }',
'#libtv-prompt .ltp-item .ltp-name { font-size:12px; color:#c7d2fe; flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }',
'#libtv-prompt .ltp-item .ltp-actions { display:flex; gap:4px; opacity:0; transition:opacity .15s; }',
'#libtv-prompt .ltp-item:hover .ltp-actions { opacity:1; }',
'#libtv-prompt .ltp-item .ltp-preview { font-size:11px; color:rgba(255,255,255,0.25); margin-top:2px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }',
'#libtv-prompt .ltp-status { font-size:11px; color:rgba(255,255,255,0.3); margin-top:6px; }',
'#libtv-prompt .ltp-empty { text-align:center; padding:30px 0; color:rgba(255,255,255,0.2); font-size:13px; }',
/* 模板变量填充弹窗 */
'#libtv-prompt .ltp-var-overlay { position:absolute; inset:0; z-index:10; background:rgba(8,8,16,0.94); backdrop-filter:blur(16px); -webkit-backdrop-filter:blur(16px); display:flex; flex-direction:column; padding:16px 18px; border-radius:12px; border:1px solid rgba(129,140,248,0.15); }',
'#libtv-prompt .ltp-var-title { font-size:13px; color:#fff; font-weight:600; margin-bottom:10px; }',
'#libtv-prompt .ltp-var-sub { font-size:11px; color:rgba(255,255,255,0.25); margin-bottom:12px; padding-bottom:10px; border-bottom:1px solid rgba(255,255,255,0.06); }',
'#libtv-prompt .ltp-var-row { margin-bottom:8px; display:flex; align-items:center; gap:8px; }',
'#libtv-prompt .ltp-var-row label { font-size:11px; color:rgba(255,255,255,0.4); min-width:64px; flex-shrink:0; text-align:right; }',
'#libtv-prompt .ltp-var-row input { flex:1; padding:6px 10px; border-radius:6px; border:1px solid rgba(129,140,248,0.2); background:rgba(129,140,248,0.04); color:#e0e7ff; font:12px/1.4 ui-monospace,SFMono-Regular,monospace; outline:none; transition:border-color .15s, box-shadow .15s; }',
'#libtv-prompt .ltp-var-row input:focus { border-color:#818cf8; box-shadow:0 0 8px rgba(129,140,248,0.2); }',
'#libtv-prompt .ltp-var-preview { margin-top:8px; padding:8px 10px; border-radius:6px; background:rgba(255,255,255,0.03); font-size:11px; color:rgba(255,255,255,0.3); white-space:pre-wrap; word-break:break-all; max-height:80px; overflow-y:auto; flex-shrink:0; }',
'#libtv-prompt .ltp-var-actions { display:flex; gap:6px; margin-top:auto; padding-top:10px; justify-content:flex-end; border-top:1px solid rgba(255,255,255,0.06); }',
/* 调色板 */
'.ltp-pal-section { margin-bottom:14px; }',
'.ltp-pal-section-title { font-size:11px; color:rgba(255,255,255,0.35); letter-spacing:0.05em; margin-bottom:8px; cursor:pointer; display:flex; align-items:center; gap:6px; user-select:none; }',
'.ltp-pal-section-title::before { content:"▸"; font-size:9px; transition:transform .15s; }',
'.ltp-pal-section-title.open::before { transform:rotate(90deg); }',
'.ltp-pal-section-body { display:grid; grid-template-columns:repeat(auto-fill,minmax(32px,1fr)); gap:6px; }',
'.ltp-pal-section-body.collapsed { display:none; }',
'.ltp-pal-swatch { width:32px; height:32px; border-radius:6px; cursor:pointer; border:2px solid transparent; transition:all .15s; position:relative; }',
'.ltp-pal-swatch:hover { transform:scale(1.15); border-color:rgba(255,255,255,0.4); z-index:1; }',
'.ltp-pal-swatch.copied { border-color:#22c55e !important; }',
'.ltp-pal-swatch .ltp-pal-tip { position:absolute; bottom:calc(100% + 4px); left:50%; transform:translateX(-50%); background:rgba(0,0,0,0.85); color:#fff; font-size:10px; padding:2px 6px; border-radius:4px; white-space:nowrap; opacity:0; pointer-events:none; transition:opacity .15s; }',
'.ltp-pal-swatch:hover .ltp-pal-tip { opacity:1; }',
'.ltp-pal-picker { display:flex; align-items:center; gap:12px; margin-bottom:16px; padding:12px; border-radius:10px; background:rgba(255,255,255,0.03); border:1px solid rgba(129,140,248,0.12); }',
'.ltp-pal-picker input[type="color"] { width:48px; height:48px; border:none; border-radius:8px; cursor:pointer; background:none; padding:0; }',
'.ltp-pal-picker input[type="color"]::-webkit-color-swatch-wrapper { padding:0; }',
'.ltp-pal-picker input[type="color"]::-webkit-color-swatch { border-radius:8px; border:2px solid rgba(255,255,255,0.1); }',
'.ltp-pal-info { flex:1; }',
'.ltp-pal-hex { font-size:16px; font-weight:600; color:#e0e7ff; cursor:pointer; letter-spacing:0.03em; }',
'.ltp-pal-hex:hover { color:#a5b4fc; }',
'.ltp-pal-rgb, .ltp-pal-hsl { font-size:11px; color:rgba(255,255,255,0.35); margin-top:2px; cursor:pointer; }',
'.ltp-pal-rgb:hover, .ltp-pal-hsl:hover { color:rgba(255,255,255,0.6); }',
'.ltp-pal-ai { display:flex; gap:6px; align-items:center; margin-top:10px; padding:8px 10px; border-radius:8px; background:rgba(129,140,248,0.08); border:1px solid rgba(129,140,248,0.15); }',
'.ltp-pal-ai-desc { flex:1; font-size:11px; color:rgba(255,255,255,0.5); line-height:1.5; }',
'.ltp-pal-recent { display:flex; gap:4px; flex-wrap:wrap; margin-top:12px; }',
'.ltp-pal-recent-title { width:100%; font-size:11px; color:rgba(255,255,255,0.3); margin-bottom:4px; }',
'.ltp-pal-toast { position:fixed; bottom:30px; left:50%; transform:translateX(-50%); background:rgba(129,140,248,0.9); color:#fff; font-size:12px; padding:6px 16px; border-radius:8px; z-index:999999; pointer-events:none; opacity:0; transition:opacity .2s; }',
'.ltp-pal-toast.show { opacity:1; }',
/* 提示词悬浮按钮 */
'#libtv-pbtn {',
' transition: transform 0.2s ease !important;',
' background: #000 !important;',
' border: none !important;',
' box-shadow:',
' inset 0 0 8px #fff,',
' inset 3px 0 10px #f0f,',
' inset -3px 0 10px #0ff,',
' inset 3px 0 30px #f0f,',
' inset -3px 0 30px #0ff,',
' 0 0 8px #fff,',
' -2px 0 10px #f0f,',
' 2px 0 10px #0ff !important;',
' animation: libtv-pbtn-glow 3s ease-in-out infinite alternate !important;',
'}',
'@keyframes libtv-pbtn-glow {',
' 0% { box-shadow: inset 0 0 6px #fff, inset 2px 0 8px #f0f, inset -2px 0 8px #0ff, inset 2px 0 20px #f0f, inset -2px 0 20px #0ff, 0 0 6px #fff, -1px 0 8px #f0f, 1px 0 8px #0ff !important; }',
' 100% { box-shadow: inset 0 0 12px #fff, inset 4px 0 14px #f0f, inset -4px 0 14px #0ff, inset 4px 0 40px #f0f, inset -4px 0 40px #0ff, 0 0 12px #fff, -3px 0 14px #f0f, 3px 0 14px #0ff !important; }',
'}',
'.lt-tag-icon {',
' background:rgba(18,18,28,0.6) !important;',
' border:1px solid rgba(129,140,248,0.4);',
' color:#c7d2fe;',
' opacity:0.8;',
' box-shadow:0 1px 6px rgba(129,140,248,0.25);',
' transition:opacity 0.15s,box-shadow 0.15s,transform 0.15s,background 0.15s;',
'}',
'.lt-tag-icon:hover {',
' opacity:1 !important;',
' color:#fff;',
' background:rgba(129,140,248,0.18) !important;',
' border-color:rgba(129,140,248,0.7);',
' box-shadow:0 2px 10px rgba(129,140,248,0.45);',
' transform:scale(1.06);',
'}',
'#libtv-pbtn:hover {',
' transform: scale(1.08) !important;',
'}',
'#libtv-pbtn:active {',
' cursor: grabbing !important;',
' transform: scale(0.94) !important;',
'}',
/* 画布主题覆盖 — 仅覆盖节点/连线的颜色,不动画布背景(保留站点原生网格) */
'.react-flow__node { background: var(--node-bg) !important; border-color: var(--border-color) !important; }',
'.react-flow__edge-path { stroke: var(--edge-color) !important; }',
/* 标签系统 · 四层结构 */
'.lt-tag-menu { position:fixed; z-index:100000; width:520px; max-height:250px; min-width:240px; min-height:160px; background:rgba(15,15,20,0.94); backdrop-filter:blur(24px) saturate(1.3); -webkit-backdrop-filter:blur(24px) saturate(1.3); border:1px solid rgba(129,140,248,0.25); border-radius:12px; overflow:hidden; display:flex; flex-direction:column; box-shadow:0 8px 32px rgba(0,0,0,0.6),0 0 0 1px rgba(129,140,248,0.1),0 0 20px rgba(129,140,248,0.12); resize:none; }',
'.lt-tag-resize { position:absolute; right:0; bottom:0; width:18px; height:18px; cursor:nwse-resize; display:flex; align-items:flex-end; justify-content:flex-end; z-index:5; touch-action:none; }',
'.lt-tag-resize::after { content:""; width:9px; height:9px; margin:0 3px 3px 0; border-right:2px solid rgba(199,210,254,0.45); border-bottom:2px solid rgba(199,210,254,0.45); border-bottom-right-radius:3px; }',
'.lt-tag-resize:hover::after { border-color:#818cf8; }',
'.lt-tag-header { display:flex; align-items:center; gap:6px; padding:9px 10px; border-bottom:1px solid rgba(129,140,248,0.12); flex-shrink:0; }',
'.lt-tag-lib { flex:0 0 auto; max-width:112px; background:rgba(129,140,248,0.1); border:1px solid rgba(129,140,248,0.2); color:#c7d2fe; border-radius:6px; padding:4px 6px; font-size:11px; outline:none; cursor:pointer; }',
'.lt-tag-search { flex:1; min-width:0; background:rgba(255,255,255,0.05); border:1px solid rgba(129,140,248,0.15); color:#e0e7ff; border-radius:6px; padding:5px 8px; font-size:11px; outline:none; transition:border-color .12s; }',
'.lt-tag-search:focus { border-color:#818cf8; }',
'.lt-tag-refresh,.lt-tag-close { flex:0 0 auto; width:24px; height:24px; border:none; border-radius:6px; background:rgba(129,140,248,0.1); color:rgba(255,255,255,0.5); cursor:pointer; font-size:13px; line-height:1; display:flex; align-items:center; justify-content:center; transition:all .12s; }',
'.lt-tag-refresh:hover,.lt-tag-close:hover { background:rgba(129,140,248,0.25); color:#fff; }',
'.lt-tag-tabs { display:flex; align-items:center; gap:2px; padding:6px 8px 0; border-bottom:1px solid rgba(129,140,248,0.1); flex-shrink:0; overflow-x:auto; }',
'.lt-tag-tab { padding:6px 10px 8px; cursor:pointer; font-size:11px; color:rgba(255,255,255,0.4); border-bottom:2px solid transparent; transition:all .15s; user-select:none; white-space:nowrap; }',
'.lt-tag-tab:hover { color:rgba(224,231,255,0.75); }',
'.lt-tag-tab.active { color:#818cf8; border-bottom-color:#818cf8; text-shadow:0 0 8px rgba(129,140,248,0.5); }',
'.lt-tag-add { margin-left:auto; flex:0 0 auto; width:22px; height:22px; border-radius:6px; background:rgba(129,140,248,0.1); color:rgba(255,255,255,0.5); cursor:pointer; font-size:14px; line-height:22px; text-align:center; transition:all .12s; }',
'.lt-tag-add:hover { background:rgba(129,140,248,0.25); color:#fff; }',
'.lt-tag-content { flex:1; overflow-y:auto; padding:8px 10px 12px; }',
'.lt-tag-recent { margin-bottom:8px; }',
'.lt-tag-recent-head,.lt-tag-ins-head { font-size:11px; color:rgba(255,255,255,0.45); margin:2px 2px 6px; display:flex; align-items:center; justify-content:space-between; }',
'.lt-rec-clear,.lt-ins-clear { color:rgba(255,255,255,0.3); cursor:pointer; font-size:10px; padding:1px 6px; border-radius:4px; }',
'.lt-rec-clear:hover,.lt-ins-clear:hover { color:#f87171; background:rgba(239,68,68,0.12); }',
'.lt-tag-group { margin-bottom:8px; border:1px solid rgba(129,140,248,0.1); border-radius:8px; overflow:hidden; background:rgba(129,140,248,0.03); }',
'.lt-tag-group-head { display:flex; align-items:center; justify-content:space-between; padding:7px 10px; cursor:pointer; user-select:none; background:rgba(129,140,248,0.06); }',
'.lt-tag-group-head:hover { background:rgba(129,140,248,0.12); }',
'.lt-tag-group-name { font-size:11px; color:#c7d2fe; font-weight:600; letter-spacing:0.02em; }',
'.lt-tag-group-actions { display:flex; align-items:center; gap:8px; }',
'.lt-tag-add-item { width:18px; height:18px; border-radius:4px; background:rgba(129,140,248,0.15); color:#c7d2fe; cursor:pointer; font-size:13px; line-height:18px; text-align:center; transition:all .12s; }',
'.lt-tag-add-item:hover { background:#818cf8; color:#fff; }',
'.lt-tag-arrow { font-size:10px; color:rgba(255,255,255,0.4); transition:transform .15s; }',
'.lt-tag-arrow.open { transform:rotate(0deg); }',
'.lt-tag-arrow:not(.open) { transform:rotate(-90deg); }',
'.lt-tag-group-head-static { padding:6px 10px; font-size:11px; color:#c7d2fe; font-weight:600; border-bottom:1px solid rgba(129,140,248,0.08); }',
'.lt-tag-grid { display:flex; flex-wrap:wrap; align-content:flex-start; gap:6px; padding:8px; }',
'.lt-tag-item { padding:5px 11px; border-radius:16px; font-size:11px; color:rgba(255,255,255,0.78); background:rgba(129,140,248,0.1); border:1px solid rgba(129,140,248,0.14); cursor:pointer; transition:all .12s; user-select:none; line-height:1.4; }',
'.lt-tag-item:hover { background:rgba(129,140,248,0.28); color:#fff; border-color:rgba(129,140,248,0.4); box-shadow:0 0 10px rgba(129,140,248,0.25); transform:translateY(-1px); }',
'.lt-tag-add-group-wrap { text-align:center; margin-top:6px; }',
'.lt-tag-add-group { display:inline-block; padding:5px 14px; border-radius:8px; background:rgba(129,140,248,0.08); border:1px dashed rgba(129,140,248,0.3); color:rgba(199,210,254,0.7); font-size:11px; cursor:pointer; transition:all .12s; }',
'.lt-tag-add-group:hover { background:rgba(129,140,248,0.2); color:#fff; }',
'.lt-tag-empty,.lt-tag-search-hint { font-size:11px; color:rgba(255,255,255,0.4); padding:10px 4px; text-align:center; }',
/* 管理面板 */
'.lt-mgr-overlay { position:fixed; inset:0; z-index:100001; display:flex; align-items:center; justify-content:center; background:rgba(0,0,0,0.5); backdrop-filter:blur(4px); }',
'.lt-mgr-panel { width:400px; max-width:88vw; max-height:70vh; background:rgba(15,15,20,0.95); backdrop-filter:blur(32px) saturate(1.3); -webkit-backdrop-filter:blur(32px) saturate(1.3); border:1px solid rgba(129,140,248,0.2); border-radius:14px; display:flex; flex-direction:column; overflow:hidden; box-shadow:0 16px 48px rgba(0,0,0,0.6); }',
'.lt-mgr-head { display:flex; align-items:center; justify-content:space-between; padding:14px 16px 10px; border-bottom:1px solid rgba(129,140,248,0.1); font-size:13px; color:#e0e7ff; font-weight:600; flex-shrink:0; }',
'.lt-mgr-body { flex:1; overflow-y:auto; padding:12px 16px; }',
'.lt-mgr-foot { padding:10px 16px 14px; border-top:1px solid rgba(129,140,248,0.08); flex-shrink:0; }',
'.lt-mgr-group { margin-bottom:14px; border:1px solid rgba(129,140,248,0.1); border-radius:8px; padding:10px 12px; background:rgba(129,140,248,0.03); }',
'.lt-mgr-ghead { display:flex; align-items:center; gap:8px; margin-bottom:8px; }',
'.lt-mgr-gname { flex:1; background:rgba(255,255,255,0.04); border:1px solid rgba(129,140,248,0.12); border-radius:5px; padding:4px 8px; font:12px/1.5 -apple-system,sans-serif; color:#d4d4d8; outline:none; transition:border-color .12s; }',
'.lt-mgr-gname:focus { border-color:#818cf8; }',
'.lt-tag-delg { background:none; border:none; color:rgba(239,68,68,0.5); cursor:pointer; font-size:10px; padding:2px 6px; border-radius:4px; transition:all .12s; }',
'.lt-tag-delg:hover { background:rgba(239,68,68,0.15); color:#f87171; }',
'.lt-mgr-item { display:flex; align-items:center; gap:6px; margin:4px 0; }',
'.lt-mgr-itext { flex:1; background:rgba(255,255,255,0.04); border:1px solid rgba(129,140,248,0.1); border-radius:4px; padding:3px 8px; font:11px/1.5 -apple-system,sans-serif; color:#d4d4d8; outline:none; }',
'.lt-mgr-itext:focus { border-color:#818cf8; }',
'.lt-tag-deli { background:none; border:none; color:rgba(239,68,68,0.4); cursor:pointer; font-size:9px; padding:2px 4px; border-radius:3px; }',
'.lt-tag-deli:hover { background:rgba(239,68,68,0.12); color:#f87171; }',
'.lt-mgr-add-item { margin-top:4px; }',
'/* 毛玻璃 - 节点浮动面板 */',
'.react-flow__nodes .node-floating-ui > div.bg-panel-background {',
' background-color: rgba(38, 38, 38, 0.55) !important;',
' backdrop-filter: blur(20px) !important;',
' -webkit-backdrop-filter: blur(20px) !important;',
' border: 1px solid rgba(255, 255, 255, 0.08) !important;',
'}',
'/* 毛玻璃 - 底部导航栏 */',
'div[class*="b768:bottom-3"] {',
' background-color: rgba(38, 38, 38, 0.55) !important;',
' backdrop-filter: blur(20px) !important;',
' -webkit-backdrop-filter: blur(20px) !important;',
' border: 1px solid rgba(255, 255, 255, 0.08) !important;',
'}',
'/* 隐藏青色"会员超市"按钮 */',
'button[aria-label="会员超市"],',
'button[class*="text-[#05A3C5]"] {',
' display: none !important;',
'}',
'/* 隐藏Mantine图标按钮 */',
'#mantine-y9su9myak-target {',
' display: none !important;',
'}',
'/* 隐藏额外的Mantine图标按钮 */',
'#mantine-44x1mzccr-target {',
' display: none !important;',
'}',
'/* 隐藏"限时40折"徽章 */',
'[class*="bg-[#FAD6A4]"] {',
' display: none !important;',
'}',
'/* 隐藏导航栏右侧文字div */',
'div[class*="border-"][class*="topnav-btn-border"] > div.relative:first-child > div.relative:last-child {',
' display: none !important;',
'}',
'/* 画布背景:网格参考线 + 中心暖色辉光 */',
'.react-flow__pane {',
' background-image: ',
' radial-gradient(ellipse at 50% 50%, rgba(255, 180, 80, 0.05) 0%, rgba(255, 140, 50, 0.02) 25%, transparent 55%),',
' repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.015) 0px, rgba(255, 255, 255, 0.015) 1px, transparent 1px, transparent 40px),',
' repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.015) 0px, rgba(255, 255, 255, 0.015) 1px, transparent 1px, transparent 40px) !important;',
' background-color: transparent !important;',
'}',
/* ===== 隐藏干扰元素 ===== */
'header.m_3b16f56b > div.relative:first-child {',
' display: none !important;',
'}',
'body.libtv-clean-home button[aria-label="会员超市"], button[class*="text-[#05A3C5]"] {',
' display: none !important;',
'}',
'[class*="bg-[#FAD6A4]"] {',
' display: none !important;',
'}',
'#mantine-ycmieh2cx-target,',
'#mantine-cdb8qursd-target,',
'body.libtv-clean-home button[aria-label="帮助信息"] {',
' display: none !important;',
'}',
'body.libtv-clean-home a[aria-label="回到主站"],',
'body.libtv-clean-home button[aria-label="创作者挑战赛"] {',
' display: none !important;',
'}',
/* 主 Banner / 横向轮播 / AI输入区 / TV Show 区域 / 底部滚动按钮 */
'body.libtv-clean-home div.b1280\\:max-w-\\[1440px\\] > div.block,',
'body.libtv-clean-home div.b1280\\:max-w-\\[1440px\\] > div.hidden,',
'body.libtv-clean-home div.b1280\\:max-w-\\[1440px\\] > div.mx-auto,',
'body.libtv-clean-home div.b1280\\:max-w-\\[1440px\\] > div.mt-10,',
'body.libtv-clean-home div.b1280\\:max-w-\\[1440px\\] > button.border-border-default {',
' display: none !important;',
'}',
/* ===== 首页-个人最近项目 ===== */
'body.libtv-clean-home div.b768\\:mb-8:nth-of-type(4) {',
' width: 100% !important;',
' max-width: 1200px !important;',
' height: auto !important;',
' margin: 48px auto !important;',
' padding: 0 24px !important;',
'}',
'body.libtv-clean-home div.b768\\:mb-8:nth-of-type(4) > body.libtv-clean-home div.b768\\:mb-4 {',
' margin-bottom: 28px !important;',
' padding: 0 4px !important;',
' display: flex !important;',
' visibility: visible !important;',
' opacity: 1 !important;',
'}',
'body.libtv-clean-home div.b768\\:mb-8:nth-of-type(4) > body.libtv-clean-home div.b768\\:mb-4 body.libtv-clean-home div.b768\\:text-\\[18px\\] {',
' font-size: 22px !important;',
' font-weight: 600 !important;',
' letter-spacing: 0.3px !important;',
'}',
'body.libtv-clean-home div.b768\\:mb-8:nth-of-type(4) div.scrollbar-hide {',
' display: grid !important;',
' grid-template-columns: repeat(3, 1fr) !important;',
' gap: 24px !important;',
' width: 100% !important;',
' height: auto !important;',
' min-width: 0 !important;',
'}',
'/* 开始创作卡片 */',
'body.libtv-clean-home div.b768\\:mb-8:nth-of-type(4) div.aspect-video,',
'body.libtv-clean-home div.b768\\:mb-8:nth-of-type(4) div.aspect-video > div.cursor-pointer {',
' width: 100% !important;',
' height: 320px !important;',
' max-width: 100% !important;',
' min-width: 0 !important;',
'}',
'body.libtv-clean-home div.b768\\:mb-8:nth-of-type(4) div.create-new-project-card {',
' width: 100% !important;',
' height: 100% !important;',
' background-color: rgba(38, 38, 38, 0.4) !important;',
' border: 2px dashed rgba(255, 255, 255, 0.12) !important;',
' border-radius: 16px !important;',
' gap: 16px !important;',
' transition: all 0.3s ease !important;',
'}',
'body.libtv-clean-home div.b768\\:mb-8:nth-of-type(4) div.create-new-project-card:hover {',
' background-color: rgba(38, 38, 38, 0.65) !important;',
' border-color: rgba(255, 255, 255, 0.25) !important;',
'}',
'body.libtv-clean-home div.b768\\:mb-8:nth-of-type(4) div.create-new-project-card div.text-fg-default {',
' font-size: 16px !important;',
' color: rgba(255, 255, 255, 0.7) !important;',
' text-align: center !important;',
' width: auto !important;',
'}',
'/* 项目卡片 */',
'body.libtv-clean-home div.b768\\:mb-8:nth-of-type(4) div.md\\:w-auto {',
' width: 100% !important;',
' height: 320px !important;',
' max-width: 100% !important;',
' min-width: 0 !important;',
'}',
'body.libtv-clean-home div.b768\\:mb-8:nth-of-type(4) div.md\\:w-auto div.group {',
' width: 100% !important;',
' height: 100% !important;',
' border-radius: 16px !important;',
' overflow: hidden !important;',
' background-color: #1e1e1e !important;',
' border: 1px solid rgba(255, 255, 255, 0.06) !important;',
' transition: transform 0.3s ease, box-shadow 0.3s ease !important;',
'}',
'body.libtv-clean-home div.b768\\:mb-8:nth-of-type(4) div.md\\:w-auto div.group:hover {',
' transform: translateY(-4px) !important;',
' box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5) !important;',
'}',
'/* 封面 */',
'body.libtv-clean-home div.b768\\:mb-8:nth-of-type(4) div.md\\:w-auto div.group > div:nth-of-type(1),',
'body.libtv-clean-home div.b768\\:mb-8:nth-of-type(4) div.md\\:w-auto div.group div.rounded-xl,',
'body.libtv-clean-home div.b768\\:mb-8:nth-of-type(4) div.md\\:w-auto div.group div.rounded-xl div.relative {',
' width: 100% !important;',
' height: 210px !important;',
' border-radius: 0 !important;',
'}',
'/* 底部信息 */',
'body.libtv-clean-home div.b768\\:mb-8:nth-of-type(4) div.md\\:w-auto div.group div.items-top {',
' width: 100% !important;',
' height: 110px !important;',
' padding: 16px !important;',
' flex-direction: column !important;',
' align-items: flex-start !important;',
' gap: 8px !important;',
'}',
'body.libtv-clean-home div.b768\\:mb-8:nth-of-type(4) div.md\\:w-auto div.group div.items-top div.max-w-\\[calc\\(100\\%-34px\\)\\] {',
' width: 100% !important;',
' max-width: 100% !important;',
'}',
'body.libtv-clean-home div.b768\\:mb-8:nth-of-type(4) div.md\\:w-auto div.group div.items-top p.text-fg-default {',
' font-size: 15px !important;',
' font-weight: 500 !important;',
' line-height: 1.4 !important;',
' color: #f0f0f0 !important;',
' display: -webkit-box !important;',
' -webkit-line-clamp: 2 !important;',
' -webkit-box-orient: vertical !important;',
' overflow: hidden !important;',
'}',
'body.libtv-clean-home div.b768\\:mb-8:nth-of-type(4) div.md\\:w-auto div.group div.items-top p.text-xs {',
' font-size: 13px !important;',
' color: #888 !important;',
'}',
/* ===== 全部项目 - 容器 ===== */
'body.libtv-clean-home div.b768\\:px-\\[10px\\] > div.mx-auto {',
' max-width: 1800px !important;',
' padding: 0 24px !important;',
' margin: 0 auto !important;',
'}',
'/* 面包屑导航 */',
'body.libtv-clean-home div.b768\\:px-\\[10px\\] > div.mx-auto > div.mb-6 {',
' margin: 28px 0 24px 0 !important;',
' justify-content: space-between !important;',
' align-items: center !important;',
'}',
'body.libtv-clean-home div.b768\\:px-\\[10px\\] > div.mx-auto > div.mb-6 div.text-base {',
' font-size: 24px !important;',
' font-weight: 600 !important;',
'}',
'body.libtv-clean-home div.b768\\:px-\\[10px\\] > div.mx-auto > div.mb-6 button.bg-btn-secondary {',
' background-color: rgba(255, 255, 255, 0.08) !important;',
' border: 1px solid rgba(255, 255, 255, 0.12) !important;',
' padding: 4px 16px !important;',
' border-radius: 8px !important;',
'}',
'/* 网格 */',
'body.libtv-clean-home div.b768\\:px-\\[10px\\] > div.mx-auto body.libtv-clean-home div.b768\\:grid-cols-3 {',
' display: grid !important;',
' grid-template-columns: repeat(6, 1fr) !important;',
' gap: 16px !important;',
' width: 100% !important;',
' height: auto !important;',
'}',
'body.libtv-clean-home div.b768\\:px-\\[10px\\] > div.mx-auto input.hidden {',
' display: none !important;',
'}',
'/* "最近项目" 分区标题 */',
'body.libtv-clean-home div.b768\\:px-\\[10px\\] > div.mx-auto body.libtv-clean-home div.b768\\:grid-cols-3::before {',
' content: \'最近项目\' !important;',
' grid-column: 1 / -1 !important;',
' display: block !important;',
' font-size: 18px !important;',
' font-weight: 600 !important;',
' color: rgba(255, 255, 255, 0.9) !important;',
' padding: 4px 0 !important;',
' margin-bottom: 4px !important;',
'}',
'/* 开始创作卡片 - 280px */',
'body.libtv-clean-home div.b768\\:px-\\[10px\\] > div.mx-auto div.aspect-video {',
' width: 100% !important;',
' min-width: 0 !important;',
' height: 280px !important;',
'}',
'body.libtv-clean-home div.b768\\:px-\\[10px\\] > div.mx-auto div.create-new-project-card {',
' width: 100% !important;',
' height: 280px !important;',
' background-color: rgba(38, 38, 38, 0.4) !important;',
' border: 2px dashed rgba(255, 255, 255, 0.12) !important;',
' border-radius: 16px !important;',
' gap: 8px !important;',
' transition: all 0.3s ease !important;',
'}',
'body.libtv-clean-home div.b768\\:px-\\[10px\\] > div.mx-auto div.create-new-project-card:hover {',
' background-color: rgba(38, 38, 38, 0.65) !important;',
' border-color: rgba(255, 255, 255, 0.25) !important;',
'}',
'body.libtv-clean-home div.b768\\:px-\\[10px\\] > div.mx-auto div.create-new-project-card div.text-fg-default {',
' font-size: 16px !important;',
' text-align: center !important;',
'}',
'body.libtv-clean-home div.b768\\:px-\\[10px\\] > div.mx-auto div.create-new-project-card svg,',
'body.libtv-clean-home div.b768\\:px-\\[10px\\] > div.mx-auto div.create-new-project-card div.py-2\\.5 p {',
' display: block !important;',
'}',
'/* 项目卡片 - 280px */',
'body.libtv-clean-home div.b768\\:px-\\[10px\\] > div.mx-auto body.libtv-clean-home div.b768\\:grid-cols-3 > div.group {',
' border-radius: 16px !important;',
' overflow: hidden !important;',
' background-color: #1a1a1a !important;',
' border: 1px solid rgba(255, 255, 255, 0.06) !important;',
' transition: transform 0.25s ease, box-shadow 0.25s ease !important;',
' width: 100% !important;',
' min-width: 0 !important;',
' height: 280px !important;',
'}',
'body.libtv-clean-home div.b768\\:px-\\[10px\\] > div.mx-auto body.libtv-clean-home div.b768\\:grid-cols-3 > div.group:hover {',
' transform: translateY(-3px) !important;',
' box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5) !important;',
'}',
'/* 封面 - 170px */',
'body.libtv-clean-home div.b768\\:px-\\[10px\\] > div.mx-auto body.libtv-clean-home div.b768\\:grid-cols-3 > div.group > div:nth-of-type(1) {',
' width: 100% !important;',
' height: 170px !important;',
' overflow: hidden !important;',
'}',
'body.libtv-clean-home div.b768\\:px-\\[10px\\] > div.mx-auto body.libtv-clean-home div.b768\\:grid-cols-3 > div.group div.aspect-video {',
' width: 100% !important;',
' height: 170px !important;',
'}',
'body.libtv-clean-home div.b768\\:px-\\[10px\\] > div.mx-auto body.libtv-clean-home div.b768\\:grid-cols-3 > div.group img {',
' width: 100% !important;',
' height: 100% !important;',
' object-fit: cover !important;',
'}',
'/* 底部信息 - 110px */',
'body.libtv-clean-home div.b768\\:px-\\[10px\\] > div.mx-auto body.libtv-clean-home div.b768\\:grid-cols-3 > div.group div.items-top {',
' width: 100% !important;',
' padding: 14px 16px !important;',
' height: 110px !important;',
'}',
'body.libtv-clean-home div.b768\\:px-\\[10px\\] > div.mx-auto body.libtv-clean-home div.b768\\:grid-cols-3 > div.group div.items-top p.text-fg-default {',
' font-size: 13px !important;',
' font-weight: 500 !important;',
' color: #eee !important;',
' line-height: 1.3 !important;',
' white-space: nowrap !important;',
' overflow: hidden !important;',
' text-overflow: ellipsis !important;',
' display: -webkit-box !important;',
' -webkit-line-clamp: 2 !important;',
' -webkit-box-orient: vertical !important;',
'}',
'body.libtv-clean-home div.b768\\:px-\\[10px\\] > div.mx-auto body.libtv-clean-home div.b768\\:grid-cols-3 > div.group div.items-top p.text-xs {',
' font-size: 11px !important;',
' color: #888 !important;',
'}',
'/* 分割线 + "所有项目" 标题 */',
'body.libtv-clean-home div.b768\\:px-\\[10px\\] > div.mx-auto body.libtv-clean-home div.b768\\:grid-cols-3 > div.group:nth-of-type(12) {',
' position: relative !important;',
'}',
'body.libtv-clean-home div.b768\\:px-\\[10px\\] > div.mx-auto body.libtv-clean-home div.b768\\:grid-cols-3 > div.group:nth-of-type(12)::after {',
' content: \'所有项目\' !important;',
' position: absolute !important;',
' bottom: -52px !important;',
' left: -1200% !important;',
' width: 5000px !important;',
' padding-top: 28px !important;',
' font-size: 18px !important;',
' font-weight: 600 !important;',
' color: rgba(255, 255, 255, 0.9) !important;',
' border-top: 1px solid rgba(255, 255, 255, 0.10) !important;',
' pointer-events: none !important;',
'}',
'/* ⚙ 设置面板 */',
'.lt-settings { position:fixed; top:50%; left:50%; transform:translate(-50%,-50%); z-index:100002; width:440px; max-width:90vw; max-height:80vh; background:rgba(15,15,20,0.96); backdrop-filter:blur(32px) saturate(1.3); -webkit-backdrop-filter:blur(32px) saturate(1.3); border:1px solid rgba(129,140,248,0.2); border-radius:14px; display:flex; flex-direction:column; overflow:hidden; box-shadow:0 16px 48px rgba(0,0,0,0.6); }',
'.lt-settings-head { display:flex; align-items:center; justify-content:space-between; padding:16px 18px 10px; border-bottom:1px solid rgba(129,140,248,0.1); font-size:14px; color:#e0e7ff; font-weight:600; flex-shrink:0; letter-spacing:0.02em; }',
'.lt-settings-close { cursor:pointer; font-size:16px; color:rgba(255,255,255,0.2); transition:color .15s; line-height:1; }',
'.lt-settings-close:hover { color:#818cf8; }',
'.lt-settings-body { flex:1; overflow-y:auto; padding:4px 18px 18px; }',
'.lt-settings-sec { margin-top:16px; }',
'.lt-settings-stitle { font-size:11px; color:rgba(129,140,248,0.5); margin-bottom:8px; letter-spacing:0.04em; text-transform:uppercase; }',
'.lt-settings-toggle { display:flex; align-items:center; justify-content:space-between; padding:8px 0; cursor:pointer; border-bottom:1px solid rgba(255,255,255,0.03); }',
'.lt-settings-toggle span:first-child { font-size:13px; color:rgba(255,255,255,0.55); }',
'.lt-settings-switch { width:36px; height:20px; border-radius:10px; background:rgba(255,255,255,0.1); position:relative; transition:background .2s; flex-shrink:0; }',
'.lt-settings-switch::after { content:\'\'; position:absolute; top:2px; left:2px; width:16px; height:16px; border-radius:50%; background:#fff; transition:transform .2s; }',
'.lt-settings-switch.on { background:#818cf8; }',
'.lt-settings-switch.on::after { transform:translateX(16px); }',
'.lt-settings-row { display:flex; align-items:center; gap:8px; margin-bottom:6px; }',
'.lt-settings-row label { font-size:11px; color:rgba(255,255,255,0.3); min-width:60px; flex-shrink:0; }',
'.lt-settings-inp { flex:1; background:rgba(255,255,255,0.04); border:1px solid rgba(129,140,248,0.12); border-radius:6px; padding:7px 10px; font:12px/1.4 -apple-system,sans-serif; color:#d4d4d8; outline:none; transition:border-color .12s; }',
'.lt-settings-inp:focus { border-color:#818cf8; }',
'.lt-settings-status { font-size:11px; color:rgba(74,222,128,0.7); margin-left:8px; }',
'.lt-settings-dlist { margin-bottom:8px; }',
'.lt-settings-ditem { display:flex; align-items:center; gap:6px; padding:5px 0; border-bottom:1px solid rgba(255,255,255,0.02); font-size:11px; }',
'.lt-settings-ditem span:first-child { flex:1; color:rgba(255,255,255,0.35); }',
'.lt-settings-ditem span:nth-child(2) { color:rgba(255,255,255,0.15); min-width:40px; text-align:right; }',
'.lt-settings-dclear { background:none; border:none; color:rgba(239,68,68,0.4); cursor:pointer; font-size:10px; padding:1px 6px; border-radius:3px; transition:all .12s; }',
'.lt-settings-dclear:hover { background:rgba(239,68,68,0.12); color:#f87171; }',
'.lt-settings-about { font-size:11px; color:rgba(255,255,255,0.2); line-height:1.6; margin-top:4px; }',
'.lt-settings-cpbtns { display:flex; gap:6px; margin-top:8px; }',
'.lt-settings-btn { display:inline-flex; align-items:center; gap:4px; padding:6px 12px; border-radius:7px; border:none; cursor:pointer; font:12px/1.4 -apple-system,sans-serif; transition:all .15s; }',
'.lt-settings-btn-primary { background:#6366f1; color:#fff; }',
'.lt-settings-btn-primary:hover { background:#818cf8; }',
'.lt-settings-btn-ghost { background:rgba(255,255,255,0.05); color:rgba(255,255,255,0.55); border:1px solid rgba(255,255,255,0.06); }',
'.lt-settings-btn-ghost:hover { background:rgba(255,255,255,0.1); color:#fff; }',
'.lt-settings-btn-sm { padding:4px 10px; font-size:11px; }',
'',
].join('\n');
document.head.appendChild(style);
/* =========================================================
* 2. FPS 面板
* ========================================================= */
var fpsEl = document.createElement('div');
fpsEl.id = 'libtv-fps';
fpsEl.innerHTML = '<span class="fps-val">--fps</span><span class="fps-sep">|</span><span class="fps-zoom">100%</span><span class="fps-sep">|</span><span class="fps-cnt">-节点</span><span class="fps-sep fps-flag-sep">|</span><span class="fps-flags"></span>';
var fpsVal = fpsEl.querySelector('.fps-val');
var fpsZoom = fpsEl.querySelector('.fps-zoom');
var fpsCnt = fpsEl.querySelector('.fps-cnt');
var fpsFlags = fpsEl.querySelector('.fps-flags');
var fpsFlagSep = fpsEl.querySelector('.fps-flag-sep');
document.body.appendChild(fpsEl);
var helpEl = document.createElement('div');
helpEl.id = 'libtv-help';
helpEl.classList.add('libtv-hide');
helpEl.textContent = '画布\n G 网格 T 性能 H 隐藏 L 连线\n C 全链 R 直角 X 专注\n工具\n F 搜索 P 提示词 N 清爽 ? 帮助';
document.body.appendChild(helpEl);
function _showHelp(){ if(helpEl) helpEl.classList.remove('libtv-hide'); }
function _hideHelp(){ if(helpEl && !helpEl.classList.contains('libtv-pin')) helpEl.classList.add('libtv-hide'); }
if(fpsEl){ fpsEl.addEventListener('mouseenter', _showHelp); fpsEl.addEventListener('mouseleave', _hideHelp); }
var _fc = 0, _lastT = performance.now(), _fps = 0;
// FPS 拖拽
(function(){
var dx = 0, dy = 0, dragging = false;
fpsEl.addEventListener('mousedown', function(e){
dragging = true;
dx = e.clientX - fpsEl.offsetLeft;
dy = e.clientY - fpsEl.offsetTop;
e.preventDefault();
});
document.addEventListener('mousemove', function(e){
if(!dragging) return;
var l = e.clientX - dx, t = e.clientY - dy;
var pw = fpsEl.offsetWidth, ph = fpsEl.offsetHeight;
l = Math.max(4, Math.min(l, window.innerWidth - pw - 4));
t = Math.max(4, Math.min(t, window.innerHeight - ph - 4));
fpsEl.style.left = l + 'px';
fpsEl.style.top = t + 'px';
fpsEl.style.bottom = 'auto';
fpsEl.style.right = 'auto';
});
document.addEventListener('mouseup', function(){
dragging = false;
});
})();
function fpsLoop(now){
if (document.hidden) { _lastT = now; requestAnimationFrame(fpsLoop); return; }
_fc++;
if (now - _lastT >= 1000){
_fps = Math.round(_fc * 1000 / (now - _lastT));
var flags = '', zoom = '';
var bg = document.querySelector('.react-flow__background');
if (bg && bg.classList.contains('perf-no-grid')) flags += '<span class="fps-flag">■</span>';
if (document.body.classList.contains('perf-mode')) flags += '<span class="fps-flag">◆</span>';
if (document.body.classList.contains('perf-hide-imgs')) flags += '<span class="fps-flag">⊙</span>';
var edges = document.querySelector('.react-flow__edges');
if (edges && edges.classList.contains('perf-hide-edges')) flags += '<span class="fps-flag">╳</span>';
if (document.body.classList.contains('libtv-chain')) flags += '<span class="fps-flag">◉</span>';
if (document.body.classList.contains('libtv-autochain')) flags += '<span class="fps-flag">⟷</span>';
if (document.body.classList.contains('libtv-focus')) flags += '<span class="fps-flag">◎</span>';
if (document.body.classList.contains('libtv-step-edges')) flags += '<span class="fps-flag">└</span>';
if (document.body.classList.contains('libtv-clean-home')) flags += '<span class="fps-flag">♡</span>';
var nTotal = document.querySelectorAll('.react-flow__node').length;
// 缩放级别
var vp = document.querySelector('.react-flow__viewport');
if(vp){
var m = (vp.style.transform || '').match(/scale\(([^)]+)\)/);
if(m) zoom = Math.round(parseFloat(m[1]) * 100) + '%';
}
fpsVal.textContent = _fps + 'fps';
fpsZoom.textContent = zoom || '';
fpsZoom.style.display = zoom ? '' : 'none';
fpsCnt.textContent = nTotal + '节点';
fpsFlags.innerHTML = flags;
fpsFlagSep.style.display = flags ? '' : 'none';
_fc = 0;
_lastT = now;
}
requestAnimationFrame(fpsLoop);
}
requestAnimationFrame(fpsLoop);
/* =========================================================
* 流动光效 — 全屏 SVG overlay,不碰节点 DOM
* ========================================================= */
(function(){
var svgNS='http://www.w3.org/2000/svg';
var overlay=document.createElementNS(svgNS,'svg');
overlay.id='libtv-glow';
overlay.style.cssText='position:fixed;top:0;left:0;width:100vw;height:100vh;pointer-events:none;z-index:50;';
document.body.appendChild(overlay);
var glowDefs=document.createElementNS(svgNS,'defs');
var filter=document.createElementNS(svgNS,'filter');
filter.setAttribute('id','glowBlur');
filter.setAttribute('x','-50%');filter.setAttribute('y','-50%');
filter.setAttribute('width','200%');filter.setAttribute('height','200%');
var blur=document.createElementNS(svgNS,'feGaussianBlur');
blur.setAttribute('stdDeviation','6');
filter.appendChild(blur);
glowDefs.appendChild(filter);
overlay.appendChild(glowDefs);
var animGroup=document.createElementNS(svgNS,'g');
overlay.appendChild(animGroup);
var prevNodes=new Set();
var animRaf=null;
function readAccent(){
var n=document.querySelector('.react-flow__node');
if(!n)return{accent:'#6366f1',accentLight:'#818cf8'};
var s=getComputedStyle(n);
return{
accent:s.getPropertyValue('--accent').trim()||'#6366f1',
accentLight:s.getPropertyValue('--accent-light').trim()||'#818cf8'
};
}
function buildFrame(){
while(animGroup.firstChild)animGroup.removeChild(animGroup.firstChild);
var nodes=document.querySelectorAll('.react-flow__node.selected');
if(!nodes.length){prevNodes.clear();return;}
var c=readAccent();
var now=performance.now();
nodes.forEach(function(node){
var r=node.getBoundingClientRect();
var w=r.width,h=r.height;
var cssW=node.offsetWidth||w,cssH=node.offsetHeight||h;
var zoomX=cssW?w/cssW:1,zoomY=cssH?h/cssH:1;
var zoom=Math.min(zoomX,zoomY);
var cssBr=parseFloat(getComputedStyle(node).borderRadius)||12;
var br=cssBr*zoom;
var perim=2*(w+h);
var dash=Math.round(perim*0.12),gap=perim-dash;
function mkRect(stroke,sw){
var el=document.createElementNS(svgNS,'rect');
el.setAttribute('x',0);el.setAttribute('y',0);
el.setAttribute('width',w);el.setAttribute('height',h);
el.setAttribute('rx',br);el.setAttribute('fill','none');
el.setAttribute('stroke',stroke);el.setAttribute('stroke-width',sw);
el.setAttribute('stroke-dasharray',dash+' '+gap);
return el;
}
var g1=mkRect(c.accentLight,8);
g1.setAttribute('filter','url(#glowBlur)');
var g2=mkRect('#fff',2);
var p=((now%7000)/7000);
var off=Math.round(p*perim);
g1.setAttribute('stroke-dashoffset',off);
g2.setAttribute('stroke-dashoffset',off);
var wrap=document.createElementNS(svgNS,'g');
wrap.setAttribute('transform','translate('+r.left+','+r.top+')');
wrap.appendChild(g1);
wrap.appendChild(g2);
animGroup.appendChild(wrap);
});
}
function loop(){buildFrame();animRaf=requestAnimationFrame(loop);}
loop();
})();
/* =========================================================
* AI Agent Drawer 适配 — 动态读宽度右推
* ========================================================= */
(function(){
var drawerSel = '.canvas-agent-drawer-chat';
function drawerEl(){ return document.querySelector(drawerSel) || document.querySelector('.mantine-Drawer-content.canvas-agent-drawer-chat'); }
function adjust(){
var el = drawerEl(), dw = el ? el.offsetWidth : 0;
var fps = document.getElementById('libtv-fps');
var pbtn = document.getElementById('libtv-pbtn');
if(dw > 0 && el.getBoundingClientRect().right > window.innerWidth / 2){
/* Drawer on right — shift our elements if they're still in default right position (not dragged) */
var gap = 16;
[fps, pbtn].forEach(function(x){
if(x && !x.style.left){
if(!x._dd){ x._dd = true; x._dr = x.style.right; x._db = x.style.bottom; }
x.style.right = (dw + gap + (x === pbtn ? 46 : 0)) + 'px';
}
});
} else if(dw === 0){
[fps, pbtn].forEach(function(x){
if(x && x._dd){ x.style.right = x._dr; x.style.bottom = x._db; delete x._dd; delete x._dr; delete x._db; }
});
}
}
var obs = new MutationObserver(function(){
if(obs._t) clearTimeout(obs._t);
obs._t = setTimeout(adjust, 50);
});
obs.observe(document.body, { childList: true, subtree: true });
window.addEventListener('resize', function(){
if(drawerEl()) setTimeout(adjust, 50);
});
setTimeout(adjust, 500);
})();
/* =========================================================
* 3. 快捷键 + 状态持久化
* ========================================================= */
var hook;
try {
hook = document.createElement('script');
hook.textContent = [
'(function(){',
/* ———— 链高亮引擎 ———— */
' function _ltClearChain(){',
' document.body.classList.remove("libtv-chain");',
' document.querySelectorAll(".libtv-chain-node,.libtv-chain-edge").forEach(function(e){',
' e.classList.remove("libtv-chain-node","libtv-chain-edge");',
' });',
' };',
' var _ltAutoChain=localStorage.getItem("_lt_autochain")==="1";',
' if(_ltAutoChain) document.body.classList.add("libtv-autochain");',
' var _ltGraphCache=null;',
' function _ltGetGraph(){',
' if(!_ltGraphCache){',
' var up={},down={};',
' document.querySelectorAll(".react-flow__edge").forEach(function(e){',
' var lb=e.getAttribute("aria-label")||"",m=lb.match(/^Edge from (\\S+) to (\\S+)$/);',
' if(!m)return;',
' var s=m[1],t=m[2];',
' if(!down[s])down[s]=[]; down[s].push(t);',
' if(!up[t])up[t]=[]; up[t].push(s);',
' });',
' _ltGraphCache={up:up,down:down};',
' }',
' return _ltGraphCache;',
' }',
' function _ltInvalidateGraph(){_ltGraphCache=null;}',
' document.addEventListener("click",function(e){',
' _ltInvalidateGraph();',
' if(!_ltAutoChain) return;',
' if(!e.target.closest(".react-flow__node")){',
' _ltClearChain(); return;',
' }',
' setTimeout(function(){',
' if(document.querySelector(".react-flow__node.selected")){',
' var g=_ltGetGraph(),sid=document.querySelector(".react-flow__node.selected").getAttribute("data-id")||"";',
' if(!sid||!g)return;',
' var v={},q=[sid]; v[sid]=1;',
' while(q.length){',
' var c=q.shift();',
' (g.up[c]||[]).forEach(function(n){if(!v[n]){v[n]=1;q.push(n);}});',
' (g.down[c]||[]).forEach(function(n){if(!v[n]){v[n]=1;q.push(n);}});',
' }',
' document.querySelectorAll(".react-flow__node").forEach(function(n){',
' n.classList[(v[n.getAttribute("data-id")||n.id||""])?"add":"remove"]("libtv-chain-node");',
' });',
' document.querySelectorAll(".react-flow__edge").forEach(function(e){',
' var lb=e.getAttribute("aria-label")||"",m=lb.match(/^Edge from (\\S+) to (\\S+)$/);',
' e.classList[(m&&v[m[1]]&&v[m[2]])?"add":"remove"]("libtv-chain-edge");',
' });',
' document.body.classList.add("libtv-chain");',
' }',
' }, 50);',
' }, true);',
/* ———— 连线 hover 高亮 ———— */
' document.addEventListener("mouseover",function(e){',
' var n=e.target.closest(".react-flow__node");',
' if(!n)return;',
' var id=n.getAttribute("data-id")||n.id||""; if(!id)return;',
' document.querySelectorAll(".react-flow__edge").forEach(function(ed){',
' var lb=ed.getAttribute("aria-label")||"",m=lb.match(/^Edge from (\\S+) to (\\S+)$/);',
' if(m&&(m[1]===id||m[2]===id)) ed.classList.add("libtv-edge-active");',
' });',
' },true);',
' document.addEventListener("mouseout",function(e){',
' if(!e.target.closest(".react-flow__node"))return;',
' document.querySelectorAll(".react-flow__edge.libtv-edge-active").forEach(function(ed){',
' ed.classList.remove("libtv-edge-active");',
' });',
' },true);',
/* ———— 节点搜索 ———— */
' function _ltSearch(){',
' var overlay=document.getElementById("libtv-search");',
' if(overlay){ overlay.remove(); return; }',
' var items=[];',
' document.querySelectorAll(".react-flow__node").forEach(function(n){',
' var id=n.getAttribute("data-id")||n.id||"";',
' if(!id)return;',
' var txt=(n.textContent||"").trim().split("\\n")[0].trim().slice(0,50);',
' items.push({id:id,name:txt||id,el:n});',
' });',
' var div=document.createElement("div");',
' div.id="libtv-search";',
' div.style.cssText="position:fixed;top:60px;right:20px;z-index:99999;background:rgba(0,0,0,0.9);border-radius:10px;padding:10px;width:280px;max-height:60vh;overflow:auto;font:12px/1.5 sans-serif;";',
' div.innerHTML="<input id=\\\"lt-search-input\\\" placeholder=\\\"搜索节点...\\\" style=\\\"width:100%;box-sizing:border-box;padding:6px 10px;border-radius:6px;border:1px solid rgba(255,255,255,0.1);background:rgba(255,255,255,0.06);color:#fff;font:12px/1.5 sans-serif;outline:none;\\\"><div id=\\\"lt-search-results\\\" style=\\\"margin-top:6px;\\\"></div>";',
' document.body.appendChild(div);',
' function render(q){',
' var q=(q||"").toLowerCase(),html="";',
' items.forEach(function(it){',
' if(!q||it.name.toLowerCase().indexOf(q)>=0||it.id.toLowerCase().indexOf(q)>=0){',
' html+="<div data-id=\\\""+_ltEsc(it.id)+"\\\" style=\\\"padding:4px 8px;border-radius:4px;cursor:pointer;color:#ccc;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;\\">"+_ltEsc(it.name)+"</div>";',
' }',
' });',
' document.getElementById("lt-search-results").innerHTML=html;',
' }',
' render("");',
' document.getElementById("lt-search-input").addEventListener("input",function(){',
' render(this.value);',
' });',
' document.getElementById("lt-search-results").addEventListener("click",function(e){',
' var item=e.target.closest("[data-id]");',
' if(!item)return;',
' var id=item.getAttribute("data-id");',
' var el=document.querySelector(\'.react-flow__node[data-id="\'+id+\'"],.react-flow__node#\'+id);',
' if(el){',
' el.scrollIntoView({behavior:"smooth",block:"center"});',
' el.click();',
' }',
' div.remove();',
' });',
' document.getElementById("lt-search-input").focus();',
' }',
/* ———— 提示词工具 ———— */
' var _ltPrompts=JSON.parse(localStorage.getItem("_lt_prompts")||"[]");',
' if(!_ltPrompts.length){',
' _ltPrompts=[',
' {id:"d1",name:"产品摄影",category:"图像",content:"Product photography on {background=white} background, {lighting=studio lighting}, high detail, 8K, sharp focus, {extra}"},',
' {id:"d2",name:"电影镜头",category:"图像",content:"Cinematic shot, {lens=anamorphic} lens, {lighting=dramatic} lighting, shallow depth of field, {style}"},',
' {id:"d3",name:"动画-吉卜力风",category:"图像",content:"Studio Ghibli style, hand-drawn animation, {palette=soft pastel} colors, {atmosphere=whimsical}"},',
' {id:"d4",name:"产品展示-环绕",category:"视频",content:"Smooth 360 orbit around {subject=product}, {lighting=soft studio} lighting, slow motion, {extra}"},',
' {id:"d5",name:"风光-延时",category:"视频",content:"Timelapse, {time=golden hour}, {sky=dramatic clouds}, warm tones, smooth transition, {extra}"},',
' ];',
' try{localStorage.setItem("_lt_prompts",JSON.stringify(_ltPrompts));}catch(e){}',
' }',
' var _ltPromptAPI=JSON.parse(localStorage.getItem("_lt_prompt_api")||"{\\"url\\":\\"https://api.deepseek.com/chat/completions\\",\\"model\\":\\"deepseek-v4-flash\\"}");',
' if(!_ltPromptAPI.url){_ltPromptAPI.url="https://api.deepseek.com/chat/completions";_ltPromptAPI.model=_ltPromptAPI.model||"deepseek-v4-flash";}',
' var _ltThemePresets=[',
' {n:"靛蓝",a:"#6366f1",l:"#818cf8",d:"#4f46e5",ar:"99,102,241",alr:"129,140,248",cb:"#0e0e12",gc:"rgba(255,255,255,0.12)",nb:"#16162a",nc:"rgba(129,140,248,0.15)",ec:"rgba(129,140,248,0.15)",cat:"dark"},',
' {n:"翡翠",a:"#10b981",l:"#34d399",d:"#059669",ar:"16,185,129",alr:"52,211,153",cb:"#0b120f",gc:"rgba(255,255,255,0.12)",nb:"#12261c",nc:"rgba(52,211,153,0.15)",ec:"rgba(52,211,153,0.15)",cat:"dark"},',
' {n:"玫瑰",a:"#f43f5e",l:"#fb7185",d:"#e11d48",ar:"244,63,94",alr:"251,113,133",cb:"#120b0d",gc:"rgba(255,255,255,0.12)",nb:"#261318",nc:"rgba(251,113,133,0.15)",ec:"rgba(251,113,133,0.15)",cat:"dark"},',
' {n:"琥珀",a:"#f59e0b",l:"#fbbf24",d:"#d97706",ar:"245,158,11",alr:"251,191,36",cb:"#12100a",gc:"rgba(255,255,255,0.12)",nb:"#261e12",nc:"rgba(251,191,36,0.15)",ec:"rgba(251,191,36,0.15)",cat:"dark"},',
' {n:"天蓝",a:"#0ea5e9",l:"#38bdf8",d:"#0284c7",ar:"14,165,233",alr:"56,189,248",cb:"#0a1013",gc:"rgba(255,255,255,0.12)",nb:"#111f28",nc:"rgba(56,189,248,0.15)",ec:"rgba(56,189,248,0.15)",cat:"dark"},',
' {n:"紫色",a:"#8b5cf6",l:"#a78bfa",d:"#7c3aed",ar:"139,92,246",alr:"167,139,250",cb:"#0e0c14",gc:"rgba(255,255,255,0.12)",nb:"#1b1730",nc:"rgba(167,139,250,0.15)",ec:"rgba(167,139,250,0.15)",cat:"dark"},',
' {n:"暗夜绿",a:"#22c55e",l:"#4ade80",d:"#16a34a",ar:"34,197,94",alr:"74,222,128",cb:"#080c0a",gc:"rgba(255,255,255,0.08)",nb:"#0f1a14",nc:"rgba(74,222,128,0.12)",ec:"rgba(74,222,128,0.12)",cat:"dark"},',
' {n:"赛博朋克",a:"#f472b6",l:"#fb923c",d:"#e11d48",ar:"244,114,182",alr:"251,146,60",cb:"#0a0a14",gc:"rgba(255,255,255,0.08)",nb:"#14142a",nc:"rgba(244,114,182,0.15)",ec:"rgba(244,114,182,0.15)",cat:"dark"},',
' {n:"暖棕复古",a:"#d97706",l:"#f59e0b",d:"#b45309",ar:"217,119,6",alr:"245,158,11",cb:"#0f0c08",gc:"rgba(255,255,255,0.08)",nb:"#1c160e",nc:"rgba(245,158,11,0.12)",ec:"rgba(245,158,11,0.12)",cat:"dark"},',
' {n:"极简白",a:"#6366f1",l:"#818cf8",d:"#4f46e5",ar:"99,102,241",alr:"129,140,248",cb:"#f5f5f0",gc:"rgba(0,0,0,0.06)",nb:"#ffffff",nc:"rgba(99,102,241,0.12)",ec:"rgba(0,0,0,0.08)",cat:"light"},',
' {n:"灰银",a:"#6b7280",l:"#9ca3af",d:"#4b5563",ar:"107,114,128",alr:"156,163,175",cb:"#e8e8e5",gc:"rgba(0,0,0,0.06)",nb:"#f0f0ed",nc:"rgba(0,0,0,0.1)",ec:"rgba(0,0,0,0.08)",cat:"light"},',
' {n:"暖白",a:"#d97706",l:"#f59e0b",d:"#b45309",ar:"217,119,6",alr:"245,158,11",cb:"#f0ebe3",gc:"rgba(0,0,0,0.06)",nb:"#faf5ed",nc:"rgba(217,119,6,0.1)",ec:"rgba(0,0,0,0.08)",cat:"light"},',
' {n:"高对比",a:"#ffffff",l:"#e0e0e0",d:"#ffffff",ar:"255,255,255",alr:"224,224,224",cb:"#000000",gc:"rgba(255,255,255,0.15)",nb:"#1a1a1a",nc:"rgba(255,255,255,0.2)",ec:"rgba(255,255,255,0.2)",cat:"high"},',
' {n:"高对比蓝",a:"#00bfff",l:"#87ceeb",d:"#00bfff",ar:"0,191,255",alr:"135,206,235",cb:"#000000",gc:"rgba(0,191,255,0.1)",nb:"#0a0a14",nc:"rgba(0,191,255,0.2)",ec:"rgba(0,191,255,0.2)",cat:"high"},',
' ];',
' var _ltTheme=JSON.parse(localStorage.getItem("_lt_theme")||"null")||_ltThemePresets[0];',
' if(!_ltTheme.cb){_ltTheme.cb=_ltThemePresets[0].cb;_ltTheme.gc=_ltThemePresets[0].gc;_ltTheme.nb=_ltThemePresets[0].nb;_ltTheme.nc=_ltThemePresets[0].nc;_ltTheme.ec=_ltThemePresets[0].ec;}',
' function _ltApplyTheme(t){',
' var r=document.documentElement;',
' r.style.setProperty("--accent",t.a);',
' r.style.setProperty("--accent-light",t.l);',
' r.style.setProperty("--accent-dark",t.d);',
' r.style.setProperty("--accent-rgb",t.ar);',
' r.style.setProperty("--accent-light-rgb",t.alr);',
' r.style.setProperty("--canvas-bg",t.cb);',
' r.style.setProperty("--node-bg",t.nb);',
' r.style.setProperty("--border-color",t.nc);',
' r.style.setProperty("--edge-color",t.ec);',
' _ltTheme=t;',
' try{localStorage.setItem("_lt_theme",JSON.stringify(t));}catch(e){}',
' try{document.getElementById("ltp-theme-preview").style.background=t.l;}catch(e){}',
' try{var _e=document.querySelectorAll(".react-flow__renderer,.react-flow");for(var _i=0;_i<_e.length;_i++)_e[_i].style.backgroundColor=t.cb;}catch(e){}',
' }',
' _ltApplyTheme(_ltTheme);',
' setTimeout(function(){try{var _e=document.querySelectorAll(".react-flow__renderer,.react-flow");for(var _i=0;_i<_e.length;_i++)_e[_i].style.backgroundColor=_ltTheme.cb;}catch(e){}},500);',
' var _ltPActiveTab="templates",_ltPCat="",_ltAISource=null,_ltBodyOrigMinH="";',
' function _ltPromptPanel(anchor){',
' if(_ltPActiveTab==="settings")_ltPActiveTab="templates";',
' var el=document.getElementById("libtv-prompt");',
' if(el){el.remove();return;}',
' function savePrompts(){try{localStorage.setItem("_lt_prompts",JSON.stringify(_ltPrompts));}catch(e){}}',
' function renderBody(){',
' var body=document.getElementById("ltp-body"); if(!body)return;',
' if(_ltPActiveTab==="templates"){',
' var cats={};',
' _ltPrompts.forEach(function(p){if(!cats[p.category])cats[p.category]=0;cats[p.category]++;});',
' var catKeys=Object.keys(cats);',
' var filtered= _ltPCat ? _ltPrompts.filter(function(p){return p.category===_ltPCat;}) : _ltPrompts;',
' var h=\'<div class="ltp-cat"><button class="ltp-cat-btn\'+(!_ltPCat?" active":"")+\'" data-cat="">全部</button>\';',
' catKeys.forEach(function(c){h+=\'<button class="ltp-cat-btn\'+(c===_ltPCat?" active":"")+\'" data-cat="\'+_ltEsc(c)+\'">\'+_ltEsc(c)+\' (\'+cats[c]+\')</button>\';});',
' h+="</div>";',
' if(!filtered.length){h+=\'<div class="ltp-empty">暂无模板,点击右上角 + 添加</div>\';}',
' else{',
' filtered.forEach(function(p){',
' h+=\'<div class="ltp-item" data-id="\'+p.id+\'">\'',
' +\'<div><div class="ltp-name">\'+_ltEsc(p.name)+\'</div>\'',
' +\'<div class="ltp-preview">\'+_ltEsc(p.content.slice(0,60))+\'</div></div>\'',
' +\'<div class="ltp-actions">\'',
' +\'<button class="ltp-btn ltp-btn-primary ltp-btn-sm" data-action="copy" data-id="\'+p.id+\'">复制</button>\'',
' +\'<button class="ltp-btn ltp-btn-ghost ltp-btn-sm" data-action="edit" data-id="\'+p.id+\'">编辑</button>\'',
' +\'<button class="ltp-btn ltp-btn-danger ltp-btn-sm" data-action="del" data-id="\'+p.id+\'">×</button>\'',
' +\'</div></div>\';',
' });',
' }',
' body.innerHTML=h;',
' body.querySelectorAll(".ltp-cat-btn").forEach(function(b){b.onclick=function(){_ltPCat=this.getAttribute("data-cat")||"";renderBody();};});',
' body.querySelectorAll("[data-action=copy]").forEach(function(b){b.onclick=function(){var id=b.getAttribute("data-id"),p=_ltPrompts.find(function(x){return x.id===id;});if(!p)return;var m,pairs=[],re=/\\{(\\w+)(?:=([^}]*))?\\}/g;while((m=re.exec(p.content))!==null)pairs.push({n:m[1],d:m[2]||""});if(!pairs.length){navigator.clipboard.writeText(p.content).then(function(){b.textContent="✅";setTimeout(function(){b.textContent="复制";},1200);});return;}var overlay=document.createElement("div");overlay.className="ltp-var-overlay";var html=\'<div class="ltp-var-title">\'+_ltEsc(p.name)+\'</div><div class="ltp-var-sub">填写变量后点击确认,替换结果将复制到剪贴板</div>\';pairs.forEach(function(v){html+=\'<div class="ltp-var-row"><label>\'+v.n+\'</label><input class="ltp-var-inp" data-var="\'+v.n+\'" value="\'+_ltEsc(v.d)+\'"></div>\';});html+=\'<div class="ltp-var-preview" id="ltp-var-ovprev">\'+_ltEsc(p.content)+\'</div><div class="ltp-var-actions"><button class="ltp-btn ltp-btn-ghost" id="ltp-var-cancel">取消</button><button class="ltp-btn ltp-btn-primary" id="ltp-var-ok">填充并复制</button></div></div>\';overlay.innerHTML=html;_ltBodyOrigMinH=body.style.minHeight||"";body.style.minHeight="320px";body.appendChild(overlay);function _clean(){if(overlay.parentNode)overlay.parentNode.removeChild(overlay);body.style.minHeight=_ltBodyOrigMinH;}function _upd(){var r=p.content;overlay.querySelectorAll(".ltp-var-inp").forEach(function(i){r=r.replace(new RegExp("\\\\{"+i.getAttribute("data-var")+"(?:=[^}]*)?\\\\}","g"),i.value||i.getAttribute("data-var"));});overlay.querySelector("#ltp-var-ovprev").textContent=r;}overlay.querySelectorAll(".ltp-var-inp").forEach(function(i){i.addEventListener("input",_upd);});overlay.querySelector("#ltp-var-cancel").onclick=function(){_clean();};overlay.querySelector("#ltp-var-ok").onclick=function(){var r=p.content;overlay.querySelectorAll(".ltp-var-inp").forEach(function(i){r=r.replace(new RegExp("\\\\{"+i.getAttribute("data-var")+"(?:=[^}]*)?\\\\}","g"),i.value);});navigator.clipboard.writeText(r).then(function(){b.textContent="✅";setTimeout(function(){b.textContent="复制";},1200);_clean();}).catch(function(){_clean();});};};});',
' body.querySelectorAll("[data-action=edit]").forEach(function(b){b.onclick=function(){var id=this.getAttribute("data-id"),p=_ltPrompts.find(function(x){return x.id===id;});if(!p)return;var nn=prompt("名称:",p.name);if(nn===null)return;var cc=prompt("内容:",p.content);if(cc===null)return;var cat=prompt("分类:",p.category);if(cat===null)return;p.name=nn;p.content=cc;p.category=cat||"通用";savePrompts();renderBody();};});',
' body.querySelectorAll("[data-action=del]").forEach(function(b){b.onclick=function(){var id=this.getAttribute("data-id");_ltPrompts=_ltPrompts.filter(function(x){return x.id!==id;});savePrompts();renderBody();};});',
' }',
' else if(_ltPActiveTab==="ai"){',
' var api=_ltPromptAPI;',
' body.innerHTML=\'<div style="margin-bottom:8px;color:rgba(255,255,255,0.5);font-size:11px;">输入或修改提示词,AI 将帮你润色/扩写</div>\'',
' +\'<textarea id="ltp-ai-input" placeholder="在此输入提示词..."></textarea>\'',
' +\'<div style="display:flex;gap:6px;margin-top:8px;">\'',
' +\'<button class="ltp-btn ltp-btn-primary" id="ltp-ai-zh">🇨🇳 中文增强</button>\'',
' +\'<button class="ltp-btn ltp-btn-primary" id="ltp-ai-en">🇺🇸 English Enhance</button>\'',
' +\'<button class="ltp-btn ltp-btn-ghost" id="ltp-ai-fill">从输入框获取</button>\'',
' +\'<button class="ltp-btn ltp-btn-ghost" id="ltp-ai-clear">清空</button>\'',
' +\'</div>\'',
' +\'<div id="ltp-ai-result" style="margin-top:8px;padding:8px 10px;border-radius:6px;background:rgba(255,255,255,0.03);min-height:30px;font-size:12px;color:#aaa;white-space:pre-wrap;word-break:break-all;-webkit-user-select:text;user-select:text;"></div>\'',
' +\'<div class="ltp-status" id="ltp-ai-status">\'+(api.url?"已配置 "+api.url:"未配置 API,请在⚙设置中配置")+\'</div>\';',
' document.getElementById("ltp-ai-fill").onclick=function(){',
' var candidates=[],best=null;',
' document.querySelectorAll("textarea").forEach(function(t){if(t.offsetParent!==null)candidates.push({el:t,val:t.value});});',
' document.querySelectorAll("input[type=text]").forEach(function(t){if(t.offsetParent!==null)candidates.push({el:t,val:t.value});});',
' document.querySelectorAll("[contenteditable=true]").forEach(function(t){if(t.offsetParent!==null)candidates.push({el:t,val:t.textContent||""});});',
' candidates.forEach(function(c){if(c.val.trim()&&(!best||c.val.length>best.val.length))best=c;});',
' document.getElementById("ltp-ai-input").value=best?best.val:"";',
' _ltAISource=best?best.el:null;',
' document.getElementById("ltp-ai-status").textContent=_ltAISource?"✅ 已绑定源输入框,增强结果点击即可写入":"⚠ 未找到可见输入框";',
' };',
' document.getElementById("ltp-ai-clear").onclick=function(){document.getElementById("ltp-ai-input").value="";document.getElementById("ltp-ai-result").textContent="";};',
' var _ltDoAI=function(text,btn,sysPrompt,langLabel){',
' var api=_ltPromptAPI;',
' if(!api.url||!api.key){document.getElementById("ltp-ai-status").textContent="❌ 请先在⚙设置中配置 API";btn.textContent=langLabel;btn.disabled=false;return;}',
' fetch(api.url,{',
' method:"POST",',
' headers:{"Content-Type":"application/json","Authorization":"Bearer "+api.key},',
' body:JSON.stringify({model:api.model||"deepseek-v4-flash",messages:[{role:"system",content:sysPrompt},{role:"user",content:text}],max_tokens:1000})',
' }).then(function(r){return r.json();}).then(function(d){',
' var result=d.choices&&d.choices[0]&&d.choices[0].message?d.choices[0].message.content:JSON.stringify(d);',
' document.getElementById("ltp-ai-result").textContent=result;',
' document.getElementById("ltp-ai-result").style.cursor="pointer";',
' if(_ltAISource){',
' document.getElementById("ltp-ai-status").textContent="✅ 完成,点击结果直接写回节点";',
' document.getElementById("ltp-ai-result").onclick=function(){',
' try{',
' if(_ltAISource.tagName==="TEXTAREA"||_ltAISource.tagName==="INPUT"){_ltAISource.value=result;_ltAISource.dispatchEvent(new Event("input",{bubbles:true}));}',
' else if(_ltAISource.isContentEditable){_ltAISource.textContent=result;_ltAISource.dispatchEvent(new Event("input",{bubbles:true}));}',
' document.getElementById("ltp-ai-status").textContent="✅ ✅ 已写回节点";',
' }catch(ex){document.getElementById("ltp-ai-status").textContent="❌ 写入失败: "+ex.message;}',
' };',
' }else{',
' document.getElementById("ltp-ai-status").textContent="✅ 完成,点击结果可复制";',
' document.getElementById("ltp-ai-result").onclick=function(){',
' var sel=window.getSelection();var r=document.createRange();r.selectNodeContents(this);sel.removeAllRanges();sel.addRange(r);',
' try{var ok=document.execCommand("copy");if(ok){sel.removeAllRanges();document.getElementById("ltp-ai-status").textContent="✅ ✅ 已复制到剪贴板";return;}}catch(e){}',
' document.getElementById("ltp-ai-status").textContent="✅ 文本已选中,请按 Ctrl+C";',
' };',
' }',
' btn.textContent=langLabel; btn.disabled=false;',
' }).catch(function(err){',
' document.getElementById("ltp-ai-status").textContent="❌ 请求失败: "+err.message;',
' btn.textContent=langLabel; btn.disabled=false;',
' });',
' };',
' document.getElementById("ltp-ai-zh").onclick=function(){',
' var text=document.getElementById("ltp-ai-input").value.trim();',
' if(!text)return;',
' var btn=this; btn.textContent="处理中..."; btn.disabled=true;',
' _ltDoAI(text,btn,"你是一个提示词工程专家。请优化并扩展用户的 AI 图像/视频生成提示词,保持简洁的同时补充光影、构图、风格、氛围等细节。请务必用中文回复,只输出中文提示词,不要输出英文。","🇨🇳 中文增强");',
' };',
' document.getElementById("ltp-ai-en").onclick=function(){',
' var text=document.getElementById("ltp-ai-input").value.trim();',
' if(!text)return;',
' var btn=this; btn.textContent="Processing..."; btn.disabled=true;',
' _ltDoAI(text,btn,"You are a prompt engineering expert. Improve and expand the user\'s prompt for AI image/video generation. Keep it concise but add details about lighting, composition, style, and atmosphere. Output only the enhanced prompt, no explanations.","🇺🇸 English Enhance");',
' };',
' }',
' else if(_ltPActiveTab==="theme"){',
' function _ltRenderTheme(){',
' var cats=[["dark","\\u6df1\\u8272\\u7cfb"],["light","\\u6d45\\u8272\\u7cfb"],["high","\\u9ad8\\u5bf9\\u6bd4"]],html="";',
' cats.forEach(function(c){',
' var items=_ltThemePresets.filter(function(t){return t.cat===c[0];});',
' if(!items.length)return;',
' html+=\'<div style="margin-top:10px;font-size:10px;color:rgba(255,255,255,0.25);letter-spacing:0.04em;margin-bottom:4px;">\'+c[1]+\'</div>\';',
' html+=\'<div style="display:flex;flex-wrap:wrap;gap:6px;">\';',
' items.forEach(function(t,i){',
' var idx=_ltThemePresets.indexOf(t);',
' var sel=t.a===_ltTheme.a&&t.cb===_ltTheme.cb?"2px solid var(--accent-light)":"1px solid rgba(255,255,255,0.06)";',
' html+=\'<button class="ltp-theme-preset" data-idx="\'+idx+\'" style="width:76px;height:50px;border-radius:8px;border:\'+sel+\';cursor:pointer;padding:0;overflow:hidden;position:relative;transition:all .12s;background:\'+t.nb+\';display:flex;flex-direction:column;">\'',
' +\'<div style="height:6px;background:\'+t.a+\';flex-shrink:0;"></div>\'',
' +\'<div style="flex:1;display:flex;align-items:center;justify-content:center;font-size:9px;color:rgba(255,255,255,0.4);overflow:hidden;">\'+t.n+\'</div>\'',
' +\'</button>\';',
' });',
' html+=\'</div>\';',
' });',
' html+=\'<div style="margin-top:12px;display:flex;gap:6px;"><button class="lt-settings-btn lt-settings-btn-ghost lt-settings-btn-sm" id="ltp-theme-reset">\\u91cd\\u7f6e\\u4e3a\\u9884\\u8bbe</button></div>\';',
' body.innerHTML=html;',
' body.querySelectorAll(".ltp-theme-preset").forEach(function(b){',
' b.onclick=function(){',
' var idx=parseInt(this.getAttribute("data-idx")),t=_ltThemePresets[idx];',
' _ltApplyTheme(t);',
' _ltRenderTheme();',
' };',
' });',
' document.getElementById("ltp-theme-reset").onclick=function(){',
' var t=_ltThemePresets[0];',
' _ltApplyTheme(t);',
' _ltRenderTheme();',
' };',
' }',
' _ltRenderTheme();',
' }',
' else if(_ltPActiveTab==="palette"){',
' var _presets={',
' "电影色调":["#2c1e30","#4a2c4a","#c9a227","#e8d5b7","#1a3a4a","#2d5a7b","#8b4513","#cd853f"],',
' "赛博朋克":["#ff00ff","#00ffff","#ff1493","#00bfff","#ff6ec7","#7b68ee","#ff4500","#1c1c3c"],',
' "莫兰迪":["#b5c4b1","#e8e0d4","#c9b8a8","#a8b5c4","#d4c5b9","#b9c4d4","#c4b5b1","#d4d0c5"],',
' "马卡龙":["#ffb3ba","#bae1ff","#baffc9","#ffffba","#e8baff","#baffee","#ffd1ba","#d4baff"],',
' "暖色系":["#ff6b35","#f7c59f","#efefd0","#ffb4a2","#e5989b","#b5838d","#6d6875","#ffcdb2"],',
' "冷色系":["#023e8a","#0077b6","#0096c7","#00b4d8","#48cae4","#90e0ef","#ade8f4","#caf0f8"],',
' "黑白灰":["#000000","#1a1a1a","#333333","#666666","#999999","#cccccc","#e5e5e5","#ffffff"],',
' "高饱和":["#ff0000","#ff8800","#ffff00","#00ff00","#0088ff","#8800ff","#ff00ff","#00ffff"],',
' "低饱和":["#8b7d72","#a0937e","#b8a99a","#c4b7a6","#d1c4b0","#e0d6c8","#ebe3d7","#f5f0e8"]',
' };',
' function _hex2rgb(h){h=h.replace("#","");return[parseInt(h.slice(0,2),16),parseInt(h.slice(2,4),16),parseInt(h.slice(4,6),16)];}',
' function _rgb2hsl(r,g,b){r/=255;g/=255;b/=255;var mx=Math.max(r,g,b),mn=Math.min(r,g,b),h,s,l=(mx+mn)/2;if(mx===mn){h=s=0;}else{var d=mx-mn;s=l>0.5?d/(2-mx-mn):d/(mx+mn);switch(mx){case r:h=((g-b)/d+(g<b?6:0))/6;break;case g:h=((b-r)/d+2)/6;break;case b:h=((r-g)/d+4)/6;break;}}return[Math.round(h*360),Math.round(s*100),Math.round(l*100)];}',
' function _aiDesc(hex){var r=_hex2rgb(hex),hsl=_rgb2hsl(r[0],r[1],r[2]);var h=hsl[0],s=hsl[1],l=hsl[2];var desc="";if(l<15)desc="very dark";else if(l<35)desc="dark";else if(l<65)desc="mid-tone";else if(l<85)desc="light";else desc="very light";if(s<10)desc+=", almost gray";else if(s<30)desc+=", muted";else if(s<60)desc+=", moderate saturation";else desc+=", highly saturated";var hue="";if(h<15||h>=345)hue="red";else if(h<45)hue="orange";else if(h<70)hue="yellow";else if(h<160)hue="green";else if(h<200)hue="cyan";else if(h<260)hue="blue";else if(h<310)hue="purple";else hue="pink";return desc+" "+hue+" ("+hex+")";}',
' var _recent=JSON.parse(localStorage.getItem("_lt_pal_recent")||"[]");',
' function _saveRecent(c){_recent=_recent.filter(function(x){return x!==c;});_recent.unshift(c);if(_recent.length>20)_recent.pop();try{localStorage.setItem("_lt_pal_recent",JSON.stringify(_recent));}catch(e){}}',
' function _copySwatch(el,color){navigator.clipboard.writeText(color).then(function(){el.classList.add("copied");setTimeout(function(){el.classList.remove("copied");},800);var toast=document.createElement("div");toast.className="ltp-pal-toast show";toast.textContent="Copied "+color.toUpperCase();document.body.appendChild(toast);setTimeout(function(){toast.classList.remove("show");setTimeout(function(){toast.remove();},300);},1200);_saveRecent(color);});}',
' function _renderPalette(){',
' var h=\'<div class="ltp-pal-picker"><input type="color" id="ltp-pal-pick" value="#818cf8"><div class="ltp-pal-info"><div class="ltp-pal-hex" id="ltp-pal-hex">#818CF8</div><div class="ltp-pal-rgb" id="ltp-pal-rgb">rgb(129, 140, 248)</div><div class="ltp-pal-hsl" id="ltp-pal-hsl">hsl(235, 91%, 74%)</div></div></div>\';',
' h+=\'<div class="ltp-pal-ai"><div class="ltp-pal-ai-desc" id="ltp-pal-ai-desc">muted blue (#818cf8)</div><button class="ltp-btn ltp-btn-primary ltp-btn-sm" id="ltp-pal-ai-copy">复制AI描述</button></div>\';',
' h+=\'<div class="ltp-pal-section"><div class="ltp-pal-section-title open">我的收藏</div><div class="ltp-pal-section-body" id="ltp-pal-fav"></div><button class="ltp-btn ltp-btn-ghost ltp-btn-sm" id="ltp-pal-add-fav" style="margin-top:6px;">+ 添加当前颜色</button></div>\';',
' if(_recent.length){',
' h+=\'<div class="ltp-pal-section"><div class="ltp-pal-section-title">最近使用</div><div class="ltp-pal-section-body collapsed">\',',
' _recent.slice(0,16).forEach(function(c){',
' h+=\'<div class="ltp-pal-swatch" style="background:\'+c+\'" data-color="\'+c+\'"><div class="ltp-pal-tip">\'+c+\'</div></div>\';',
' });',
' h+=\'</div></div>\';',
' }',
' Object.keys(_presets).forEach(function(name){',
' h+=\'<div class="ltp-pal-section"><div class="ltp-pal-section-title" data-group="\'+name+\'">\'+name+\'</div><div class="ltp-pal-section-body collapsed" data-body="\'+name+\'">\';',
' _presets[name].forEach(function(c){',
' h+=\'<div class="ltp-pal-swatch" style="background:\'+c+\'" data-color="\'+c+\'"><div class="ltp-pal-tip">\'+c+\'</div></div>\';',
' });',
' h+=\'</div></div>\';',
' });',
' body.innerHTML=h;',
' var _fav=JSON.parse(localStorage.getItem("_lt_pal_fav")||"[]");',
' function _renderFav(){var fb=document.getElementById("ltp-pal-fav");if(!fb)return;fb.innerHTML="";_fav.forEach(function(c,i){var s=document.createElement("div");s.className="ltp-pal-swatch";s.style.background=c;s.setAttribute("data-color",c);s.innerHTML=\'<div class="ltp-pal-tip">\'+_ltEsc(c)+\'</div>\';s.onclick=function(){_copySwatch(s,c);_updPicker(c);};fb.appendChild(s);});}',
' _renderFav();',
' function _updPicker(hex){document.getElementById("ltp-pal-pick").value=hex;document.getElementById("ltp-pal-hex").textContent=hex.toUpperCase();var rgb=_hex2rgb(hex);document.getElementById("ltp-pal-rgb").textContent="rgb("+rgb.join(", ")+")";var hsl=_rgb2hsl(rgb[0],rgb[1],rgb[2]);document.getElementById("ltp-pal-hsl").textContent="hsl("+hsl[0]+", "+hsl[1]+"%, "+hsl[2]+"%)";document.getElementById("ltp-pal-ai-desc").textContent=_aiDesc(hex);}',
' document.getElementById("ltp-pal-pick").oninput=function(){_updPicker(this.value);};',
' body.querySelectorAll(".ltp-pal-swatch").forEach(function(s){s.onclick=function(){var c=this.getAttribute("data-color");_copySwatch(s,c);_updPicker(c);};});',
' body.querySelectorAll(".ltp-pal-section-title").forEach(function(t){t.onclick=function(){var b=this.nextElementSibling;if(b)b.classList.toggle("collapsed");this.classList.toggle("open");};});',
' document.getElementById("ltp-pal-hex").onclick=function(){var v=this.textContent;navigator.clipboard.writeText(v);var toast=document.createElement("div");toast.className="ltp-pal-toast show";toast.textContent="Copied "+v;document.body.appendChild(toast);setTimeout(function(){toast.classList.remove("show");setTimeout(function(){toast.remove();},300);},1200);};',
' document.getElementById("ltp-pal-rgb").onclick=function(){var v=this.textContent;navigator.clipboard.writeText(v);var toast=document.createElement("div");toast.className="ltp-pal-toast show";toast.textContent="Copied "+v;document.body.appendChild(toast);setTimeout(function(){toast.classList.remove("show");setTimeout(function(){toast.remove();},300);},1200);};',
' document.getElementById("ltp-pal-hsl").onclick=function(){var v=this.textContent;navigator.clipboard.writeText(v);var toast=document.createElement("div");toast.className="ltp-pal-toast show";toast.textContent="Copied "+v;document.body.appendChild(toast);setTimeout(function(){toast.classList.remove("show");setTimeout(function(){toast.remove();},300);},1200);};',
' document.getElementById("ltp-pal-ai-copy").onclick=function(){var v=document.getElementById("ltp-pal-ai-desc").textContent;navigator.clipboard.writeText(v);var toast=document.createElement("div");toast.className="ltp-pal-toast show";toast.textContent="Copied AI描述";document.body.appendChild(toast);setTimeout(function(){toast.classList.remove("show");setTimeout(function(){toast.remove();},300);},1200);};',
' document.getElementById("ltp-pal-add-fav").onclick=function(){var hex=document.getElementById("ltp-pal-pick").value;if(!_fav.includes(hex)){_fav.push(hex);try{localStorage.setItem("_lt_pal_fav",JSON.stringify(_fav));}catch(e){}_renderFav();}};',
' }',
' _renderPalette();',
' }',
' else if(_ltPActiveTab==="settings"){',
' var existing=document.getElementById("lt-settings");',
' if(existing){existing.remove();return;}',
' var p=document.getElementById("libtv-prompt");',
' if(p)p.remove();',
' _ltSettingsPanel();',
' return;',
' }',
' }',
' var div=document.createElement("div");',
' div.id="libtv-prompt";',
' div.innerHTML=\'<div class="ltp-head"><h3>提示词工具</h3><span class="ltp-close" id="ltp-close">✕</span></div>\'',
' +\'<div class="ltp-tabs"><span class="ltp-tab active" data-tab="templates">模板</span><span class="ltp-tab" data-tab="palette">调色</span><span class="ltp-tab" data-tab="ai">AI 增强</span><span class="ltp-tab" data-tab="theme">主题</span><span class="ltp-tab" data-tab="settings">设置</span></div>\'',
' +\'<div id="ltp-body" class="ltp-body"></div>\'',
' +\'<div style="display:flex;gap:6px;padding:8px 16px 12px;border-top:1px solid rgba(129,140,248,0.12);">\'',
' +\'<button class="ltp-btn ltp-btn-primary ltp-btn-sm" id="ltp-add">+ 新增模板</button>\'',
' +\'<button class="ltp-btn ltp-btn-ghost ltp-btn-sm" id="ltp-reset">恢复默认模板</button>\'',
' +\'</div>\';',
' document.body.appendChild(div);',
' if(!anchor||!anchor.getBoundingClientRect){',
' div.style.left="50%"; div.style.top="50%";',
' div.style.transform="translate(-50%,-50%)";',
' }',
' renderBody();',
' div.addEventListener("mousemove",function(e){',
' var items=div.querySelectorAll(".ltp-item");',
' items.forEach(function(it){',
' var r=it.getBoundingClientRect();',
' it.style.setProperty("--mx",(e.clientX-r.left)+"px");',
' it.style.setProperty("--my",(e.clientY-r.top)+"px");',
' });',
' });',
' document.getElementById("ltp-close").onclick=function(){div.remove();};',
' document.getElementById("ltp-add").onclick=function(){',
' var nn=prompt("模板名称:"); if(nn===null)return;',
' var cc=prompt("提示词内容:"); if(cc===null)return;',
' var cat=prompt("分类(如:图像/视频/通用):")||"通用";',
' _ltPrompts.push({id:"p"+Date.now(),name:nn,content:cc,category:cat});',
' savePrompts(); renderBody();',
' };',
' document.getElementById("ltp-reset").onclick=function(){',
' if(!confirm("恢复默认模板将覆盖当前所有模板,确认?"))return;',
' _ltPrompts=[',
' {id:"d1",name:"产品摄影",category:"图像",content:"Product photography on {background=white} background, {lighting=studio lighting}, high detail, 8K, sharp focus, {extra}"},',
' {id:"d2",name:"电影镜头",category:"图像",content:"Cinematic shot, {lens=anamorphic} lens, {lighting=dramatic} lighting, shallow depth of field, {style}"},',
' {id:"d3",name:"动画-吉卜力风",category:"图像",content:"Studio Ghibli style, hand-drawn animation, {palette=soft pastel} colors, {atmosphere=whimsical}"},',
' {id:"d4",name:"产品展示-环绕",category:"视频",content:"Smooth 360 orbit around {subject=product}, {lighting=soft studio} lighting, slow motion, {extra}"},',
' {id:"d5",name:"风光-延时",category:"视频",content:"Timelapse, {time=golden hour}, {sky=dramatic clouds}, warm tones, smooth transition, {extra}"},',
' ];',
' savePrompts(); renderBody();',
' };',
' div.querySelectorAll(".ltp-tab").forEach(function(t){t.onclick=function(){_ltPActiveTab=this.getAttribute("data-tab");div.querySelectorAll(".ltp-tab").forEach(function(x){x.classList.toggle("active",x===t);});renderBody();};});',
' window._ltPromptRefresh=function(){var d=document.getElementById("libtv-prompt");if(d){_ltPrompts=JSON.parse(localStorage.getItem("_lt_prompts")||"[]");renderBody();}};',
' }',
/* ———— 标签系统 ———— */
' var _ltTagLibs=JSON.parse(localStorage.getItem("_lt_tag_libs")||"null");',
' if(!_ltTagLibs){',
' _ltTagLibs={"默认标签":{categories:[',
' {name:"常规标签",icon:"⭐",groups:[',
' {name:"画质",open:true,items:["杰作","写实","提高质量","最佳质量","高分辨率","超高分辨率","超高清","更多细节","简单背景","模糊背景","清晰背景","清晰细节","超精细绘画","聚焦清晰","物理渲染","极详细刻画","改善细节","添加鲜艳色彩","扫描"]},',
' {name:"负面标签",open:false,items:["低质量","模糊","畸形","多余手指","水印","签名","丑陋","变形","低分辨率","噪点","抖动","糟糕构图","文本","拼贴","多余的文字"]},',
' {name:"摄影",open:false,items:["摄影","单反","胶片颗粒","移轴","长曝光","微距摄影","人像摄影","风景摄影"]},',
' {name:"光影",open:false,items:["工作室光照","戏剧性光照","柔光","黄金时刻","霓虹灯光","轮廓光","体积光","电影光照"]},',
' {name:"构图",open:false,items:["特写","广角","鸟瞰","低角度","对称构图","三分法","居中构图","前景"]}',
' ]},',
' {name:"艺术题材",icon:"🎨",groups:[',
' {name:"题材",open:false,items:["奇幻","科幻","赛博朋克","蒸汽朋克","水墨","浮世绘","像素艺术","低多边形","超现实主义","复古"]}',
' ]},',
' {name:"人物类",icon:"👤",groups:[',
' {name:"人物",open:false,items:["女孩","男孩","少女","少年","女人","男人","老者","儿童","多人","角色设计","五官精致","红发","蓝眼"]}',
' ]},',
' {name:"场景",icon:"🏞",groups:[',
' {name:"场景",open:false,items:["城市","森林","山脉","海滩","星空","室内","废墟","花园","雪景","夜景","雨天"]}',
' ]}',
' ]}};',
' try{localStorage.setItem("_lt_tag_libs",JSON.stringify(_ltTagLibs));}catch(e){}',
' }',
' var _ltCurLib=localStorage.getItem("_lt_cur_lib")||"默认标签";',
' if(!_ltTagLibs[_ltCurLib])_ltCurLib=Object.keys(_ltTagLibs)[0];',
' var _ltTagActiveCat=0;',
' var _ltTagSearch="";',
' var _ltRecentTags=JSON.parse(localStorage.getItem("_lt_recent")||"[]");',
' var _ltTagMenuEl=null,_ltTagInputEl=null;',
' function _ltCurLibCats(){var l=_ltTagLibs[_ltCurLib];return l&&l.categories?l.categories:[];}',
' function _ltCurCatGroups(){var c=_ltCurLibCats()[_ltTagActiveCat];return c&&c.groups?c.groups:[];}',
' function _ltSaveLibs(){try{localStorage.setItem("_lt_tag_libs",JSON.stringify(_ltTagLibs));localStorage.setItem("_lt_cur_lib",_ltCurLib);}catch(e){}}',
' window._ltTagRefresh=function(){var s=localStorage.getItem("_lt_tag_libs");if(s){try{_ltTagLibs=JSON.parse(s);}catch(e){}}if(!_ltTagLibs[_ltCurLib])_ltCurLib=Object.keys(_ltTagLibs)[0];if(_ltTagMenuEl)_ltRenderTagMenu();};',
' function _ltPushRecent(t){t=String(t);if(!t)return;_ltRecentTags=_ltRecentTags.filter(function(x){return x!==t;});_ltRecentTags.push(t);if(_ltRecentTags.length>40)_ltRecentTags=_ltRecentTags.slice(-40);try{localStorage.setItem("_lt_recent",JSON.stringify(_ltRecentTags));}catch(e){}if(_ltTagMenuEl&&_ltTagActiveCat>=_ltCurLibCats().length)_ltRenderTagMenu();}',
' function _ltInsertTagAtCursor(tagText){',
' var ta=_ltTagInputEl; if(!ta)return;',
' if(ta.tagName==="TEXTAREA"||(ta.tagName==="INPUT"&&ta.type==="text")){',
' var start=ta.selectionStart,end=ta.selectionEnd,val=ta.value;',
' var before=val.slice(0,start);',
' var sep=(before.length>0&&!/[\\s,,]$/.test(before))?", ":"";',
' var ins=sep+tagText;',
' var newVal=val.slice(0,start)+ins+val.slice(end);',
' var proto=ta.tagName==="TEXTAREA"?HTMLTextAreaElement.prototype:HTMLInputElement.prototype;',
' var nativeSetter=Object.getOwnPropertyDescriptor(proto,"value").set;',
' nativeSetter.call(ta,newVal);',
' var pos=start+ins.length;',
' ta.setSelectionRange(pos,pos);',
' ta.dispatchEvent(new Event("input",{bubbles:true}));',
' }else if(ta.isContentEditable){',
' var sel=window.getSelection();',
' if(!sel||!sel.rangeCount){var pre0=ta.textContent;ta.appendChild(document.createTextNode((pre0&&pre0.length?", ":"")+tagText));}',
' else{',
' var r=sel.getRangeAt(0);',
' var pr=r.cloneRange();pr.selectNodeContents(ta);pr.setEnd(r.startContainer,r.startOffset);',
' var beforeText=pr.toString();',
' var sep=(beforeText.length>0&&!/[\\s,,]$/.test(beforeText))?", ":"";',
' r.deleteContents();',
' r.insertNode(document.createTextNode(sep+tagText));',
' r.collapse(false);',
' sel.removeAllRanges();sel.addRange(r);',
' }',
' ta.dispatchEvent(new Event("input",{bubbles:true}));',
' }',
' ta.focus();',
' }',
' function _ltRenderCat(cat){',
' if(!cat)return "";',
' var h="";',
' if(_ltRecentTags.length){',
' h+="<div class=\\"lt-tag-recent\\"><div class=\\"lt-tag-recent-head\\">最近使用<span class=\\"lt-rec-clear\\">清空</span></div><div class=\\"lt-tag-grid\\">";',
' _ltRecentTags.slice(-10).reverse().forEach(function(t){var s=_ltEsc(t);h+="<div class=\\"lt-tag-item\\" data-text=\\""+s+"\\" title=\\""+s+"\\">"+s+"</div>";});',
' h+="</div></div>";',
' }',
' (cat.groups||[]).forEach(function(g,gi){',
' h+="<div class=\\"lt-tag-group\\">";',
' h+="<div class=\\"lt-tag-group-head\\" data-gi=\\""+gi+"\\"><span class=\\"lt-tag-group-name\\">"+_ltEsc(g.name)+"</span><span class=\\"lt-tag-group-actions\\"><span class=\\"lt-tag-add-item\\" data-gi=\\""+gi+"\\" title=\\"新增标签\\">+</span><span class=\\"lt-tag-arrow "+(g.open?"open":"")+"\\">▾</span></span></div>";',
' if(g.open){',
' h+="<div class=\\"lt-tag-grid\\">";',
' (g.items||[]).forEach(function(it){var s=_ltEsc(it);h+="<div class=\\"lt-tag-item\\" data-text=\\""+s+"\\" title=\\""+s+"\\">"+s+"</div>";});',
' h+="</div>";',
' }',
' h+="</div>";',
' });',
' h+="<div class=\\"lt-tag-add-group-wrap\\"><span class=\\"lt-tag-add-group\\">+ 新增分组</span></div>";',
' return h;',
' }',
' function _ltRenderSearch(){',
' var q=_ltTagSearch,h="<div class=\\"lt-tag-search-hint\\">搜索:“"+q+"”</div>",found=false;',
' _ltCurLibCats().forEach(function(cat){',
' (cat.groups||[]).forEach(function(g){',
' var ms=(g.items||[]).filter(function(it){return String(it).toLowerCase().indexOf(q)>=0;});',
' if(ms.length){',
' found=true;',
' h+="<div class=\\"lt-tag-group\\"><div class=\\"lt-tag-group-head-static\\"><span class=\\"lt-tag-group-name\\">"+_ltEsc(cat.name)+" · "+_ltEsc(g.name)+"</span></div><div class=\\"lt-tag-grid\\">";',
' ms.forEach(function(it){var s=_ltEsc(it);h+="<div class=\\"lt-tag-item\\" data-text=\\""+s+"\\" title=\\""+s+"\\">"+s+"</div>";});',
' h+="</div></div>";',
' }',
' });',
' });',
' if(!found)h+="<div class=\\"lt-tag-empty\\">无匹配标签</div>";',
' return h;',
' }',
' function _ltRenderInserted(){',
' var h="<div class=\\"lt-tag-ins-head\\">已插入<span class=\\"lt-ins-clear\\">清空</span></div>";',
' if(!_ltRecentTags.length){h+="<div class=\\"lt-tag-empty\\">还没有插入过标签</div>";return h;}',
' h+="<div class=\\"lt-tag-grid\\">";',
' _ltRecentTags.slice().reverse().forEach(function(t){var s=_ltEsc(t);h+="<div class=\\"lt-tag-item\\" data-text=\\""+s+"\\" title=\\""+s+"\\">"+s+"</div>";});',
' h+="</div>";',
' return h;',
' }',
' function _ltRenderTagMenu(){',
' if(!_ltTagMenuEl)return;',
' var cats=_ltCurLibCats();',
' var isInserted=_ltTagActiveCat>=cats.length;',
' var sel=_ltTagMenuEl.querySelector("#lt-tag-lib");',
' if(sel)sel.innerHTML=Object.keys(_ltTagLibs).map(function(n){return "<option value=\\""+_ltEsc(n)+"\\""+(_ltCurLib===n?" selected":"")+">"+_ltEsc(n)+"</option>";}).join("");',
' var tabs=_ltTagMenuEl.querySelector("#lt-tag-tabs");',
' var th="";',
' cats.forEach(function(c,i){th+="<span class=\\"lt-tag-tab"+(i===_ltTagActiveCat?" active":"")+"\\" data-cat=\\""+i+"\\">"+(c.icon?_ltEsc(c.icon)+" ":"")+_ltEsc(c.name)+"</span>";});',
' th+="<span class=\\"lt-tag-tab"+(isInserted?" active":"")+"\\" data-cat=\\"ins\\">已插入</span>";',
' th+="<span class=\\"lt-tag-add\\" id=\\"lt-tag-add-cat\\" title=\\"新增分类\\">+</span>";',
' tabs.innerHTML=th;',
' var content=_ltTagMenuEl.querySelector("#lt-tag-content");',
' if(isInserted)content.innerHTML=_ltRenderInserted();',
' else if(_ltTagSearch)content.innerHTML=_ltRenderSearch();',
' else content.innerHTML=_ltRenderCat(cats[_ltTagActiveCat]);',
' }',
' function _ltPosTagMenu(){',
' if(!_ltTagMenuEl||!_ltTagInputEl)return;',
' var mw=_ltTagMenuEl.offsetWidth||688,mh=_ltTagMenuEl.offsetHeight||420;',
' var icon=_ltTagInputEl.parentNode?_ltTagInputEl.parentNode.querySelector(".lt-tag-icon"):null;',
' var ir=icon?icon.getBoundingClientRect():_ltTagInputEl.getBoundingClientRect();',
' var l=ir.right; if(l+mw>window.innerWidth-8)l=window.innerWidth-8-mw; if(l<8)l=8;',
' var t=ir.top-mh; if(t<8)t=ir.bottom+6;',
' _ltTagMenuEl.style.left=l+"px";_ltTagMenuEl.style.top=t+"px";',
' }',
' function _ltShowTagMenu(ta){',
' _ltCloseTagMenu();',
' _ltTagInputEl=ta;',
' var div=document.createElement("div");div.className="lt-tag-menu";div.id="lt-tag-menu";',
' div.innerHTML=',
' "<div class=\\"lt-tag-header\\">"',
' +"<select class=\\"lt-tag-lib\\" id=\\"lt-tag-lib\\"></select>"',
' +"<input class=\\"lt-tag-search\\" id=\\"lt-tag-search\\" placeholder=\\"搜索标签...\\">"',
' +"<button class=\\"lt-tag-refresh\\" id=\\"lt-tag-refresh\\" title=\\"刷新/重置\\">⟳</button>"',
' +"<button class=\\"lt-tag-close\\" id=\\"lt-tag-close\\" title=\\"关闭\\">✕</button>"',
' +"</div>"',
' +"<div class=\\"lt-tag-tabs\\" id=\\"lt-tag-tabs\\"></div>"',
' +"<div class=\\"lt-tag-content\\" id=\\"lt-tag-content\\"></div>"',
' +"<div class=\\"lt-tag-resize\\" id=\\"lt-tag-resize\\" title=\\"拖拽调整大小\\"></div>";',
' document.body.appendChild(div);',
' _ltTagMenuEl=div;',
' var libSel=div.querySelector("#lt-tag-lib");',
' libSel.onchange=function(){_ltCurLib=libSel.value;_ltTagActiveCat=0;_ltSaveLibs();_ltRenderTagMenu();};',
' var search=div.querySelector("#lt-tag-search");',
' search.oninput=function(){_ltTagSearch=search.value.trim().toLowerCase();_ltRenderTagMenu();};',
' div.querySelector("#lt-tag-refresh").onclick=function(){search.value="";_ltTagSearch="";_ltTagActiveCat=0;_ltRenderTagMenu();};',
' div.querySelector("#lt-tag-close").onclick=_ltCloseTagMenu;',
' div.querySelector("#lt-tag-tabs").addEventListener("click",function(e){',
' var tab=e.target.closest(".lt-tag-tab");',
' if(tab){var v=tab.getAttribute("data-cat");_ltTagActiveCat=(v==="ins")?_ltCurLibCats().length:parseInt(v);_ltRenderTagMenu();return;}',
' var ac=e.target.closest("#lt-tag-add-cat");',
' if(ac){var n=prompt("新分类名称:");if(n&&n.trim()){_ltCurLibCats().push({name:n.trim(),icon:"",groups:[{name:"新分组",open:true,items:[]}]});_ltSaveLibs();_ltTagActiveCat=_ltCurLibCats().length-1;_ltRenderTagMenu();}}',
' });',
' div.querySelector("#lt-tag-content").addEventListener("click",function(e){',
' var item=e.target.closest(".lt-tag-item");',
' if(item){_ltInsertTagAtCursor(item.getAttribute("data-text"));_ltPushRecent(item.getAttribute("data-text"));if(_ltTagActiveCat>=_ltCurLibCats().length)_ltRenderTagMenu();return;}',
' var ai=e.target.closest(".lt-tag-add-item");',
' if(ai){var gi=parseInt(ai.getAttribute("data-gi"));var txt=prompt("新标签:");if(txt&&txt.trim()){_ltCurCatGroups()[gi].items.push(txt.trim());_ltSaveLibs();_ltRenderTagMenu();}return;}',
' var gh=e.target.closest(".lt-tag-group-head");',
' if(gh){var gi=parseInt(gh.getAttribute("data-gi"));var g=_ltCurCatGroups()[gi];if(g){g.open=!g.open;_ltSaveLibs();_ltRenderTagMenu();}return;}',
' var ag=e.target.closest(".lt-tag-add-group");',
' if(ag){var n=prompt("新分组名称:");if(n&&n.trim()){_ltCurCatGroups().push({name:n.trim(),open:true,items:[]});_ltSaveLibs();_ltRenderTagMenu();}return;}',
' var rc=e.target.closest(".lt-rec-clear");',
' if(rc){_ltRecentTags=[];try{localStorage.removeItem("_lt_recent");}catch(ex){}_ltRenderTagMenu();return;}',
' var ic=e.target.closest(".lt-ins-clear");',
' if(ic){_ltRecentTags=[];try{localStorage.removeItem("_lt_recent");}catch(ex){}_ltRenderTagMenu();return;}',
' });',
' _ltRenderTagMenu();',
' _ltPosTagMenu();',
' var rz=div.querySelector("#lt-tag-resize");',
' rz.addEventListener("mousedown",function(ev){',
' ev.preventDefault();ev.stopPropagation();',
' var sw=div.offsetWidth,sh=div.offsetHeight,sx=ev.clientX,sy=ev.clientY;',
' var left=parseInt(div.style.left)||0,top=parseInt(div.style.top)||0;',
' function mm(e){',
' var nw=Math.max(240,sw+(e.clientX-sx));',
' var nh=Math.max(160,sh+(e.clientY-sy));',
' if(left+nw>window.innerWidth-8)nw=window.innerWidth-8-left;',
' if(top+nh>window.innerHeight-8)nh=window.innerHeight-8-top;',
' div.style.width=nw+"px";div.style.height=nh+"px";div.style.maxHeight=nh+"px";',
' }',
' function mu(){document.removeEventListener("mousemove",mm);document.removeEventListener("mouseup",mu);document.body.style.userSelect="";}',
' document.addEventListener("mousemove",mm);',
' document.addEventListener("mouseup",mu);',
' document.body.style.userSelect="none";',
' });',
' }',
' function _ltCloseTagMenu(){',
' var el=document.getElementById("lt-tag-menu");if(el)el.remove();',
' _ltTagMenuEl=null;_ltTagInputEl=null;',
' }',
' /* 标签管理已移至面板内联(新增标签 / 分组 / 分类) */',
' (function(){',
' function _ltTagScan(){',
' var els=document.querySelectorAll("textarea,input[type=\\"text\\"],[contenteditable=\\"true\\"]");',
'',
' els.forEach(function(ta){',
' if(ta.offsetParent===null)return;',
' /* unified tag icon for all inputs; anchored to parent, shows/hides with input */',
' var wr=ta.parentNode;',
' if(wr&&!wr.querySelector(":scope > .lt-tag-icon")){',
' if(ta.parentNode&&!ta.parentNode.querySelector(".lt-tag-icon")){',
' var wr=ta.parentNode;',
' if(getComputedStyle(wr).position==="static")wr.style.position="relative";',
' var icon=document.createElement("div");',
' icon.className="lt-tag-icon";',
' icon.title="\\u6807\\u7b7e";',
' icon.innerHTML=\'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z"/><line x1="7" y1="7" x2="7.01" y2="7"/></svg>\';',
' icon.style.cssText="position:absolute;right:6px;bottom:6px;z-index:2147483646;width:24px;height:24px;pointer-events:auto;border-radius:6px;display:flex;align-items:center;justify-content:center;cursor:pointer;";',
' icon.onclick=function(e){e.stopPropagation();if(document.getElementById("lt-tag-menu"))_ltCloseTagMenu();else _ltShowTagMenu(ta);};',
' wr.appendChild(icon);',
' }',
' }',
' });',
' }',
' var _ltTagTimer=null;',
' var _ltTagObs=new MutationObserver(function(){',
' if(_ltTagTimer)clearTimeout(_ltTagTimer);',
' _ltTagTimer=setTimeout(_ltTagScan,100);',
' });',
' _ltTagObs.observe(document.body,{childList:true,subtree:true,attributes:true,attributeFilter:["style","class","hidden"]});',
' _ltTagScan();',
' setInterval(_ltTagScan,1500);',
' })();',
/* ———— 悬浮提示词按钮(仅画布页面) ———— */
' (function(){',
' function _createBtn(){',
' if(document.getElementById("libtv-pbtn"))return;',
' var btn=document.createElement("div");',
' btn.id="libtv-pbtn";',
' btn.title="提示词工具 (P)";',
' btn.innerHTML=\'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="16" y1="13" x2="8" y2="13"/><line x1="16" y1="17" x2="8" y2="17"/><polyline points="10 9 9 9 8 9"/></svg>\';',
' btn.style.cssText="position:fixed;right:60px;bottom:70px;z-index:99998;width:36px;height:36px;border-radius:50%;background:linear-gradient(135deg,rgba(99,102,241,0.9),rgba(79,70,229,0.9));color:#fff;display:flex;align-items:center;justify-content:center;cursor:grab;user-select:none;box-shadow:0 4px 16px rgba(99,102,241,0.25);";',
' btn.onmouseenter=function(){btn.style.transform="scale(1.08)";btn.style.boxShadow="0 6px 24px rgba(99,102,241,0.35)";};',
' btn.onmouseleave=function(){btn.style.transform="scale(1)";btn.style.boxShadow="0 4px 16px rgba(99,102,241,0.25)";};',
' document.body.appendChild(btn);',
' function _ltPosPanel(){',
' var p=document.getElementById("libtv-prompt");if(!p)return;',
' var r=btn.getBoundingClientRect(),pw=Math.min(520,window.innerWidth-32),ph=p.offsetHeight||400;',
' p.style.left=Math.max(12,Math.min(r.left+r.width/2-pw/2,window.innerWidth-pw-12))+"px";',
' var t=r.bottom+10;if(t+ph>window.innerHeight-12)t=Math.max(12,r.top-ph-10);',
' p.style.top=t+"px";p.style.transform="none";',
' }',
' function _ltToggle(){',
' var p=document.getElementById("libtv-prompt");if(p){p.remove();return;}',
' _ltPromptPanel(btn);_ltPosPanel();',
' }',
' btn.onclick=_ltToggle;',
' function _ltClamp(){var pw=36,ph=36;var l=parseInt(btn.style.left);var t=parseInt(btn.style.top);if(!isNaN(l)){l=Math.max(4,Math.min(l,window.innerWidth-pw-4));btn.style.left=l+"px";}if(!isNaN(t)){t=Math.max(4,Math.min(t,window.innerHeight-ph-4));btn.style.top=t+"px";}_ltPosPanel();}',
' var dx=0,dy=0,dragging=false;',
' btn.addEventListener("mousedown",function(e){dragging=true;dx=e.clientX-btn.offsetLeft;dy=e.clientY-btn.offsetTop;e.preventDefault();});',
' document.addEventListener("mousemove",function(e){if(!dragging)return;var pw=36,ph=36,l=e.clientX-dx,t=e.clientY-dy;l=Math.max(4,Math.min(l,window.innerWidth-pw-4));t=Math.max(4,Math.min(t,window.innerHeight-ph-4));btn.style.left=l+"px";btn.style.top=t+"px";btn.style.right="auto";btn.style.bottom="auto";_ltPosPanel();});',
' document.addEventListener("mouseup",function(){if(dragging){dragging=false;try{localStorage.removeItem("_lt_pbtn_r");localStorage.removeItem("_lt_pbtn_b");localStorage.removeItem("_lt_pbtn_x");localStorage.removeItem("_lt_pbtn_y");}catch(ex){}}});',
' window.addEventListener("resize",_ltClamp);',
' }',
' function _removeBtn(){var b=document.getElementById("libtv-pbtn");if(b)b.remove();}',
' var _obs=new MutationObserver(function(){',
' if(document.querySelector(".react-flow")){_createBtn();}',
' else{_removeBtn();}',
' });',
' _obs.observe(document.body,{childList:true,subtree:true});',
' if(document.querySelector(".react-flow")){_createBtn();}',
' })();',
/* ———— 直角连线 ———— */
' var _ltStepTo=null;',
' function _ltStepEdges(){',
' document.querySelectorAll(".react-flow__edges path").forEach(function(p){',
' var d=p.getAttribute("d")||"";',
' if(d.indexOf("C")===-1)return;',
' try{',
' var len=p.getTotalLength();',
' if(!len||isNaN(len))return;',
' var s=p.getPointAtLength(0),e=p.getPointAtLength(len);',
' p.setAttribute("d","M "+s.x+" "+s.y+" L "+e.x+" "+s.y+" L "+e.x+" "+e.y);',
' }catch(ex){}',
' });',
' }',
' var _ltStepObs=null,_ltStepRetries=0;',
' function _ltStepApply(){',
' if(_ltStepTo){clearTimeout(_ltStepTo);_ltStepTo=null;}',
' var ed=document.querySelector(".react-flow__edges");',
' if(!ed){if(++_ltStepRetries>5)return;_ltStepTo=setTimeout(_ltStepApply,500);return;}',
' _ltStepRetries=0;',
' if(document.body.classList.contains("libtv-step-edges")){',
' _ltStepEdges();',
' if(!_ltStepObs){',
' var _ltStepParent=document.querySelector(".react-flow")||document.body;',
' _ltStepObs=new MutationObserver(function(){_ltStepRetries=0;_ltStepApply();});',
' _ltStepObs.observe(_ltStepParent,{childList:true,subtree:true,attributes:true,attributeFilter:["d"]});',
' }',
' }else{',
' if(_ltStepObs){_ltStepObs.disconnect();_ltStepObs=null;}',
' }',
' }',
' var _ltStepOn=localStorage.getItem("_lt_step")==="1";',
' if(_ltStepOn){ document.body.classList.add("libtv-step-edges"); _ltStepApply(); }',
/* ———— 快捷键 ———— */
' document.addEventListener("keydown",function(e){',
' if(e.ctrlKey||e.metaKey||e.altKey)return;',
/* Escape 始终可用 */
' if(e.key==="Escape"){',
' var _handled=false; var _tm=document.getElementById("lt-tag-menu"); if(_tm){_ltCloseTagMenu();_handled=true;}',
' _ltClearChain();',
' var _ss=document.getElementById("libtv-search"); if(_ss){_ss.remove();_handled=true;}',
' var _pp=document.getElementById("libtv-prompt"); if(_pp){_pp.remove();_handled=true;}',
' var _dd=document.getElementById("lt-debug"); if(_dd){_dd.remove();_handled=true;}',
' if(_handled){e.preventDefault();e.stopPropagation();}',
' return;',
' }',
' var t=e.target||document.activeElement;',
' if(t&&(t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.isContentEditable)){',
' return;',
' }',
/* G: 网格 */
' if(e.key==="g"||e.key==="G"){',
' e.preventDefault(); e.stopPropagation();',
' var bg=document.querySelector(".react-flow__background");',
' if(bg) bg.classList.toggle("perf-no-grid");',
' try{localStorage.setItem("_lt_grid",bg.classList.contains("perf-no-grid")?"1":"0");}catch(ex){}',
' return;',
' }',
/* T: 性能 */
' if(e.key==="t"||e.key==="T"){',
' e.preventDefault(); e.stopPropagation();',
' document.body.classList.toggle("perf-mode");',
' try{localStorage.setItem("_lt_perf",document.body.classList.contains("perf-mode")?"1":"0");}catch(ex){}',
' return;',
' }',
/* H: 隐藏图片 */
' if(e.key==="h"||e.key==="H"){',
' e.preventDefault(); e.stopPropagation();',
' document.body.classList.toggle("perf-hide-imgs");',
' try{localStorage.setItem("_lt_hide",document.body.classList.contains("perf-hide-imgs")?"1":"0");}catch(ex){}',
' return;',
' }',
/* L: 隐藏连线 */
' if(e.key==="l"||e.key==="L"){',
' e.preventDefault(); e.stopPropagation();',
' var edges=document.querySelector(".react-flow__edges");',
' if(edges) edges.classList.toggle("perf-hide-edges");',
' try{localStorage.setItem("_lt_edges",edges.classList.contains("perf-hide-edges")?"1":"0");}catch(ex){}',
' return;',
' }',
/* C: 自动全链路模式 */
' if(e.key==="c"||e.key==="C"){',
' e.preventDefault(); e.stopPropagation();',
' _ltAutoChain=!_ltAutoChain;',
' document.body.classList.toggle("libtv-autochain",_ltAutoChain);',
' try{localStorage.setItem("_lt_autochain",_ltAutoChain?"1":"0");}catch(ex){}',
' if(!_ltAutoChain) _ltClearChain();',
' return;',
' }',
/* F: 搜索 */
' if(e.key==="f"||e.key==="F"){',
' e.preventDefault(); e.stopPropagation();',
' _ltSearch();',
' return;',
' }',
/* P: 提示词工具 */
' if(e.key==="p"||e.key==="P"){',
' e.preventDefault(); e.stopPropagation();',
' _ltPromptPanel();',
' return;',
' }',
/* X: 专注模式 */
' if(e.key==="x"||e.key==="X"){',
' e.preventDefault(); e.stopPropagation();',
' document.body.classList.toggle("libtv-focus");',
' try{localStorage.setItem("_lt_focus",document.body.classList.contains("libtv-focus")?"1":"0");}catch(ex){}',
' return;',
' }',
/* R: 直角连线 */
' if(e.key==="r"||e.key==="R"){',
' e.preventDefault(); e.stopPropagation();',
' document.body.classList.toggle("libtv-step-edges");',
' try{localStorage.setItem("_lt_step",document.body.classList.contains("libtv-step-edges")?"1":"0");}catch(ex){}',
' _ltStepApply();',
' return;',
' }',
/* N: 清爽首页 */
' if(e.key==="n"||e.key==="N"){',
' e.preventDefault(); e.stopPropagation();',
' document.body.classList.toggle("libtv-clean-home");',
' try{localStorage.setItem("_lt_clean",document.body.classList.contains("libtv-clean-home")?"1":"0");}catch(ex){}',
' return;',
' }',
/* ?: 帮助(固定/取消固定快捷键提示) */
' if(e.key==="?"||e.key==="/"){',
' e.preventDefault(); e.stopPropagation();',
' var h=document.getElementById("libtv-help");',
' if(h){ h.classList.toggle("libtv-pin"); if(h.classList.contains("libtv-pin")) h.classList.remove("libtv-hide"); else h.classList.add("libtv-hide"); }',
' return;',
' }',
' }, true);',
/* ———— 通用 HTML 转义(防止内容包/用户输入造成 XSS) ———— */
' function _ltEsc(s){return String(s==null?"":s).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");}',
/* ———— 通用 Toast 提示 ———— */
' function _ltToast(msg, dur){var e=document.getElementById("_ltToast");if(!e){e=document.createElement("div");e.id="_ltToast";Object.assign(e.style,{position:"fixed",bottom:"20px",left:"50%",transform:"translateX(-50%)",background:"rgba(0,0,0,.8)",color:"#fff",padding:"8px 18px",borderRadius:"6px",zIndex:99999,fontSize:"14px",pointerEvents:"none",transition:"opacity .3s",opacity:"0"});document.body.appendChild(e)}e.textContent=msg;e.style.opacity="1";clearTimeout(e._t);e._t=setTimeout(function(){e.style.opacity="0"},dur||2000);}',
/* ———— 内容包:导出 / 导入(提示词 + 标签) ———— */
' function _ltBuildContentPack(){',
' var prompts=JSON.parse(localStorage.getItem("_lt_prompts")||"[]");',
' var tagLibs=JSON.parse(localStorage.getItem("_lt_tag_libs")||"null")||{};',
' var curLib=localStorage.getItem("_lt_cur_lib")||"默认标签";',
' return {app:"libtv-boost",type:"content-pack",version:1,exportedAt:new Date().toISOString(),currentLib:curLib,prompts:prompts,tagLibs:tagLibs};',
' }',
' function _ltDownloadContentPack(){',
' var str=JSON.stringify(_ltBuildContentPack(),null,2);',
' var blob=new Blob([str],{type:"application/json"});',
' var url=URL.createObjectURL(blob);',
' var a=document.createElement("a");',
' var d=new Date(),pad=function(n){return (n<10?"0":"")+n;};',
' a.href=url;a.download="libtv-content-pack-"+d.getFullYear()+"-"+pad(d.getMonth()+1)+"-"+pad(d.getDate())+".json";',
' document.body.appendChild(a);a.click();a.remove();',
' setTimeout(function(){try{URL.revokeObjectURL(url);}catch(e){}},1000);',
' }',
' function _ltImportContentPackFromFile(){',
' var inp=document.createElement("input");inp.type="file";inp.accept="application/json,.json";',
' inp.onchange=function(){var f=inp.files&&inp.files[0];if(!f)return;var r=new FileReader();r.onload=function(){try{_ltShowContentPackChooser(String(r.result));}catch(e){_ltToast("内容包解析失败:"+e.message);}};r.readAsText(f);};',
' inp.click();',
' }',
' function _ltShowContentPackChooser(text){',
' var data;try{data=JSON.parse(text);}catch(e){_ltToast("不是有效的 JSON 内容包:"+e.message);return;}',
' if(!data||data.type!=="content-pack"){_ltToast("文件不是 libtv-boost 内容包(缺少 type:\\"content-pack\\")");return;}',
' var ov=document.createElement("div");ov.id="lt-cp-overlay";',
' ov.style.cssText="position:fixed;inset:0;background:rgba(0,0,0,0.6);z-index:2147483647;display:flex;align-items:center;justify-content:center;";',
' var box=document.createElement("div");',
' box.style.cssText="background:#1b1d2a;border:1px solid rgba(129,140,248,0.3);border-radius:12px;padding:22px;min-width:320px;max-width:90vw;color:#e7e9f3;font-family:inherit;";',
' var pcount=Array.isArray(data.prompts)?data.prompts.length:0;',
' var tcount=data.tagLibs?Object.keys(data.tagLibs).length:0;',
' box.innerHTML=\'<div style="font-size:15px;font-weight:600;margin-bottom:6px;">导入内容包</div>\'',
' +\'<div style="font-size:12px;color:rgba(255,255,255,0.55);margin-bottom:14px;">检测到 \'+pcount+\' 条提示词 · \'+tcount+\' 个标签库</div>\'',
' +\'<div style="display:flex;flex-direction:column;gap:8px;">\'',
' +\'<button id="lt-cp-replace" style="padding:10px;border-radius:8px;border:1px solid rgba(129,140,248,0.4);background:linear-gradient(135deg,rgba(129,140,248,0.25),rgba(167,139,250,0.25));color:#fff;cursor:pointer;font-size:13px;">整体替换(覆盖现有)</button>\'',
' +\'<button id="lt-cp-merge" style="padding:10px;border-radius:8px;border:1px solid rgba(255,255,255,0.15);background:rgba(255,255,255,0.06);color:#e7e9f3;cursor:pointer;font-size:13px;">合并去重(保留现有)</button>\'',
' +\'<button id="lt-cp-cancel" style="padding:9px;border-radius:8px;border:1px solid rgba(255,255,255,0.1);background:transparent;color:rgba(255,255,255,0.6);cursor:pointer;font-size:12px;">取消</button>\'',
' +\'</div>\';',
' ov.appendChild(box);document.body.appendChild(ov);',
' function close(){if(ov.parentNode)ov.parentNode.removeChild(ov);}',
' document.getElementById("lt-cp-replace").onclick=function(){close();_ltApplyContentPack(data,"replace");};',
' document.getElementById("lt-cp-merge").onclick=function(){close();_ltApplyContentPack(data,"merge");};',
' document.getElementById("lt-cp-cancel").onclick=close;',
' ov.onclick=function(e){if(e.target===ov)close();};',
' }',
' function _ltApplyContentPack(data,mode){',
' try{',
' if(mode==="replace"){',
' if(Array.isArray(data.prompts))try{localStorage.setItem("_lt_prompts",JSON.stringify(data.prompts));}catch(e){}',
' if(data.tagLibs&&typeof data.tagLibs==="object")try{localStorage.setItem("_lt_tag_libs",JSON.stringify(data.tagLibs));}catch(e){}',
' if(data.currentLib)try{localStorage.setItem("_lt_cur_lib",data.currentLib);}catch(e){}',
' }else{',
' var prompts=JSON.parse(localStorage.getItem("_lt_prompts")||"[]");',
' var seen={};prompts.forEach(function(p){seen[(p&&p.id)||("n"+Math.random())]=true;});',
' (data.prompts||[]).forEach(function(p){if(p&&p.id&&!seen[p.id]){prompts.push(p);seen[p.id]=true;}});',
' try{localStorage.setItem("_lt_prompts",JSON.stringify(prompts));}catch(e){}',
' var tagLibs=JSON.parse(localStorage.getItem("_lt_tag_libs")||"null");if(!tagLibs)tagLibs={};',
' var src=data.tagLibs||{};',
' for(var k in src){if(!src.hasOwnProperty(k))continue;',
' if(!tagLibs[k]){tagLibs[k]=src[k];continue;}',
' var dstCats=tagLibs[k].categories||[];var srcCats=src[k].categories||[];',
' srcCats.forEach(function(c){',
' var ex=null;for(var i=0;i<dstCats.length;i++){if(dstCats[i].name===c.name){ex=dstCats[i];break;}}',
' if(!ex){dstCats.push(c);return;}',
' var dg=ex.groups||[];',
' (c.groups||[]).forEach(function(g){',
' var eg=null;for(var j=0;j<dg.length;j++){if(dg[j].name===g.name){eg=dg[j];break;}}',
' if(!eg){dg.push(g);return;}',
' eg.items=eg.items||[];(g.items||[]).forEach(function(it){if(eg.items.indexOf(it)<0)eg.items.push(it);});',
' });',
' });',
' tagLibs[k].categories=dstCats;',
' }',
' try{localStorage.setItem("_lt_tag_libs",JSON.stringify(tagLibs));}catch(e){}',
' }',
' if(window._ltPromptRefresh)window._ltPromptRefresh();',
' if(window._ltTagRefresh)window._ltTagRefresh();',
' _ltToast("✅ 内容包已导入("+(mode==="replace"?"整体替换":"合并去重")+")");',
' }catch(e){_ltToast("导入失败:"+e.message);}',
' }',
'function _ltSettingsPanel(){',
' var existing=document.getElementById("lt-settings");',
' if(existing){existing.remove();return;}',
' var div=document.createElement("div");div.id="lt-settings";div.className="lt-settings";',
' var h="<div class=\\\"lt-settings-head\\\"><span>⚙ \\u8bbe\\u7f6e</span><span class=\\\"lt-settings-close\\\" id=\\\"lt-settings-close\\\">\\u2715</span></div>"',
' +"<div class=\\\"lt-settings-body\\\" id=\\\"lt-settings-body\\\">";',
' /* \\u5f00\\u5173 */',
' var toggles=[',
' {k:"perf",l:"\\u6027\\u80fd\\u6a21\\u5f0f"},',
' {k:"hide",l:"\\u9690\\u85cf\\u56fe\\u7247"},',
' {k:"edges",l:"\\u9690\\u85cf\\u8fde\\u7ebf"},',
' {k:"grid",l:"\\u9690\\u85cf\\u7f51\\u683c"},',
' {k:"focus",l:"\\u4e13\\u6ce8\\u6a21\\u5f0f"},',
' ];',
' h+="<div class=\\\"lt-settings-sec\\\"><div class=\\\"lt-settings-stitle\\\">\\u5f00\\u5173</div>";',
' toggles.forEach(function(t){',
' var on=document.body.classList.contains("perf-mode")||localStorage.getItem("_lt_"+t.k)==="1";',
' h+="<div class=\\\"lt-settings-toggle\\\" data-key=\\\""+t.k+"\\\"><span>"+t.l+"</span><span class=\\\"lt-settings-switch"+(on?" on":"")+"\\\"></span></div>";',
' });',
' h+="</div>";',
' /* API */',
' var api=JSON.parse(localStorage.getItem("_lt_prompt_api")||"{}");',
' h+="<div class=\\\"lt-settings-sec\\\"><div class=\\\"lt-settings-stitle\\\">AI \\u589e\\u5f3a API</div>"',
' +"<div class=\\\"lt-settings-row\\\"><label>API \\u5730\\u5740</label><input class=\\\"lt-settings-inp\\\" id=\\\"lt-set-url\\\" value=\\\""+_ltEsc(api.url||"")+"\\\" placeholder=\\\"https://api.deepseek.com/chat/completions\\\"></div>"',
' +"<div class=\\\"lt-settings-row\\\"><label>API Key</label><input class=\\\"lt-settings-inp\\\" type=\\\"password\\\" id=\\\"lt-set-key\\\" value=\\\""+_ltEsc(api.key||"")+"\\\" placeholder=\\\"sk-...\\\"></div>"',
' +"<div class=\\\"lt-settings-row\\\"><label>\\u6a21\\u578b</label><input class=\\\"lt-settings-inp\\\" id=\\\"lt-set-model\\\" value=\\\""+_ltEsc(api.model||"")+"\\\" placeholder=\\\"deepseek-v4-flash\\\"></div>"',
' +"<div style=\\\"margin-top:8px;\\\"><button class=\\\"lt-settings-btn lt-settings-btn-primary\\\" id=\\\"lt-set-api-save\\\">\\u4fdd\\u5b58</button><span class=\\\"lt-settings-status\\\" id=\\\"lt-set-api-status\\\"></span></div>"',
' +"</div>";',
' /* \\u6570\\u636e */',
' h+="<div class=\\\"lt-settings-sec\\\"><div class=\\\"lt-settings-stitle\\\">\\u6570\\u636e\\u7ba1\\u7406</div>"',
' +"<div class=\\\"lt-settings-dlist\\\" id=\\\"lt-settings-dlist\\\"></div>"',
' +"<button class=\\\"lt-settings-btn lt-settings-btn-ghost lt-settings-btn-sm\\\" id=\\\"lt-set-export-all\\\">\\u5bfc\\u51fa\\u5168\\u90e8\\u914d\\u7f6e</button>"',
' +"<div class=\\\"lt-settings-cpbtns\\\">"',
' +"<button class=\\\"lt-settings-btn lt-settings-btn-primary lt-settings-btn-sm\\\" id=\\\"lt-set-cp-export\\\">\\u5bfc\\u51fa\\u5185\\u5bb9\\u5305</button>"',
' +"<button class=\\\"lt-settings-btn lt-settings-btn-ghost lt-settings-btn-sm\\\" id=\\\"lt-set-cp-import\\\">\\u5bfc\\u5165\\u5185\\u5bb9\\u5305</button>"',
' +"</div>"',
' +"</div>";',
' /* \\u5173\\u4e8e */',
' h+="<div class=\\\"lt-settings-sec\\\"><div class=\\\"lt-settings-stitle\\\">\\u5173\\u4e8e</div>"',
' +"<div class=\\\"lt-settings-about\\\">LibTV Canvas Boost v1.9.7<br>\\u6e90\\u7801\\u6a21\\u5757\\u5316\\u6784\\u5efa\\uff0c\\u63d0\\u4f9b\\u6027\\u80fd\\u4f18\\u5316\\u3001\\u89c6\\u89c9\\u589e\\u5f3a\\u3001AI \\u63d0\\u793a\\u8bcd\\u3001\\u6807\\u7b7e\\u7cfb\\u7edf</div>"',
' +"</div>";',
' h+="</div>";',
' div.innerHTML=h;',
' document.body.appendChild(div);',
' /* \\u5f00\\u5173\\u4e8b\\u4ef6 */',
' div.querySelectorAll(".lt-settings-toggle").forEach(function(el){',
' el.onclick=function(){',
' var k=this.getAttribute("data-key");',
' var v=localStorage.getItem("_lt_"+k)!=="1";',
' try{localStorage.setItem("_lt_"+k,v?"1":"0");}catch(e){}',
' if(k==="grid"){var bg=document.querySelector(".react-flow__background");if(bg)bg.classList.toggle("perf-no-grid",v);}',
' else if(k==="edges"){var ed=document.querySelector(".react-flow__edges");if(ed)ed.classList.toggle("perf-hide-edges",v);}',
' else document.body.classList.toggle(k==="perf"?"perf-mode":k==="hide"?"perf-hide-imgs":"libtv-"+k,v);',
' this.querySelector(".lt-settings-switch").classList.toggle("on",v);',
' };',
' });',
' /* API \\u4fdd\\u5b58 */',
' document.getElementById("lt-set-api-save").onclick=function(){',
' var d={url:document.getElementById("lt-set-url").value.trim(),key:document.getElementById("lt-set-key").value.trim(),model:document.getElementById("lt-set-model").value.trim()||"deepseek-v4-flash"};',
' try{localStorage.setItem("_lt_prompt_api",JSON.stringify(d));}catch(e){}',
' document.getElementById("lt-set-api-status").textContent="\\u2705 \\u5df2\\u4fdd\\u5b58";',
' };',
' /* \\u6570\\u636e\\u6e05\\u5355 */',
' var keys=[["_lt_tag_libs","\\u6807\\u7b7e\\u5e93"],["_lt_cur_lib","\\u5f53\\u524d\\u6807\\u7b7e\\u5e93"],["_lt_recent","\\u5df2\\u63d2\\u5165\\u5386\\u53f2"]];',
' var dl=document.getElementById("lt-settings-dlist");',
' keys.forEach(function(kv){',
' var val=localStorage.getItem(kv[0]);',
' if(!val)return;',
' var size=Math.round(val.length/1024);',
' var el=document.createElement("div");el.className="lt-settings-ditem";',
' el.innerHTML="<span>"+kv[1]+"</span><span>"+size+"KB</span><button class=\\\"lt-settings-dclear\\\" data-key=\\\""+kv[0]+"\\\">\\u6e05\\u7a7a</button>";',
' el.querySelector(".lt-settings-dclear").onclick=function(e){e.stopPropagation();try{localStorage.removeItem(this.getAttribute("data-key"));}catch(ex){}el.remove();};',
' dl.appendChild(el);',
' });',
' /* \\u5bfc\\u51fa\\u5168\\u90e8 */',
' document.getElementById("lt-set-export-all").onclick=function(){',
' var data={};',
' keys.forEach(function(kv){var v=localStorage.getItem(kv[0]);if(v)data[kv[0]]=v;});',
' data._version="1.8.3";',
' data._exportedAt=new Date().toISOString();',
' var blob=new Blob([JSON.stringify(data,null,2)],{type:"application/json"});',
' var url=URL.createObjectURL(blob);',
' var a=document.createElement("a");a.href=url;a.download="libtv-boost-config-"+new Date().toISOString().slice(0,10)+".json";a.click();',
' setTimeout(function(){URL.revokeObjectURL(url);},1000);',
' };',
' document.getElementById("lt-set-cp-export").onclick=function(){ _ltDownloadContentPack(); };',
' document.getElementById("lt-set-cp-import").onclick=function(){ _ltImportContentPackFromFile(); };',
' /* \\u5173\\u95ed */',
' document.getElementById("lt-settings-close").onclick=function(){div.remove();};',
' }',
' window._ltOpenSettings=_ltSettingsPanel;',
' window._ltContent={exportPack:_ltDownloadContentPack,importFile:_ltImportContentPackFromFile};',
' window._ltShowTagMenu=_ltShowTagMenu;',
'})();'
].join('\n');
document.body.appendChild(hook);
} catch(e) {
console.error('[LibTV] Hook error:', e);
if (typeof alert !== 'undefined') alert('LibTV hook error: ' + e.message);
}
/* =========================================================
* 4. 菜单开关 + 状态持久化
* ========================================================= */
var _toggles = {
perf: function(v){ document.body.classList.toggle('perf-mode', v); },
hide: function(v){ document.body.classList.toggle('perf-hide-imgs', v); },
grid: function(v){
var bg = document.querySelector('.react-flow__background');
if(bg) bg.classList.toggle('perf-no-grid', v);
},
edges: function(v){
var edges = document.querySelector('.react-flow__edges');
if(edges) edges.classList.toggle('perf-hide-edges', v);
},
focus: function(v){ document.body.classList.toggle('libtv-focus', v); },
};
function _read(){
var s = {};
for(var k in _toggles) if(_toggles.hasOwnProperty(k))
try{ s[k] = localStorage.getItem('_lt_'+k) === '1'; }catch(e){}
return s;
}
function _apply(){
var s = _read();
for(var k in _toggles) if(_toggles.hasOwnProperty(k)) _toggles[k](s[k]);
}
function _click(key){
var v = true;
try{ v = localStorage.getItem('_lt_'+key) !== '1'; }catch(e){}
try{localStorage.setItem('_lt_'+key, v ? '1' : '0');}catch(e){}
_toggles[key](v);
}
setTimeout(_apply, 1000);
GM_registerMenuCommand('⚙ 设置', function(){
if(unsafeWindow._ltOpenSettings) unsafeWindow._ltOpenSettings();
});
GM_registerMenuCommand('🔍 诊断', function(){
try {
var info = [];
info.push('=== 边 (class 含 edge) ===');
var es = document.querySelectorAll('[class*="edge"]');
info.push('数量: ' + es.length);
for(var i=0;i<Math.min(es.length,10);i++){
var e = es[i];
var attrs = '';
for(var a=0;a<e.attributes.length;a++){
var attr = e.attributes[a];
if(attr.name.indexOf('__react')===0) continue;
attrs += '\n ' + attr.name + '="' + (attr.value||'').slice(0,80) + '"';
}
var path = e.querySelector('path');
var d = path ? (path.getAttribute('d')||'').slice(0,100) : '无path';
info.push(i + ' class="' + (e.getAttribute('class')||'') + '"' + attrs);
info.push(' d="' + d + '"');
}
info.push('');
info.push('=== 节点 (data-id) ===');
// 找所有有 data-id 的元素
var all = document.querySelectorAll('[data-id]');
info.push('有 data-id 的元素: ' + all.length);
var ns = [];
for(var j=0;j<all.length;j++){
var id = all[j].getAttribute('data-id');
if(id && (id.indexOf('i-')===0 || id.indexOf('n-')===0 || id.indexOf('m-')===0)){
ns.push(all[j]);
}
}
info.push('节点(data-id以i-/n-/m-开头): ' + ns.length);
for(var k=0;k<Math.min(ns.length,10);k++){
var n = ns[k];
var transform = n.style.transform || '';
var text = (n.textContent||'').trim().split('\n')[0].slice(0,40);
info.push(k + ' data-id=' + n.getAttribute('data-id') + ' transform="' + transform + '" text="' + text + '" class=' + (n.getAttribute('class')||'').slice(0,40));
}
var txt = info.join('\n');
var div = document.createElement('div');
div.style.cssText = 'position:fixed;top:10px;left:10px;z-index:999999;background:rgba(0,0,0,0.92);color:#0f0;padding:12px;border-radius:8px;font:10px/1.4 monospace;max-width:700px;max-height:80vh;overflow:auto;pointer-events:auto;';
div.innerHTML = '<div style="font-weight:bold;margin-bottom:6px;color:#fff;">🔍 诊断</div><pre style="margin:0;">' + txt.replace(/</g,'<') + '</pre><div style="margin-top:6px;display:flex;gap:6px;"><button id="lt-dbg-copy" style="padding:2px 12px;cursor:pointer;">📋 复制</button><button id="lt-dbg-close" style="padding:2px 12px;cursor:pointer;">关闭</button></div>';
document.body.appendChild(div);
document.getElementById('lt-dbg-copy').onclick = function(){
navigator.clipboard.writeText(txt).then(function(){ document.getElementById('lt-dbg-copy').textContent = '✅ 已复制'; });
};
document.getElementById('lt-dbg-close').onclick = function(){ div.remove(); };
} catch(e){ try{_ltToast(e.message);}catch(ex){} }
});
})();