// ==UserScript==
// @name MWCA-让微博重新干净(又卫生)
// @namespace http://tampermonkey.net/
// @version 1.0
// @description 让微博重新干净(又卫生)
// @author qiqikuka
// @match https://weibo.com/*
// @grant GM_addStyle
// @run-at document-start
// @license CC BY-NC-SA 4.0 (禁止商业用途)
// @downloadURL https://update.greasyfork.icu/scripts/557875/MWCA-%E8%AE%A9%E5%BE%AE%E5%8D%9A%E9%87%8D%E6%96%B0%E5%B9%B2%E5%87%80%EF%BC%88%E5%8F%88%E5%8D%AB%E7%94%9F%EF%BC%89.user.js
// @updateURL https://update.greasyfork.icu/scripts/557875/MWCA-%E8%AE%A9%E5%BE%AE%E5%8D%9A%E9%87%8D%E6%96%B0%E5%B9%B2%E5%87%80%EF%BC%88%E5%8F%88%E5%8D%AB%E7%94%9F%EF%BC%89.meta.js
// ==/UserScript==
(function() {
'use strict';
// --- CSS 注入区 (核心:导航栏完全原生 + 优化) ---
GM_addStyle(`
/* ======================================= */
/* === 核心样式:导航栏原生正常 + 所有有效优化保留 === */
/* ======================================= */
:root {
--mid-width: 960px !important;
--simple-width: 960px !important;
--main-width: 960px !important;
--left-width: 0px !important;
--mini-left-width: 0px !important;
--right-width: 0px !important;
--weibo-top-nav-borderTop: none !important;
}
/* 移除指定模块 + 强化VIP图标屏蔽 + 移除图片工具栏冗余图标 */
.index_box_MkWee,
.hotBand,
.wbpro-side.woo-panel-main,
.Main_sideMain_263ZF,
.Main_side_i7Vti,
.Nav_main_32v4H,
.Frame_side_3G0Bf,
.Links_box_17T3k,
.RepostCommentFeed_mar2_3V2Sd,
.Search_senior_19eQR, /* V33.4 移除搜索高级选项 */
span.woo-icon-main.woo-icon-vip,
span[class="woo-icon-main woo-icon-vip"],
[class*="woo-icon-vip"].woo-icon-main,
[class*="woo-icon-main"][class*="woo-icon-vip"],
.woo-icon-vip.woo-icon-main,
.Nav_top_1X6G5,
.woo-font.woo-font--imgFold.picture-tool-bar_icon_3UbxU,
.woo-font.woo-font--imgRotate.picture-tool-bar_icon_3UbxU,
.woo-font.woo-font--imgFull.picture-tool-bar_icon_3UbxU
{
display: none !important;
visibility: hidden !important;
opacity: 0 !important;
width: 0 !important;
height: 0 !important;
border-top: none !important;
pointer-events: none !important;
}
/* 核心配置:父容器max-width=960px,无错位 */
.picture-viewer_wrap_1GrIH {
background: #f9f9f9 !important;
background: var(--feed-retweet-bg) !important;
margin-left: -80px !important;
padding: 10px 0 10px 80px !important;
max-width: 960px !important;
position: relative !important;
overflow: visible !important;
}
/* 核心配置:强制图片包裹层height:auto */
.picture-viewer_imgWrap_ICKHT {
width: 860px !important;
position: relative !important;
display: -webkit-box !important;
display: -ms-flexbox !important;
display: flex !important;
-webkit-box-align: center !important;
-ms-flex-align: center !important;
align-items: center !important;
-webkit-box-pack: center !important;
justify-content: center !important;
overflow: hidden !important;
height: auto !important;
min-height: auto !important;
max-height: none !important;
}
/* 图片容器:860px固定宽度,高度自适应 */
.picture-viewer_pic_37YQ3 {
border-radius: 4px !important;
-o-object-fit: contain !important;
object-fit: contain !important;
cursor: -webkit-zoom-out !important;
cursor: zoom-out !important;
width: 860px !important;
max-width: 860px !important;
position: relative !important;
z-index: 1 !important;
height: auto !important;
display: block !important;
margin: 0 auto !important;
}
/* 左侧遮罩 */
.picture-viewer_leftMask_31Sib.picture-viewer_mask_2e9KD {
position: absolute !important;
z-index: 10 !important;
left: 0 !important;
top: 0 !important;
bottom: 0 !important;
width: 50px !important;
height: 100% !important;
max-width: none !important;
margin: 0 !important;
padding: 0 !important;
background: linear-gradient(to right, rgba(0,0,0,0.3), transparent) !important;
pointer-events: auto !important;
}
/* 右侧遮罩 */
.picture-viewer_rightMask_3Rvy2.picture-viewer_mask_2e9KD {
position: absolute !important;
z-index: 10 !important;
right: 0 !important;
top: 0 !important;
bottom: 0 !important;
width: 50px !important;
height: 100% !important;
max-width: none !important;
margin: 0 !important;
padding: 0 !important;
background: linear-gradient(to left, rgba(0,0,0,0.3), transparent) !important;
pointer-events: auto !important;
}
/* 布局调整 */
.Main_wrap_2GRrG,
.Main_full_1dfQX,
.Home_feed_3o7ry {
max-width: none !important;
margin-left: auto !important;
margin-right: auto !important;
}
.picture_inlineNum3_3P7k1 {
width: 100% !important;
}
.u-col-3 [class*=box-item],
.u-col-3 [data-type=w-box-item] {
width: 50% !important;
}
/* V33.4 修改:内容卡片圆角保持 18px */
.wbpro-feed-content {
font-size: 18px !important;
font-weight: 500 !important;
line-height: 1.6 !important;
}
/* V33.5 新增:文字截断字号调整 */
.wbpro-textcut {
font-size: 13px !important;
}
.Feed_wrap_3v9LH,
div[class*="Feed_wrap_"] {
border-radius: 18px !important;
overflow: hidden !important;
border: 1px solid rgba(0,0,0,0.05);
}
/* V33.4 修改:侧边栏 SecBar_visable_16JHY 及其内部卡片圆角更新为 23px */
.SecBar_visable_16JHY,
.SecBar_visable_16JHY .Card_wrap_2ibWe {
border-radius: 23px !important;
overflow: hidden !important; /* 确保内容在圆角内部被裁剪 */
}
/* SVG 基础样式 */
.Nav_logo_1BwBq svg,
[data-custom-icon="true"] {
display: block !important;
object-fit: contain !important;
preserveAspectRatio: xMidYMid meet !important;
}
/* 回顶部按钮(基础样式 - 日间模式) */
.BackTop_main_3m3aB {
width: 40px !important;
height: 40px !important;
border-radius: 50% !important;
overflow: hidden !important;
background-color: #ffffff !important; /* 日间默认白色 */
box-shadow: 0 4px 16px 3px rgba(0, 0, 0, 0.04) !important;
display: flex !important;
align-items: center !important;
justify-content: center !important;
padding: 10px !important;
transition: box-shadow 0.3s ease, background-color 0.3s ease !important;
}
.BackTop_main_3m3aB:hover {
box-shadow: 0 6px 20px 4px rgba(0, 0, 0, 0.06) !important;
}
.BackTop_mainin_1sH8n {
width: 100% !important;
height: 100% !important;
border-radius: 50% !important;
padding: 0 !important;
margin: 0 !important;
display: flex !important;
align-items: center !important;
justify-content: center !important;
}
/* V33.0 修改:回顶部 SVG 图标样式 (向上移动 4px) */
.BackTop_main_3m3aB svg,
.BackTop_mainin_1sH8n svg {
width: 20px !important;
height: 20px !important;
margin: auto !important;
color: #666666 !important;
opacity: 0.4 !important;
flex-shrink: 0 !important;
transition: opacity 0.2s ease !important;
transform: translateY(-2px) !important;
}
.BackTop_main_3m3aB:hover svg {
opacity: 0.8 !important;
}
/* ======================================= */
/* === 修复:图标颜色与夜间模式支持 === */
/* ======================================= */
.IconBox_btn_10GoC.IconBox_wrap_W3Oz_ {
display: flex !important;
align-items: center !important;
justify-content: center !important;
padding: 6px !important;
}
.IconBox_btn_10GoC.IconBox_wrap_W3Oz_ [data-custom-icon="true"] {
fill: currentColor !important;
color: inherit !important;
transition: transform 0.2s ease !important;
width: 16px !important;
height: 16px !important;
}
.IconBox_btn_10GoC.IconBox_wrap_W3Oz_:hover [data-custom-icon="true"] {
transform: scale(1.05) !important;
}
.IconBox_wrap_W3Oz_.IconBox_pub_1zIJ8 .IconBox_icon_1dS2Y,
.IconBox_wrap_W3Oz_.IconBox_pub_1zIJ8 svg {
color: #ffffff !important;
color: var(--w-contrast, #ffffff) !important;
fill: currentColor !important;
}
@media (prefers-color-scheme: dark) {
.IconBox_wrap_W3Oz_ .IconBox_icon_1dS2Y {
color: #ffffff !important;
}
}
/* ======================================= */
/* === 回顶部按钮夜间模式背景修正 === */
/* ======================================= */
/* 1. 系统级夜间模式 */
@media (prefers-color-scheme: dark) {
.BackTop_main_3m3aB {
background-color: rgba(255, 255, 255, 0.15) !important;
}
}
/* 2. 微博网页内部切换夜间模式 */
html[theme="dark"] .BackTop_main_3m3aB,
html[data-theme="dark"] .BackTop_main_3m3aB,
body[class*="dark"] .BackTop_main_3m3aB {
background-color: rgba(255, 255, 255, 0.15) !important;
}
`);
// --- DOM 操作 ---
// SVG 定义
const customLogoSvg = `
`.trim();
const customBackToTopSvg = `
`.trim();
const customConfigSvg = `
`.trim();
/**
* 辅助函数:创建 SVG 元素
*/
function createSvgElement(svgString) {
try {
const tempDiv = document.createElement('div');
tempDiv.innerHTML = svgString;
return tempDiv.firstChild || null;
} catch (e) {
console.error("创建SVG容错:", e);
return null;
}
}
/**
* 核心功能函数
*/
function replaceLogo() {
try {
const logoWrapper = document.querySelector('.Nav_logo_1BwBq');
if (logoWrapper && !logoWrapper.dataset.customLogo && logoWrapper.children.length > 0) {
const newSvg = createSvgElement(customLogoSvg);
if (newSvg) {
newSvg.style.height = '36px';
newSvg.style.width = 'auto';
logoWrapper.replaceChild(newSvg, logoWrapper.children[0]);
logoWrapper.dataset.customLogo = 'true';
}
}
} catch (e) {
console.error("替换Logo容错:", e);
}
}
function replaceBackToTopIcon() {
try {
const backTopButton = document.querySelector('.BackTop_main_3m3aB');
const parentContainer = document.querySelector('.BackTop_mainin_1sH8n') || backTopButton;
if (parentContainer && !parentContainer.dataset.backTopReplaced) {
const originalIcon = parentContainer.querySelector('.woo-font--backTop') || parentContainer.querySelector('svg');
if (originalIcon) {
const newSvg = createSvgElement(customBackToTopSvg);
if (newSvg) {
newSvg.style.width = '20px !important';
newSvg.style.height = '20px !important';
newSvg.style.color = '#666666 !important';
newSvg.style.opacity = '0.4 !important';
newSvg.style.flexShrink = '0';
originalIcon.parentNode.replaceChild(newSvg, originalIcon);
parentContainer.dataset.backTopReplaced = 'true';
}
}
}
} catch (e) {
console.error("替换回顶部图标容错:", e);
}
}
function replaceConfigIcon() {
try {
const configButtons = document.querySelectorAll('button.IconBox_btn_10GoC.IconBox_wrap_W3Oz_[title="设置"]');
configButtons.forEach(button => {
if (button.dataset.configReplaced) return;
const originalIcon = button.querySelector('svg') || button.querySelector('use');
if (originalIcon) {
const newSvg = createSvgElement(customConfigSvg);
if (newSvg) {
newSvg.style.width = '16px !important';
newSvg.style.height = '16px !important';
newSvg.style.color = 'inherit';
newSvg.style.margin = 'auto';
button.innerHTML = '';
button.appendChild(newSvg);
button.dataset.configReplaced = 'true';
}
}
});
} catch (e) {
console.error("替换配置图标容错:", e);
}
}
function removeTopNavBorder() {
try {
document.documentElement.style.setProperty('--weibo-top-nav-borderTop', 'none !important');
const topNavElements = document.querySelectorAll('.Nav_top_1X6G5, .Nav_wrap_2w2Ly, header');
topNavElements.forEach(el => {
el.style.borderTop = 'none !important';
});
} catch (e) {
console.error("移除顶部边框容错:", e);
}
}
function removeVipIcons() {
try {
const vipSelectors = [
'span.woo-icon-main.woo-icon-vip',
'span[class="woo-icon-main woo-icon-vip"]',
'[class*="woo-icon-vip"].woo-icon-main',
'[class*="woo-icon-main"][class*="woo-icon-vip"]',
'.woo-icon-vip.woo-icon-main',
'i.woo-icon-main.woo-icon-vip',
'div.woo-icon-main.woo-icon-vip'
];
const allVipIcons = [...new Set(vipSelectors.flatMap(selector =>
Array.from(document.querySelectorAll(selector))
))];
allVipIcons.forEach(icon => {
if (icon.parentNode) {
const parent = icon.parentNode;
if (parent.classList.length === 1 && parent.classList.contains('woo-icon-wrap')) {
parent.remove();
} else {
icon.remove();
}
} else {
icon.remove();
}
});
} catch (e) {
console.error("移除VIP图标容错:", e);
}
}
// --- MutationObserver ---
const observer = new MutationObserver((mutationsList, observer) => {
try {
replaceLogo();
replaceBackToTopIcon();
replaceConfigIcon();
removeTopNavBorder();
removeVipIcons();
} catch (e) {
console.error("Observer容错:", e);
}
});
observer.observe(document.body, {
childList: true,
subtree: true,
attributes: true,
attributeFilter: ['class', 'title']
});
// --- 首次执行 + 延迟重试 ---
setTimeout(() => {
replaceLogo();
replaceBackToTopIcon();
replaceConfigIcon();
removeTopNavBorder();
removeVipIcons();
}, 100);
setTimeout(() => {
removeVipIcons();
}, 300);
setTimeout(() => {
removeVipIcons();
}, 800);
setTimeout(() => {
removeVipIcons();
}, 2000);
})();