// ==UserScript== // @name hao123极简导航 // @namespace hao123MacOS // @version 1.0.0 // @author FBin001 // @icon https://www.hao123.com/favicon.ico // @description hao123极简风格导航 // @match *://www.hao123.com // @grant none // @license MIT // ==/UserScript== (function () { const css = ` .siye, .layout-right, .layout-left, .hotsearchCon, .notice, .hotword, .skin-wrapper, .aging-tools, .split-line, .common-sites, .coolsitead-tip, #lefttip, #shortcut-box, #hao123-govsite, #footer, #coolsites_cover, #topbeWrapper, #topbar-ad, #content-slot, #mingzhan-top-ad, #box-famous-resource, .topbar-ad, .mingzhan-top-ad, .mingzhanresource, .box-famous-resource, .mingzhan-ad-icon, .mingzhandown-close, .js-site-slot.js-ad-success, .float-ad-left, [id^="float-ad-"], [data-tu]:not(.site-slot-item) { display:none !important; } body { // background: url('https://pic3.zhimg.com/v2-b2b10364c745847811994a69c21d5532_r.jpg') no-repeat center center fixed; // background: url('https://pic3.zhimg.com/v2-3b83e03ec8352b504e7a3dab903a9c66_r.jpg') no-repeat center center fixed; background: url('https://pic1.zhimg.com/v2-908b61a41ec4bebe17a04468dcf5d834_r.jpg') no-repeat center center fixed; background-size: cover; // backdrop-filter: blur(10px); font-family: "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", "WenQuanYi Micro Hei"; } .fixed-search { padding-top: 0; } .g-red{ color:inherit } .sites2-wrapper .site-manage{ top:2px; right:2px; } .header{ position: static !important; width:1200px; height:80px; margin-bottom: 10px !important; box-sizing: border-box; padding-top: 8px; } .layout-header { margin-top:10px !important; margin-bottom: 10px !important; background: transparent !important; } .layout-header .page-width{ width:1200px !important; padding-left: 23px; } .layout-main{ width:1200px } .sites2-wrapper, .header, .page-width, .coolsites-wrapper{ box-shadow: 0px 0px 6px #888; border-radius: 8px; background: rgba(255,255,255,0.88) } .sites2-wrapper .cls_bd .site-item .new-icon-wrapper{ position: absolute; top: 0; width: 18px; height: 18px; } .sites2-wrapper .cls_bd .site-item .icon-site{ background-image: none !important; } `; const style = document.createElement("style"); style.textContent = css; document.head.appendChild(style); var rigth = document.querySelector(".layout-right"); var left = document.querySelector(".layout-left"); var hotsearchCon = document.querySelector(".hotsearchCon"); var notice = document.querySelector(".notice"); var hotword = document.querySelector(".hotword"); var skinWrapper = document.querySelector(".skin-wrapper"); var lefttip = document.querySelector("#lefttip"); var topbeWrapper = document.querySelector("#topbeWrapper"); var shortCutBox = document.querySelector("#shortcut-box"); var gov = document.querySelector("#hao123-govsite"); var footer = document.querySelector("#footer"); var game = document.querySelector("#navrecommend-hjw"); left?.parentNode.removeChild(left); rigth?.parentNode.removeChild(rigth); hotsearchCon?.parentNode.removeChild(hotsearchCon); hotword?.parentNode.removeChild(hotword); notice?.parentNode.removeChild(notice); skinWrapper?.parentNode.removeChild(skinWrapper); lefttip?.parentNode.removeChild(lefttip); topbeWrapper?.parentNode.removeChild(topbeWrapper); shortCutBox?.parentNode.removeChild(shortCutBox); gov?.parentNode.removeChild(gov); footer?.parentNode.removeChild(footer); game?.parentNode.removeChild(game); // var spread = document.querySelector(".spread"); // spread.click(); var script = document.querySelectorAll("script"); script.forEach((item) => { item?.parentNode.removeChild(item); }); // 头部区域(内含登录入口)只做 CSS 隐藏,不在这里动 DOM var topColumn = document.querySelector("#topColumn"); setTimeout(() => { // 右侧最下方 var agingTools = document.querySelector(".aging-tools"); agingTools?.parentNode.removeChild(agingTools); }, 1000); // 广告位:顶栏、名站、悬浮等(含动态插入) const adSelector = [ "#topbar-ad", "#content-slot", "#mingzhan-top-ad", "#box-famous-resource", ".mingzhanresource", "[id^='float-ad-']", "[data-tu]:not(.site-slot-item)", ].join(","); function removeAds() { document.querySelectorAll(adSelector).forEach((el) => { // topColumn 内的广告只隐藏不删除,避免影响登录入口 if (topColumn?.contains(el)) return; el.remove(); }); } removeAds(); if (document.body) { new MutationObserver(function (mutations) { for (let i = 0; i < mutations.length; i++) { if (mutations[i].addedNodes.length) { removeAds(); break; } } }).observe(document.body, { childList: true, subtree: true }); } const iconList = [ ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ]; try { const listWrapper = document.querySelector(".js_bd"); const bdList = listWrapper.children; function changeIcon() { for (let i = 0; i < bdList.length; i++) { if (i !== bdList.length - 1) { const item = bdList[i]; const inlineBlockWrapper = item.children[0]; const children = Array.from(inlineBlockWrapper.children); if ( !children.find((ele) => ele.classList.contains("new-icon-wrapper")) ) { const div = document.createElement("div"); div.classList.add("new-icon-wrapper"); div.innerHTML = iconList[i % iconList.length]; inlineBlockWrapper.appendChild(div); } } } } changeIcon(); // 创建一个 MutationObserver 实例并指定回调函数 var observer = new MutationObserver(function (mutations) { mutations.forEach(function (mutation) { changeIcon(); }); }); // 配置观察选项并开始观察 var config = { childList: true }; observer.observe(listWrapper, config); } catch (error) { console.error(error) // 报错时重新加载页面 window.location.reload(); } })();