/* v27: AI 回复长按/右键操作:保存到我的生成库/复制/分享;我的页生成库入口 */ (function () { 'use strict'; if (window.__mobV27) return; window.__mobV27 = true; var K = 'v27lib_v1'; function $(id) { return document.getElementById(id); } function esc(s) { return String(s == null ? '' : s).replace(/[&<>"']/g, function (c) { return { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]; }); } function tip(t) { try { var o = $('v27tip'); if (o) o.remove(); var d = document.createElement('div'); d.id = 'v27tip'; d.style.cssText = 'position:fixed;left:50%;bottom:120px;transform:translateX(-50%);z-index:49500;background:#0f172a;color:#fff;font-size:13px;padding:9px 16px;border-radius:18px;max-width:84%;text-align:center;'; d.textContent = t; document.body.appendChild(d); setTimeout(function () { d.remove(); }, 2200); } catch (e) {} } function txtOf(b) { var c = b && (b.querySelector('.bubble-content') || b.querySelector('[class*="content"]')); return c ? (c.innerText || '').trim() : ''; } function lib() { try { return JSON.parse(localStorage.getItem(K) || '[]'); } catch (e) { return []; } } function saveLib(a) { try { localStorage.setItem(K, JSON.stringify(a.slice(0, 500))); } catch (e) {} } function copyT(t) { if (navigator.clipboard && navigator.clipboard.writeText) { navigator.clipboard.writeText(t).then(function () { tip('✅ 已复制'); }, function () { fb(t); }); } else fb(t); } function fb(t) { try { var ta = document.createElement('textarea'); ta.value = t; document.body.appendChild(ta); ta.select(); document.execCommand('copy'); ta.remove(); tip('✅ 已复制'); } catch (e) { tip('复制失败,可长按文本手动复制'); } } function shareT(t) { try { if (navigator.share) { navigator.share({ title: '多维鹰 AI 生成内容', text: t }).catch(function () {}); } else { fb(t); tip('已复制,可粘贴分享'); } } catch (e) { fb(t); } } function actBar(b, x, y) { var old = $('v27bar'); if (old) old.remove(); var t = txtOf(b); if (!t) return; var bar = document.createElement('div'); bar.id = 'v27bar'; bar.style.cssText = 'position:fixed;left:' + Math.max(8, Math.min(x - 30, window.innerWidth - 260)) + 'px;top:' + Math.max(52, y - 46) + 'px;z-index:46000;background:#1e293b;color:#fff;border-radius:12px;padding:6px;display:flex;gap:2px;box-shadow:0 6px 20px rgba(0,0,0,.3);'; bar.innerHTML = '' + '' + ''; document.body.appendChild(bar); bar.onclick = function (e) { var btn = e.target && e.target.closest('button'); if (!btn) return; var a = btn.getAttribute('data-a'); bar.remove(); if (a === 's') { var l = lib(); l.unshift({ t: t.slice(0, 600), ts: new Date().toISOString() }); saveLib(l); tip('✅ 已保存到「我的生成库」(我的页查看)'); } else if (a === 'c') copyT(t); else if (a === 'h') shareT(t); }; setTimeout(function () { var b2 = $('v27bar'); if (b2) b2.remove(); }, 8000); } function bindChat() { var wrap = $('ai-chat-wrapper'); if (!wrap || wrap._v27b) return; wrap._v27b = true; wrap.addEventListener('contextmenu', function (e) { var b = e.target && e.target.closest('.message-bubble'); if (!b) return; e.preventDefault(); actBar(b, e.clientX, e.clientY); }); var x0 = 0, y0 = 0, t0 = 0; wrap.addEventListener('touchstart', function (e) { var b = e.target && e.target.closest('.message-bubble'); if (!b) return; x0 = e.touches && e.touches[0] ? e.touches[0].clientX : 0; y0 = e.touches && e.touches[0] ? e.touches[0].clientY : 0; t0 = Date.now(); }, { passive: true }); wrap.addEventListener('touchend', function (e) { var b = e.target && e.target.closest('.message-bubble'); if (!b) return; var ch = e.changedTouches && e.changedTouches[0]; var dx = Math.abs((ch ? ch.clientX : 0) - x0), dy = Math.abs((ch ? ch.clientY : 0) - y0); if (dx < 10 && dy < 10 && Date.now() - t0 > 480) { e.preventDefault(); actBar(b, ch ? ch.clientX : 100, ch ? ch.clientY : 100); } x0 = 0; y0 = 0; t0 = 0; }, { passive: true }); } function openLib() { var l = lib(); var p = document.createElement('div'); p.id = 'v27Lib'; p.style.cssText = 'position:fixed;inset:0;z-index:45000;background:#f1f5f9;display:flex;flex-direction:column;'; var items = l.length ? l.map(function (it, i) { return '
' + '
' + esc(it.t) + '
' + '
' + esc(String(it.ts).substring(0, 16).replace('T', ' ')) + '' + '' + '
'; }).join('') : '
暂无保存内容
长按 AI 回复可选 保存/复制/分享
'; p.innerHTML = '
📚 我的生成库
' + '
' + items + '
'; document.body.appendChild(p); $('v27Lb').onclick = function () { p.remove(); }; } window.v27CopyOne = function (i) { var l = lib(); if (l[i]) copyT(l[i].t); }; window.v27DelOne = function (i) { var l = lib(); l.splice(i, 1); saveLib(l); var x = $('v27Lib'); if (x) x.remove(); openLib(); }; window.v27OpenLib = openLib; function addMenu() { var pc = $('profile-container'); if (!pc || pc._v27m) return; var t = setInterval(function () { if (!pc.querySelector('[data-v23m]')) return; clearInterval(t); if (pc._v27m) return; pc._v27m = true; var mk = document.createElement('div'); mk.setAttribute('data-v23m', 'mobLib'); mk.style.cssText = 'background:#fff;border-radius:12px;margin:10px;padding:12px;box-shadow:0 1px 4px rgba(15,23,42,.08);display:flex;align-items:center;justify-content:space-between;cursor:pointer;'; mk.innerHTML = '📚 我的生成库›'; var first = pc.querySelector('[data-v23m]'); pc.insertBefore(mk, first); var cb = pc.onclick; pc.onclick = function (e) { var r = e.target && e.target.closest('[data-v23m]'); if (r && r.getAttribute('data-v23m') === 'mobLib') { v27OpenLib(); return; } if (cb) cb(e); }; }, 500); } function boot() { bindChat(); addMenu(); } if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', boot); else boot(); setTimeout(boot, 1500); setTimeout(boot, 3000); console.log('[MobV27] 长按保存/复制/分享就绪'); })();