您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
移除Linux.do网站上class为global-notice的公告栏
// ==UserScript== // @name Linux.do - 移除全局公告栏 // @namespace https://linux.do/ // @version 1.0 // @description 移除Linux.do网站上class为global-notice的公告栏 // @author Dahi // @match https://linux.do/* // @grant none // @run-at document-end // @license MIT // ==/UserScript== (function() { 'use strict'; // 移除全局公告栏函数 function removeGlobalNotice() { // 使用更精确的选择器,避免误删 const notice = document.querySelector('div.global-notice'); if (notice) { notice.remove(); console.log('已移除Linux.do全局公告栏'); } } // 使用MutationObserver监控DOM变化 const observer = new MutationObserver(function(mutations) { for (const mutation of mutations) { if (mutation.type === 'childList') { // 检查新增节点中是否包含公告栏 for (const node of mutation.addedNodes) { if (node.nodeType === Node.ELEMENT_NODE) { if (node.classList && node.classList.contains('global-notice')) { node.remove(); } else if (node.querySelector('div.global-notice')) { removeGlobalNotice(); } } } } } }); // 初始执行 removeGlobalNotice(); // 开始观察文档变化 observer.observe(document, { childList: true, subtree: true }); // 页面完全加载后再检查一次 window.addEventListener('load', removeGlobalNotice); // 清理observer window.addEventListener('unload', function() { observer.disconnect(); }); // 针对Turbolinks等PJAX导航的页面 document.addEventListener('turbolinks:load', removeGlobalNotice); document.addEventListener('pjax:complete', removeGlobalNotice); })();