Update ena-planner.js

This commit is contained in:
Hao19911125
2026-02-21 21:22:47 +08:00
committed by GitHub
parent 41fa00c2d0
commit f69dade415

View File

@@ -1825,6 +1825,28 @@ function injectUI() {
if (document.getElementById('ena_planner_settings')) return; if (document.getElementById('ena_planner_settings')) return;
// 动态注入 tab 按钮
const menuBar = document.querySelector('.settings-menu-vertical');
if (!menuBar) return;
if (!menuBar.querySelector('[data-target="ena-planner"]')) {
const tabDiv = document.createElement('div');
tabDiv.className = 'menu-tab';
tabDiv.setAttribute('data-target', 'ena-planner');
tabDiv.setAttribute('style', 'border-bottom:1px solid #303030;');
tabDiv.innerHTML = '<span class="vertical-text">剧情规划</span>';
menuBar.appendChild(tabDiv);
}
// 动态注入面板容器
const contentArea = document.querySelector('.settings-content');
if (!contentArea) return;
if (!document.getElementById('ena_planner_panel')) {
const panel = document.createElement('div');
panel.id = 'ena_planner_panel';
panel.className = 'ena-planner settings-section';
contentArea.appendChild(panel);
}
const container = document.getElementById('ena_planner_panel'); const container = document.getElementById('ena_planner_panel');
if (!container) return; if (!container) return;
@@ -1836,11 +1858,9 @@ function injectUI() {
if (!document.getElementById('ep_log_modal')) { if (!document.getElementById('ep_log_modal')) {
const modalWrap = document.createElement('div'); const modalWrap = document.createElement('div');
modalWrap.innerHTML = createLogModalHTML(); modalWrap.innerHTML = createLogModalHTML();
// Append all children (style + modal div)
while (modalWrap.firstChild) document.body.appendChild(modalWrap.firstChild); while (modalWrap.firstChild) document.body.appendChild(modalWrap.firstChild);
_addUniversalTap(document.getElementById('ep_log_close'), () => closeLogModal()); _addUniversalTap(document.getElementById('ep_log_close'), () => closeLogModal());
// Backdrop tap to close
const logModal = document.getElementById('ep_log_modal'); const logModal = document.getElementById('ep_log_modal');
if (logModal) { if (logModal) {
_addUniversalTap(logModal, (e) => { if (e.target === logModal) closeLogModal(); }); _addUniversalTap(logModal, (e) => { if (e.target === logModal) closeLogModal(); });
@@ -1966,9 +1986,8 @@ export function initEnaPlanner() {
ensureSettings(); ensureSettings();
loadPersistedLogsMaybe(); loadPersistedLogsMaybe();
// Wait for DOM to be ready with the panel
const tryInject = () => { const tryInject = () => {
if (document.getElementById('ena_planner_panel')) { if (document.querySelector('.settings-menu-vertical')) {
injectUI(); injectUI();
installSendInterceptors(); installSendInterceptors();
} else { } else {