diff --git a/js/Bangumi_Topic_Share.js b/js/Bangumi_Topic_Share.js index d0f1809..8c4416a 100644 --- a/js/Bangumi_Topic_Share.js +++ b/js/Bangumi_Topic_Share.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Bangumi Topic Share // @namespace http://tampermonkey.net/ -// @version 5.2 +// @version 5.3 // @description Bangumi 话题/日志分享工具:生成分享卡片,支持图片复制/下载、一键复制分享文案、可选 AI 标签 // @author Stardream // @contributor Chang ji, Mewtw0 @@ -356,7 +356,7 @@
- ${base64CharImage ? `
${pureTitle}
${badgeLabel}
` : badgeLabel ? `
${pureTitle}
${badgeLabel}
` : ''} + ${base64CharImage ? `
${pureTitle}
${badgeLabel}
` : badgeLabel ? `
${pureTitle}
${badgeLabel}
` : ''} ${username ? `
@@ -490,8 +490,12 @@ const iDoc = iframe.contentDocument; const iStyle = iDoc.createElement('style'); const maskCss = maskRevealed ? '[data-bgm-mask] { color: #fff !important; }' : ''; - const sampleLink = contentDoc.querySelector('a') || document.querySelector('a'); - const linkColor = sampleLink ? getComputedStyle(sampleLink).color : (dark ? '#8ec8e8' : '#0066cc'); + const sampleLink = contentDoc.querySelector('.topic_content a[href], #entry_content a[href], .message a[href]') + || contentDoc.querySelector('a[href^="http"]') + || contentDoc.querySelector('a[href]'); + const rawLinkColor = sampleLink ? getComputedStyle(sampleLink).color : ''; + const linkColor = rawLinkColor && rawLinkColor !== 'rgba(0, 0, 0, 0)' && rawLinkColor !== 'transparent' + ? rawLinkColor : (dark ? '#8ec8e8' : '#0066cc'); const sampleLinkDecoration = sampleLink ? getComputedStyle(sampleLink).textDecorationLine : 'none'; iStyle.textContent = style.innerHTML + maskCss + ` a { color: ${linkColor}; text-decoration: ${sampleLinkDecoration}; }`; iDoc.head.appendChild(iStyle);