// ==UserScript== // @name 微博超话美化助手(固定图标+图文右排+最新动态底行) // @namespace http://tampermonkey.net/ // @version 1.2 // @description 美化微博超话JSON数据展示,固定图标尺寸,图文右排,最新动态单独一行 // @author DrS // @match https://weibo.com/ajax/profile/topicContent?* // @grant GM_xmlhttpRequest // @grant GM_addStyle // ==/UserScript== (function() { 'use strict'; // 注入样式 // 注入样式 GM_addStyle(` body { margin: 0; padding: 0; font-family: sans-serif; background: #f5f5f5; width: 100%; margin-left: calc((100vw - 100%) / 2); box-shadow: 0 0 10px rgba(0,0,0,0.2); border-radius: 8px; overflow: hidden; } .container { padding: 10px; background: #fff; } h1 { font-size: 21px; /* 原来的14px放大1.5倍 */ text-align: center; color: #1da1f2; margin-bottom: 10px; } .topic-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; } .topic-card { background: #fafafa; border: 1px solid #ddd; border-radius: 4px; overflow: hidden; font-size: 18px; /* 原来的12px放大1.5倍 */ display: flex; flex-direction: column; justify-content: space-between; padding: 8px; } .topic-header { display: flex; align-items: flex-start; gap: 8px; } .topic-image { width: 64px; height: 64px; object-fit: cover; } .topic-info { display: flex; flex-direction: column; justify-content: space-between; flex-grow: 1; min-width: 0; /* 防止溢出 */ } .topic-title { font-weight: bold; color: #333; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .topic-meta { font-size: 15px; /* 原来的10px放大1.5倍 */ color: #666; display: flex; flex-wrap: wrap; gap: 4px; padding-top: 8px; } .topic-latest { font-size: 15px; /* 原来的10px放大1.5倍 */ color: #999; margin-top: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-overflow: ellipsis; } .back-btn { margin-top: 10px; padding: 6px 0; background: #1da1f2; color: white; border: none; border-radius: 4px; font-size: 18px; /* 原来的12px放大1.5倍 */ width: 100%; } `); const container = document.createElement('div'); container.className = 'container'; const title = document.createElement('h1'); title.textContent = '我关注的超话'; container.appendChild(title); const grid = document.createElement('div'); grid.className = 'topic-grid'; function fetchData() { let jsonData; try { jsonData = JSON.parse(document.body.textContent); } catch (e) { GM_xmlhttpRequest({ method: 'GET', url: window.location.href, onload: function(response) { try { const data = JSON.parse(response.responseText); renderTopics(data.data.list); } catch (e) { alert('解析失败'); } } }); return; } if (jsonData?.data?.list) { renderTopics(jsonData.data.list); } } function renderTopics(topics) { topics.forEach(topic => { const card = document.createElement('div'); card.className = 'topic-card'; card.innerHTML = `
${topic.title}
${topic.title}
粉丝:${formatNumber(topic.follow_count)} 动态:${formatNumber(topic.status_count)}
动态:${topic.latest_status || '无'}
`; grid.appendChild(card); }); container.appendChild(grid); const backBtn = document.createElement('button'); backBtn.className = 'back-btn'; backBtn.textContent = '返回首页'; backBtn.onclick = () => window.location.href = 'https://weibo.com/'; container.appendChild(backBtn); document.body.innerHTML = ''; document.body.appendChild(container); } // 数字格式化(千分位) function formatNumber(num) { if (num >= 10000) return (num / 10000).toFixed(1) + '万'; return num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,'); } fetchData(); })();