拾荒小猫无限卡槽控制矩阵 - 极致轻量化精简核心(面向Gemini窗口大容量优化版)
This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.greatest.deepsurf.us/scripts/579926/1835589/NitterCorpusLiteCore.js
// ==UserScript==
// @name NitterCorpusLiteCore
// @version 1.2.6_LiteCore
// @description 拾荒小猫无限卡槽控制矩阵 - 极致轻量化精简核心(面向Gemini窗口大容量优化版)
// @author Gemini Collaborator
// @grant GM_setClipboard
// ==/UserScript==
(function(window) {
'use strict';
const LiteCore = {
init(options) {
this.version = options.version || '1.2.6';
this.username = options.username || 'unknown';
this.host = options.host || location.hostname;
if (!window.NitterEnv || !window.NitterNet) {
console.error("❌ LiteCore 启动死锁:请先在油猴中安装并启用 Env 与 Net 配套脚本!");
return;
}
window.NitterEnv.setup(this.host, this.username, options.metaText, options.tweets || []);
if (window.NitterCorpusStyles) window.NitterCorpusStyles.inject();
this.buildDOM();
this.bindEvents();
this.executeAutoRun();
},
buildDOM() {
const isVisible = localStorage.getItem('rp_panel_visible') !== 'false';
const isDrawerVisible = localStorage.getItem('rp_drawer_visible') === 'true';
const env = window.NitterEnv;
const panel = document.createElement('div');
panel.id = 'rp-heavy-panel';
panel.style = `position: fixed; bottom: 20px; left: 20px; z-index: 99999; background: #11111b; color: #cdd6f4; padding: 10px; border: 1px solid #45475a; border-radius: 6px; font-family: monospace; font-size: 11px; width: 135px; box-shadow: 0 4px 15px rgba(0,0,0,0.7); display: ${isVisible ? 'block' : 'none'}; box-sizing: border-box;`;
panel.innerHTML = `
<div style="display:flex; justify-content:space-between; align-items:center; margin-bottom:4px;"><span style="color:#f5c2e7; font-weight:bold; font-size:9.5px;">v${this.version}</span><span id="rp-close" style="cursor:pointer; font-weight:bold; color:#f38ba8; font-size:12px;">×</span></div>
<div style="overflow:hidden; text-overflow:ellipsis; white-space:nowrap; width:100%; font-size:9.5px; margin-bottom:3px;">👤:${this.username}</div>
<div style="font-size:9.5px; color:#a6adc8; margin-bottom:6px;">页:[${env.localStore.currentPage}] 语料:[${env.localStore.tweets.length}条]</div>
<div style="display:flex; justify-content:space-between; margin-bottom:6px; width:100%; gap:2px;">
<button id="btn-run" style="width:25px; height:20px; padding:0; background:#f9e2af; color:#11111b; border:none; cursor:pointer; font-size:10px; font-weight:bold; border-radius:3px;">挖</button>
<button id="btn-copy" style="width:25px; height:20px; padding:0; background:#a6e3a1; color:#11111b; border:none; cursor:pointer; font-size:10px; font-weight:bold; border-radius:3px;">拷</button>
<button id="btn-download" style="width:25px; height:20px; padding:0; background:#cca7ef; color:#11111b; border:none; cursor:pointer; font-size:10px; font-weight:bold; border-radius:3px;">存</button>
<button id="btn-zip" style="width:25px; height:20px; padding:0; background:#89b4fa; color:#11111b; border:none; cursor:pointer; font-size:10px; font-weight:bold; border-radius:3px;">包</button>
<button id="btn-clear" style="width:22px; height:20px; padding:0; background:#313244; color:#f38ba8; border:none; cursor:pointer; font-size:9px; font-weight:bold; border-radius:3px;">清</button>
</div>
<div style="border-top:1px dashed #45475a; padding-top:4px;">
<div style="display:flex; justify-content:space-between; margin-bottom:5px; gap:2px;">
<button id="state-img" style="flex:1; height:18px; border:none; cursor:pointer; font-size:9px; font-weight:bold; border-radius:3px;">图</button>
<button id="state-video" style="flex:1; height:18px; border:none; cursor:pointer; font-size:9px; font-weight:bold; border-radius:3px;">影</button>
<button id="state-stamp" style="flex:1; height:18px; border:none; cursor:pointer; font-size:9px; font-weight:bold; border-radius:3px;">戳</button>
<button id="state-hot" style="flex:1; height:18px; border:none; cursor:pointer; font-size:9px; font-weight:bold; border-radius:3px;">热</button>
</div>
<div style="font-size:9px; display:flex; justify-content:space-between;"><span>调速:</span><span id="speed-txt" style="color:#a6e3a1; font-weight:bold;">3.0s</span></div>
<input type="range" id="cfg-speed" min="1" max="3" step="1" value="${env.localStore.config.level}" style="width:100%; margin:0; height:4px;">
</div>
<button id="btn-toggle-drawer" class="rp-drawer-btn">⚙️ 提示词配置中心</button>
`;
document.body.appendChild(panel);
const megaDrawer = document.createElement('div');
megaDrawer.id = 'rp-mega-drawer';
megaDrawer.className = isDrawerVisible ? '' : 'hidden';
megaDrawer.innerHTML = `
<div class="mega-layout">
<div class="mega-top-split">
<div class="mega-sidebar-left">
<div class="slot-header-area">
<span style="color:#f5c2e7; font-size:13px; font-weight:bold;">🎭 卡槽池 <span style="color:#6c7086; font-size:10px;">v${this.version}</span></span>
<button id="btn-new-slot" class="btn-create-slot">➕ 新建</button>
</div>
<div id="slot-list-zone" class="slot-container"></div>
<div class="history-panel-wrapper">
<div style="display:flex; justify-content:space-between; margin-bottom:4px;">
<span style="color:#bac2de; font-size:11px; font-weight:bold;">🕒 解析历史 (单选填回)</span>
<button id="btn-clear-history" style="background:transparent; border:none; color:#f38ba8; font-size:11px; cursor:pointer;">[清空]</button>
</div>
<div id="history-scroll-zone" class="history-list-scroll"></div>
</div>
<div style="display:flex; flex-direction:column; gap:4px; border-top:1px solid #313244; padding-top:8px;">
<span style="color:#a6adc8; font-size:11px; font-weight:bold;">💾 本地数据总线</span>
<div class="mega-matrix-grid">
<button id="mega-btn-export-cfg" class="matrix-btn">导JSON</button>
<button id="mega-btn-import-cfg" class="matrix-btn">解JSON</button>
<button id="mega-btn-copy-raw" class="matrix-btn">拷全量</button>
</div>
<div class="mega-matrix-grid">
<button id="mega-btn-copy-gf" class="matrix-btn">拷GF源</button>
<button id="mega-btn-dl-gf" class="matrix-btn">生脚本</button>
<button id="mega-btn-paste-raw" class="matrix-btn">粘文本</button>
</div>
<input type="file" id="mega-file-handler" accept=".json" style="display:none;">
</div>
</div>
<div class="mega-sidebar-right">
<div class="api-flow-wrapper">
<span style="color:#bac2de; font-size:12px; font-weight:bold;">🌐 外部资产加载中枢</span>
<textarea id="mega-api-url" class="mega-api-textarea" placeholder="在此写入远程配置JSON直链,或者在这里直接砸入你要切片部署的超长原始单文本角色卡/提示词架构..."></textarea>
<div class="api-sub-grid">
<button id="sub-generic-flow" class="api-sub-btn" style="background:#a6e3a1;">远端 JSON 部署</button>
<button id="sub-url-extract" class="api-sub-btn" style="background:#cca7ef;">远程源码解包</button>
<button id="sub-local-slice" class="api-sub-btn" style="background:#f9e2af;">本地文本切片机</button>
<button id="deck-btn-default" class="api-sub-btn" style="background:#f2cdcd;">恢复默认环境</button>
</div>
<div style="border-top:1px dashed #313244; margin:2px 0;"></div>
<div class="sandbox-row">
<button id="deck-btn-back" class="micro-deck-btn btn-deck-grey" title="撤销上一次导入" disabled>🔙 撤销导入</button>
<button id="deck-btn-save-a" class="micro-deck-btn" style="background:#fab387;">存快照A</button>
<button id="deck-btn-back-a" class="micro-deck-btn btn-deck-grey" disabled>读快照A</button>
<button id="deck-btn-save-b" class="micro-deck-btn" style="background:#fab387;">存快照B</button>
<button id="deck-btn-back-b" class="micro-deck-btn btn-deck-grey" disabled>读快照B</button>
</div>
</div>
<div class="cloud-matrix-box">
<span style="color:#a6adc8; font-size:11px; font-weight:bold;">☁️ TextDB 开放式分布式同步网络</span>
<div class="cloud-matrix-grid">
<button id="cloud-btn-share" class="cloud-btn" style="background:#b4befe;">🌐 托管分享</button>
<button id="cloud-btn-update" class="cloud-btn" style="background:#a6e3a1;">🔄 覆盖更新</button>
<button id="cloud-btn-delete" class="cloud-btn" style="background:#f38ba8;">🧹 彻底销毁</button>
</div>
</div>
</div>
</div>
<div class="mega-main-bottom">
<div style="display:flex; justify-content:space-between; align-items:center;">
<span id="current-slot-title" style="font-size:13px; color:#f5e0dc; font-weight:bold;">📝 主作业区</span>
<button id="mega-close-btn" style="background:#f38ba8; color:#11111b; border:none; padding:4px 14px; font-size:12px; font-weight:bold; border-radius:4px; cursor:pointer;">关闭面板 (ESC)</button>
</div>
<textarea id="rp-prompt-box" class="mega-textarea" placeholder="在此选择或输入当前卡槽下的全局系统提示词方案..."></textarea>
</div>
</div>
`;
document.body.appendChild(megaDrawer);
this.renderSlotsList();
this.renderStateButtons();
this.renderAssetHistoryList();
this.updateSpeedDisplay(env.localStore.config.level);
document.getElementById('rp-prompt-box').value = env.localStore.config.customPrompt;
},
renderSlotsList() {
const container = document.getElementById('slot-list-zone');
if (!container) return;
container.innerHTML = '';
const env = window.NitterEnv;
env.localStore.slots.forEach(slot => {
const btn = document.createElement('button');
btn.className = 'mega-btn';
btn.style = "background:#313244; color:#cdd6f4; border:1px solid transparent;";
if (slot.id === env.localStore.activeSlotId) {
btn.classList.add('slot-active');
document.getElementById('current-slot-title').innerText = `📝 [v${this.version}] 当前活动槽位 ➔ ${slot.name}`;
}
btn.innerHTML = `<span style="overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width:85%;">${slot.name}</span><span>➔</span>`;
btn.addEventListener('click', () => {
env.localStore.activeSlotId = slot.id;
env.localStore.config.customPrompt = slot.content;
env.save();
document.getElementById('rp-prompt-box').value = slot.content;
this.renderSlotsList();
this.triggerAutoStateModification();
});
container.appendChild(btn);
});
this.refreshManualSandboxesUI();
},
renderAssetHistoryList() {
const historyZone = document.getElementById('history-scroll-zone');
if (!historyZone) return;
historyZone.innerHTML = '';
const env = window.NitterEnv;
if (env.assetHistory.length === 0) {
historyZone.innerHTML = `<div style="color:#585b70; font-size:11px; padding:4px; text-align:center;">暂无历史解析记录</div>`;
return;
}
env.assetHistory.forEach(item => {
const row = document.createElement('div');
row.className = 'history-item-row';
row.innerHTML = `<span style="overflow:hidden; text-overflow:ellipsis; max-width:75%; text-align:left;">${item.type === '☁️云分' ? '☁️云:' : '[链]'} ${item.url.replace('https://', '')}</span><span style="color:#6c7086; font-size:10px;">${item.time}</span>`;
row.addEventListener('click', () => {
document.getElementById('mega-api-url').value = item.url;
env.showToast('📋 已填回区', '历史记录链接已置入轰炸区。');
});
historyZone.appendChild(row);
});
},
refreshManualSandboxesUI() {
const env = window.NitterEnv;
const btnA = document.getElementById('deck-btn-back-a');
const btnB = document.getElementById('deck-btn-back-b');
const toggleBtn = (btn, key) => {
if (localStorage.getItem(env[`SANDBOX_${key}_KEY`] || `${env.DB_KEY}_snap_${key.toLowerCase()}`)) {
btn.className = 'micro-deck-btn'; btn.style.background = '#fab387'; btn.style.color = '#11111b'; btn.removeAttribute('disabled');
} else { btn.className = 'micro-deck-btn btn-deck-grey'; btn.setAttribute('disabled', 'true'); }
};
toggleBtn(btnA, 'A'); toggleBtn(btnB, 'B');
},
triggerAutoStateModification() {
const env = window.NitterEnv;
if (!env.snapshottedBackup) env.snapshottedBackup = JSON.parse(JSON.stringify(env.localStore));
const backBtn = document.getElementById('deck-btn-back');
backBtn.className = 'micro-deck-btn'; backBtn.style.background = '#f9e2af'; backBtn.style.color = '#11111b'; backBtn.removeAttribute('disabled');
},
renderStateButtons() {
const c = window.NitterEnv.localStore.config;
const styleBtn = (id, active, color) => {
document.getElementById(id).style = `flex:1; height:18px; border:none; cursor:pointer; font-size:9px; font-weight:bold; border-radius:3px; background:${active?color:'#313244'}; color:${active?'#11111b':'#585b70'}`;
};
styleBtn('state-img', c.img, '#a6e3a1'); styleBtn('state-video', c.video, '#89b4fa');
styleBtn('state-stamp', c.stamp, '#f2cdcd'); styleBtn('state-hot', c.hot, '#f9e2af');
},
updateSpeedDisplay(l) {
const speedTxt = document.getElementById('speed-txt');
speedTxt.innerText = l==1?"1.5s 冲":l==3?"5.0s 养":"3.0s 衡";
speedTxt.style.color = l==1?"#f38ba8":l==3?"#89b4fa":"#a6e3a1";
},
executeRawTextSequenceImport(rawText, isCloudSource = false) {
if (!rawText || !rawText.trim()) return;
const env = window.NitterEnv;
const blocks = rawText.split(/={10,}/);
let parsedSlots = [];
let currentName = "";
blocks.forEach(block => {
let lines = block.split('\n').map(l => l.trim()).filter(l => l.length > 0);
if (lines.length === 0) return;
if (lines.length === 1 && lines[0].length < 30) { currentName = lines[0]; }
else {
let name = currentName || lines[0].substring(0, 15);
parsedSlots.push({
id: `slot_gen_${Date.now()}_${Math.random().toString(36).substr(2, 4)}`,
name: `${isCloudSource ? '☁️' : '🎭'} ${name}`,
content: (currentName ? lines : lines.slice(1)).join('\n')
});
currentName = "";
}
});
if (parsedSlots.length === 0) parsedSlots.push({ id: `slot_gen_${Date.now()}`, name: isCloudSource ? '☁️ 外部文本' : '🎭 快捷切片', content: rawText.trim() });
env.localStore.slots = parsedSlots;
env.localStore.activeSlotId = parsedSlots[0].id;
env.localStore.config.customPrompt = parsedSlots[0].content;
env.save();
document.getElementById('rp-prompt-box').value = parsedSlots[0].content;
this.renderSlotsList(); this.triggerAutoStateModification();
env.showToast('📥 序列切片成功', `部署了 ${parsedSlots.length} 个配置卡槽。`);
},
async executeCloudShareFlow(actionType) {
const env = window.NitterEnv;
const net = window.NitterNet;
const cloudKey = `cat_db_${this.host}_${this.username}`.replace(/[^\w-]/g, '');
const targetUrl = `https://textdb.online/update/`;
if (actionType === 'delete') {
if (!confirm("⚠️ 确定要在公开云端销毁该备份吗?")) return;
net.cloudUpdate(targetUrl, cloudKey, '', 'delete', (err, json) => {
if (!err && json.status === 1) env.showToast('🧹 数据注销成功', '云端数据已安全粉碎。');
});
return;
}
env.showToast('🌐 正在同步云端...', '特权安全流上传中...');
net.cloudUpdate(targetUrl, cloudKey, JSON.stringify({ config: env.localStore.config, slots: env.localStore.slots }), 'update', (err, json) => {
if (!err && json.status === 1) {
const fetchUrl = `https://textdb.online/${cloudKey}`;
document.getElementById('mega-api-url').value = fetchUrl;
if (typeof GM_setClipboard !== 'undefined') GM_setClipboard(fetchUrl);
env.assetHistory.unshift({ type: '☁️云分', url: fetchUrl, time: new Date().toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'}) });
if (env.assetHistory.length > 25) env.assetHistory.pop();
localStorage.setItem(env.HISTORY_KEY, JSON.stringify(env.assetHistory));
this.renderAssetHistoryList(); env.showToast('🚀 云端托管成功', `直链已强刷入剪贴板。`);
}
});
},
async executeRemoteFetchDeploy() {
const env = window.NitterEnv;
const inputVal = document.getElementById('mega-api-url').value.trim();
if (!inputVal.startsWith('http')) return;
env.showToast('🌐 跨域流加载中...', '拉取资产中...');
window.NitterNet.remoteFetch(inputVal, (err, text) => {
if (!err) {
this.processImportData(text);
env.assetHistory.unshift({ type: '🔗链接', url: inputVal, time: new Date().toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'}) });
if (env.assetHistory.length > 25) env.assetHistory.pop();
localStorage.setItem(env.HISTORY_KEY, JSON.stringify(env.assetHistory));
this.renderAssetHistoryList();
}
});
},
processImportData(text) {
const env = window.NitterEnv;
if (!text || !text.trim()) return;
try {
const cloud = JSON.parse(text.trim());
if (cloud && cloud.slots && Array.isArray(cloud.slots)) {
this.triggerAutoStateModification();
env.localStore.slots = cloud.slots;
env.localStore.activeSlotId = cloud.slots[0].id;
env.localStore.config.customPrompt = cloud.slots[0].content;
if (cloud.config) env.localStore.config = Object.assign({}, env.localStore.config, cloud.config);
env.save();
document.getElementById('rp-prompt-box').value = env.localStore.config.customPrompt;
this.renderSlotsList(); this.renderStateButtons();
env.showToast('📋 热泵入成功', `载入 ${cloud.slots.length} 个配置卡槽!`);
}
} catch(e) { this.executeRawTextSequenceImport(text, true); }
},
executeAutoRun() {
const env = window.NitterEnv;
if (localStorage.getItem('rp_global_autorun') === 'true' && localStorage.getItem('rp_active_key') === env.DB_KEY) {
if (env.localStore.currentPage < 10) {
const findMoreBtn = () => Array.from(document.querySelectorAll('.show-more a')).find(el => el.textContent && el.textContent.includes('Load more'));
const moreBtn = findMoreBtn();
if (moreBtn) {
env.localStore.currentPage++; env.localStore.lastUrl = location.href; env.save();
setTimeout(() => { window.scrollTo({ top: document.body.scrollHeight }); setTimeout(() => { const b = findMoreBtn(); if(b) b.click(); }, 500); }, env.localStore.config.level == 1 ? 1000 : env.localStore.config.level == 3 ? 4500 : 2500);
} else { localStorage.setItem('rp_global_autorun', 'false'); env.showToast('🏁 挖掘完成', '就绪!'); }
}
}
},
bindEvents() {
const env = window.NitterEnv; const net = window.NitterNet;
const promptBox = document.getElementById('rp-prompt-box');
const megaDrawer = document.getElementById('rp-mega-drawer');
const fileHandler = document.getElementById('mega-file-handler');
document.getElementById('rp-close').addEventListener('click', () => { document.getElementById('rp-heavy-panel').style.display = 'none'; localStorage.setItem('rp_panel_visible', 'false'); });
const bindState = (id, key) => {
document.getElementById(id).addEventListener('click', () => { env.localStore.config[key] = !env.localStore.config[key]; env.save(); this.renderStateButtons(); });
};
bindState('state-img', 'img'); bindState('state-video', 'video'); bindState('state-stamp', 'stamp'); bindState('state-hot', 'hot');
document.getElementById('cfg-speed').addEventListener('input', (e) => { let val = parseInt(e.target.value); this.updateSpeedDisplay(val); env.localStore.config.level = val; env.save(); });
const toggleMegaDrawer = () => {
const isHidden = megaDrawer.classList.contains('hidden');
megaDrawer.classList[isHidden ? 'remove' : 'add']('hidden');
localStorage.setItem('rp_drawer_visible', isHidden ? 'true' : 'false');
};
document.getElementById('btn-toggle-drawer').addEventListener('click', toggleMegaDrawer);
document.getElementById('mega-close-btn').addEventListener('click', toggleMegaDrawer);
promptBox.addEventListener('input', (e) => {
env.localStore.config.customPrompt = e.target.value;
let actSlot = env.localStore.slots.find(s => s.id === env.localStore.activeSlotId);
if (actSlot) actSlot.content = e.target.value;
env.save(); this.triggerAutoStateModification();
});
document.getElementById('btn-new-slot').addEventListener('click', () => {
const cardName = prompt("请输入新角色卡的标题:"); if (!cardName) return;
this.triggerAutoStateModification(); const newId = `slot_c_${Date.now()}`;
const newSlot = { id: newId, name: `🎭 ${cardName.trim()}`, content: "在此输入全新的系统提示词指令..." };
env.localStore.slots.push(newSlot); env.localStore.activeSlotId = newId; env.localStore.config.customPrompt = newSlot.content;
env.save(); this.renderSlotsList(); promptBox.value = newSlot.content; env.showToast('➕ 创建成功', `卡槽挂载。`);
});
document.getElementById('btn-clear-history').addEventListener('click', () => {
if (confirm("确定要清空历史解析记录吗?")) { env.assetHistory = []; localStorage.setItem(env.HISTORY_KEY, JSON.stringify(env.assetHistory)); this.renderAssetHistoryList(); }
});
document.getElementById('deck-btn-default').addEventListener('click', () => {
this.triggerAutoStateModification(); env.localStore.slots = JSON.parse(JSON.stringify(env.defaultSlots)); env.localStore.activeSlotId = env.defaultSlots[0].id; env.localStore.config.customPrompt = env.defaultSlots[0].content;
env.save(); promptBox.value = env.defaultSlots[0].content; this.renderSlotsList();
});
const bindSnap = (id, type, mode) => {
document.getElementById(id).addEventListener('click', () => {
const k = `${env.DB_KEY}_snap_${type.toLowerCase()}`;
if (mode === 'save') { localStorage.setItem(k, JSON.stringify(env.localStore)); this.refreshManualSandboxesUI(); env.showToast('💾 固化成功', `已锁入快照${type}轨。`); }
else { const d = localStorage.getItem(k); if (!d) return; this.triggerAutoStateModification(); env.localStore = JSON.parse(d); env.save(); promptBox.value = env.localStore.config.customPrompt; this.renderSlotsList(); this.renderStateButtons(); env.showToast('🔙 快照还原', `${type} 轨全量恢复。`); }
});
};
bindSnap('deck-btn-save-a', 'A', 'save'); bindSnap('deck-btn-save-b', 'B', 'save');
bindSnap('deck-btn-back-a', 'A', 'load'); bindSnap('deck-btn-back-b', 'B', 'load');
document.getElementById('mega-btn-export-cfg').addEventListener('click', () => {
const blob = new Blob([JSON.stringify({ version: this.version, config: env.localStore.config, slots: env.localStore.slots }, null, 2)], { type: 'application/json' });
const a = document.createElement('a'); a.href = URL.createObjectURL(blob); a.download = `拾荒小猫_卡槽备份.json`; a.click();
});
document.getElementById('mega-btn-import-cfg').addEventListener('click', () => fileHandler.click());
fileHandler.addEventListener('change', (e) => {
const file = e.target.files[0]; if (!file) return;
const reader = new FileReader(); reader.onload = (ev) => this.processImportData(ev.target.result); reader.readAsText(file);
});
if (typeof GM_setClipboard !== 'undefined') {
document.getElementById('mega-btn-copy-gf').addEventListener('click', () => { GM_setClipboard(net.generateGfCode(env.localStore)); env.showToast('📋 拷贝源码', '就绪'); });
document.getElementById('mega-btn-copy-raw').addEventListener('click', () => { GM_setClipboard(JSON.stringify({ config: env.localStore.config, slots: env.localStore.slots })); env.showToast('📋 备份拷毕', '已存剪贴板'); });
document.getElementById('btn-copy').addEventListener('click', () => { if (env.localStore.tweets.length === 0) return; GM_setClipboard(net.buildPromptText(env.localStore, this.username, this.host)); env.showToast('📋 复制成功', '提示词已装载'); });
}
document.getElementById('mega-btn-dl-gf').addEventListener('click', () => {
const blob = new Blob([net.generateGfCode(env.localStore)], { type: 'application/javascript;charset=utf-8;' });
const a = document.createElement('a'); a.href = URL.createObjectURL(blob); a.download = `拾荒小猫_GF组件.js`; a.click();
});
document.getElementById('btn-download').addEventListener('click', () => { if (env.localStore.tweets.length === 0) return; const blob = new Blob([net.buildPromptText(env.localStore, this.username, this.host)], { type: 'text/markdown;charset=utf-8;' }); const a = document.createElement('a'); a.href = URL.createObjectURL(blob); a.download = `${this.host}_${this.username}_语料.md`; a.click(); });
document.getElementById('btn-run').addEventListener('click', () => { env.localStore.currentPage = 1; env.localStore.lastUrl = ""; env.save(); localStorage.setItem('rp_global_autorun', 'true'); localStorage.setItem('rp_active_key', env.DB_KEY); location.reload(); });
document.getElementById('btn-clear').addEventListener('click', () => { if (confirm(`⚠️ 警告:清空 [👤:${this.username}] 语料缓存吗?`)) { localStorage.removeItem(env.DB_KEY); setTimeout(() => location.reload(), 500); } });
document.getElementById('mega-btn-paste-raw').addEventListener('click', async () => {
if (navigator.clipboard?.readText) { try { this.processImportData(await navigator.clipboard.readText()); return; } catch (err) {} }
if (typeof GM_getClipboard !== 'undefined') { GM_getClipboard((text) => this.processImportData(text)); }
});
document.getElementById('sub-generic-flow').addEventListener('click', () => this.executeRemoteFetchDeploy());
document.getElementById('sub-url-extract').addEventListener('click', () => this.executeRemoteFetchDeploy());
document.getElementById('sub-local-slice').addEventListener('click', () => this.executeRawTextSequenceImport(document.getElementById('mega-api-url').value, false));
document.getElementById('deck-btn-back').addEventListener('click', () => {
if (!env.snapshottedBackup) return; env.localStore = JSON.parse(JSON.stringify(env.snapshottedBackup)); env.save();
promptBox.value = env.localStore.config.customPrompt; this.renderSlotsList(); this.renderStateButtons(); env.snapshottedBackup = null;
document.getElementById('deck-btn-back').className = 'micro-deck-btn btn-deck-grey'; document.getElementById('deck-btn-back').setAttribute('disabled', 'true');
});
document.getElementById('cloud-btn-share').addEventListener('click', () => this.executeCloudShareFlow('share'));
document.getElementById('cloud-btn-update').addEventListener('click', () => this.executeCloudShareFlow('update'));
document.getElementById('cloud-btn-delete').addEventListener('click', () => this.executeCloudShareFlow('delete'));
}
};
window.NitterCorpusLiteCore = LiteCore;
})(window);