// ==UserScript== // @name 小红书摸鱼插件 // @namespace http://tampermonkey.net/ // @version 0.2 // @description 隐藏小红书网页版左上角的logo,便于工作摸鱼 // @author You // @match https://www.xiaohongshu.com/* // @icon https://www.google.com/s2/favicons?domain=xiaohongshu.com // @license MIT // @run-at document-start // @grant none // @downloadURL https://update.greasyfork.icu/scripts/545887/%E5%B0%8F%E7%BA%A2%E4%B9%A6%E6%91%B8%E9%B1%BC%E6%8F%92%E4%BB%B6.user.js // @updateURL https://update.greasyfork.icu/scripts/545887/%E5%B0%8F%E7%BA%A2%E4%B9%A6%E6%91%B8%E9%B1%BC%E6%8F%92%E4%BB%B6.meta.js // ==/UserScript== (function() { 'use strict'; // 立即注入CSS样式到HTML头部,在任何元素渲染前就隐藏logo const injectCSS = () => { const style = document.createElement('style'); style.id = 'xiaohongshu-hide-logo-style'; style.textContent = ` /* 隐藏小红书logo的所有可能选择器 */ img.header-logo, .header-logo, img[src^="data:image/png;base64"], .logo, .header .logo, .nav-logo, .site-logo, a[href="/"] img, .header-container img[alt*="小红书"], .header-container img[alt*="logo"], .header-wrapper img { display: none !important; visibility: hidden !important; opacity: 0 !important; width: 0 !important; height: 0 !important; } /* 强制修改所有按钮样式为文字按钮 - 防止闪烁 */ .reds-button-new, .reds-button-new.follow-button, .note-detail-modal .reds-button-new, .note-detail .reds-button-new, .modal .reds-button-new, .note-scroller .reds-button-new, .feeds-page .reds-button-new, [class*="modal"] .reds-button-new, [class*="dialog"] .reds-button-new, [class*="popup"] .reds-button-new, button[class*="reds-button"], [class*="button"][class*="reds"], .reds-button { background-color: transparent !important; background: transparent !important; background-image: none !important; color: #315efb !important; border: none !important; box-shadow: none !important; transition: none !important; } /* 防止按钮闪烁的通用样式 */ * { --reds-button-bg: transparent !important; --reds-button-color: #315efb !important; } /* 覆盖可能的内联样式 */ .reds-button-new[style*="background"] { background-color: transparent !important; background: transparent !important; } `; // 确保样式被插入到最前面 if (document.head) { document.head.insertBefore(style, document.head.firstChild); } else if (document.documentElement) { document.documentElement.appendChild(style); } }; // 立即执行CSS注入 injectCSS(); // 如果DOM还没准备好,再次确保注入 if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', injectCSS); } // 使用MutationObserver监听动态加载的logo元素 const observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { mutation.addedNodes.forEach(function(node) { if (node.nodeType === 1) { // 检查新添加的节点及其子元素 const logoSelectors = [ 'img.header-logo', '.header-logo', 'img[src^="data:image/png;base64"]', '.logo', '.header .logo', '.nav-logo', '.site-logo', 'a[href="/"] img', '.header-container img', '.header-wrapper img' ]; logoSelectors.forEach(selector => { if (node.matches && node.matches(selector)) { node.style.cssText = 'display: none !important; visibility: hidden !important; opacity: 0 !important; width: 0 !important; height: 0 !important;'; } const childElements = node.querySelectorAll && node.querySelectorAll(selector); if (childElements) { childElements.forEach(el => { el.style.cssText = 'display: none !important; visibility: hidden !important; opacity: 0 !important; width: 0 !important; height: 0 !important;'; }); } }); } }); }); }); // 当DOM准备好时开始观察 const startObserver = () => { if (document.body) { observer.observe(document.body, { childList: true, subtree: true }); } }; if (document.body) { startObserver(); } else { document.addEventListener('DOMContentLoaded', startObserver); } // 修改浏览器标签页图标(favicon) const changeFavicon = () => { // 移除现有的favicon const existingFavicons = document.querySelectorAll('link[rel*="icon"]'); existingFavicons.forEach(favicon => favicon.remove()); // 创建新的favicon - 使用Group 3图标 const newFavicon = document.createElement('link'); newFavicon.rel = 'icon'; newFavicon.type = 'image/svg+xml'; // 使用Group 3 SVG图标 newFavicon.href = 'data:image/svg+xml;base64,' + btoa(` `); document.head.appendChild(newFavicon); // 修改页面标题为百度相关内容 if (document.title.includes('小红书') || document.title.includes('工作文档')) { document.title = '百度一下,你就知道'; } }; // 立即执行favicon修改 changeFavicon(); // 页面加载完成后的处理 window.addEventListener('load', function() { // 修改按钮样式为文字按钮 const modifyButtonStyles = () => { // 修改关注按钮 const followButtons = document.querySelectorAll('.reds-button-new.follow-button'); followButtons.forEach(btn => { btn.style.backgroundColor = 'transparent !important'; btn.style.color = '#315efb !important'; btn.style.border = 'none !important'; }); // 修改弹出内容中的按钮 const modalButtons = document.querySelectorAll('.note-detail-modal .reds-button-new, .note-detail .reds-button-new, .modal .reds-button-new'); modalButtons.forEach(btn => { btn.style.backgroundColor = 'transparent !important'; btn.style.color = '#315efb !important'; btn.style.border = 'none !important'; }); // 修改所有可能的按钮 const allButtons = document.querySelectorAll('.reds-button-new'); allButtons.forEach(btn => { if (btn.style.backgroundColor && btn.style.backgroundColor !== 'transparent') { btn.style.backgroundColor = 'transparent !important'; btn.style.color = '#315efb !important'; btn.style.border = 'none !important'; } }); }; modifyButtonStyles(); // 监听弹出内容的按钮变化 const buttonObserver = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { mutation.addedNodes.forEach(function(node) { if (node.nodeType === 1) { // 检查新添加的按钮元素 if (node.matches && node.matches('.reds-button-new')) { node.style.backgroundColor = 'transparent !important'; node.style.color = '#315efb !important'; node.style.border = 'none !important'; } const newButtons = node.querySelectorAll && node.querySelectorAll('.reds-button-new'); if (newButtons) { newButtons.forEach(btn => { btn.style.backgroundColor = 'transparent !important'; btn.style.color = '#315efb !important'; btn.style.border = 'none !important'; }); } } }); }); }); // 开始监听按钮变化 if (document.body) { buttonObserver.observe(document.body, { childList: true, subtree: true }); } // 最终确保所有可能的logo都被隐藏 const logoSelectors = [ 'img.header-logo', '.header-logo', 'img[src^="data:image/png;base64"]', '.logo', '.header .logo', '.nav-logo', '.site-logo', 'a[href="/"] img', '.header-container img', '.header-wrapper img' ]; logoSelectors.forEach(selector => { const elements = document.querySelectorAll(selector); elements.forEach(el => { el.style.cssText = 'display: none !important; visibility: hidden !important; opacity: 0 !important; width: 0 !important; height: 0 !important;'; }); }); // 再次确保favicon和标题被修改 changeFavicon(); }); })();