From 3b92b929a96f4554763d451eb664418186c69b33 Mon Sep 17 00:00:00 2001 From: Stardream Date: Thu, 16 Jul 2026 11:47:33 +1000 Subject: [PATCH] =?UTF-8?q?feat(Bangumi=5FTopic=5FShare):=20add=20?= =?UTF-8?q?=E8=B4=B4=E8=B4=B4=20reactions=20visibility=20toggle=20and=20de?= =?UTF-8?q?fault=20setting,=20bump=20to=206.6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/Bangumi Topic Share/Bangumi_Topic_Share.js | 50 ++++++++++++++++++- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/js/Bangumi Topic Share/Bangumi_Topic_Share.js b/js/Bangumi Topic Share/Bangumi_Topic_Share.js index 743d675..701da88 100644 --- a/js/Bangumi Topic Share/Bangumi_Topic_Share.js +++ b/js/Bangumi Topic Share/Bangumi_Topic_Share.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Bangumi Topic Share // @namespace https://greasyfork.org/scripts/574689 -// @version 6.5 +// @version 6.6 // @description Bangumi 分享工具:生成分享卡片,支持图片复制/下载、一键复制分享文案、贴贴反应展示、可选 AI 标签 // @author Stardream // @contributor Chang ji, Mewtw0 @@ -53,6 +53,7 @@ // @match *://bgm.tv/ // @match *://bangumi.tv/ // @match *://chii.in/ +// @icon https://bgm.tv/img/favicon.ico // @grant GM_xmlhttpRequest // @grant GM_getValue // @grant GM_setValue @@ -586,6 +587,9 @@ + `; @@ -598,10 +602,13 @@ let cancelled = false; let maskRevealed = false; + let reactionsHidden = !GM_getValue('bgm_share_show_reactions', true); let currentCanvas = null; const maskPreviewStyle = document.createElement('style'); document.head.appendChild(maskPreviewStyle); + const reactionsPreviewStyle = document.createElement('style'); + document.head.appendChild(reactionsPreviewStyle); const copyBtn = document.getElementById('bgm-copy-btn'); const downloadBtn = document.getElementById('bgm-download-btn'); @@ -609,6 +616,9 @@ const hasMask = !!document.querySelector('#capture-area [data-bgm-mask]'); if (!hasMask) document.getElementById('bgm-mask-btn').style.display = 'none'; + const hasReactions = !!document.querySelector('#capture-area .reactions-row'); + if (!hasReactions) document.getElementById('bgm-reactions-btn').style.display = 'none'; + const updateMaskPreview = () => { maskPreviewStyle.textContent = maskRevealed ? '#capture-area [data-bgm-mask] { color: #fff !important; }' @@ -618,10 +628,20 @@ }; updateMaskPreview(); + const updateReactionsPreview = () => { + reactionsPreviewStyle.textContent = reactionsHidden + ? '#capture-area .reactions-row { display: none !important; }' + : ''; + const btn = document.getElementById('bgm-reactions-btn'); + if (btn) btn.setAttribute('data-tip', reactionsHidden ? '显示贴贴' : '隐藏贴贴'); + }; + updateReactionsPreview(); + overlay.addEventListener('click', (e) => { if (e.target === overlay) { cancelled = true; maskPreviewStyle.remove(); + reactionsPreviewStyle.remove(); overlay.remove(); } }); @@ -650,6 +670,12 @@ doCapture(); }); + document.getElementById('bgm-reactions-btn').addEventListener('click', () => { + reactionsHidden = !reactionsHidden; + updateReactionsPreview(); + doCapture(); + }); + copyBtn.addEventListener('click', async () => { if (!currentCanvas) return; try { @@ -723,6 +749,7 @@ const iDoc = iframe.contentDocument; const iStyle = iDoc.createElement('style'); const maskCss = maskRevealed ? '[data-bgm-mask] { color: #fff !important; }' : ''; + const reactionsCss = reactionsHidden ? '.reactions-row { display: none !important; }' : ''; const sampleLink = contentDoc.querySelector('.topic_content a[href], #entry_content a[href], .message a[href], .statusContent .text a[href], .subReply a.l[href]') || contentDoc.querySelector('a[href^="http"]') || contentDoc.querySelector('a[href]'); @@ -764,7 +791,7 @@ if (bodyColor) quoteCss += `.content-text{color:${bodyColor} !important;}`; } } catch (e) {} - iStyle.textContent = style.innerHTML + maskCss + quoteCss + ` a { color: ${linkColor} !important; text-decoration: ${sampleLinkDecoration}; } span[style*="line-through"], span[style*="line-through"] * { text-decoration: line-through !important; text-decoration-color: white !important; }`; + iStyle.textContent = style.innerHTML + maskCss + reactionsCss + quoteCss + ` a { color: ${linkColor} !important; text-decoration: ${sampleLinkDecoration}; } span[style*="line-through"], span[style*="line-through"] * { text-decoration: line-through !important; text-decoration-color: white !important; }`; iDoc.head.appendChild(iStyle); iDoc.body.style.cssText = 'margin:0;padding:0;background:transparent;display:inline-block;'; iDoc.body.innerHTML = captureEl.innerHTML; @@ -1848,6 +1875,7 @@ const aiUrl = GM_getValue('bgm_share_ai_url', ''); const aiKey = GM_getValue('bgm_share_ai_key', ''); const aiModel = GM_getValue('bgm_share_ai_model', '') || 'gpt-3.5-turbo'; + const showReactions = GM_getValue('bgm_share_show_reactions', true); const tabDiv = document.createElement('div'); tabDiv.className = 'tab-content'; @@ -1865,6 +1893,19 @@ +
+
默认展示贴贴反应
+
+
+ + +
+
+ + +
+
+
AI 标签配置(可选)
@@ -1894,6 +1935,11 @@ tabDiv.querySelector('#bgm-share-auth-btn').style.display = ''; tabDiv.querySelector('#bgm-share-deauth-btn').style.display = 'none'; }); + tabDiv.querySelectorAll('input[name="bgm-share-reactions"]').forEach(r => { + r.addEventListener('change', e => { + GM_setValue('bgm_share_show_reactions', e.target.value === 'on'); + }); + }); tabDiv.querySelector('#bgm-share-ai-save').addEventListener('click', () => { GM_setValue('bgm_share_ai_url', tabDiv.querySelector('#bgm-share-ai-url').value); GM_setValue('bgm_share_ai_key', tabDiv.querySelector('#bgm-share-ai-key').value);