// ==UserScript== // @name 百度纯净版-持续更新中... // @namespace http://tampermonkey.net/ // @description 去除百度搜索多余信息,纯净,设置背景色 // @version 0.2 // @description try to take over the world! // @author tomiaa // @match *://www.baidu.com/ // @match *://www.baidu.com/s?* // @match *://www.baidu.com/sf/* // @match *://image.baidu.com/search/index* // @match *://zhidao.baidu.com/search* // @match *://wenku.baidu.com/search* // @match *://tieba.baidu.com/f* // @match *://tieba.baidu.com/ // @match *://tieba.baidu.com/p/* // @icon https://www.baidu.com/cache/icon/favicon.ico // @grant none // @downloadURL none // ==/UserScript== ;(() => { const $ = id => document.querySelector(id); const cEl = el => document.createElement(el); const format = val => val > 9 ? val : '0' + val; document.documentElement.style = ` ` console.clear(); const config = { 'https://www.baidu.com/':{ // index remove: [ '#s-top-left', // nav 左侧 '#s-hotsearch-wrapper', // 搜索下面热搜 '#s_lg_img', // 百度logo '#bottom_layer', // 底部 '#s_side_wrapper', // 右下角 // '#s_wrap', // 资讯 ], css: ` ::-webkit-scrollbar-thumb{ background: #1aa0ac; border: 2px solid transparent; border-radius: 1em; background-clip: content-box; cursor: pointer; min-height: 50px; } ::-webkit-scrollbar{ width: 1rem; background: #e5e5e5; border-radius: 0.5em; } #u1{ right: 4em; } /* 时间 */ #clock{ position: absolute; width: 5em; height: 1em; bottom: 2em; font-size: 3em; line-height: 1em; left: 50%; transform: translateX(-50%); z-index: 999; color: #666; } /* 头部 */ #s_top_wrap{ background: transparent; } /* 设置 */ #setting { position: absolute; z-index: 999; width: 2em; height: 2em; top: 1.4em; right: 1.2em; cursor: pointer; } #setting::before { content: ""; position: absolute; top: -8px; right: -8px; bottom: -8px; left: -8px; } #setting #svg{ transition: all .5s; width: 100%; height: 100%; } #setting:hover #svg{ transform: rotate(180deg); } #setting #settingInfo{ width: 7em; height: 0; font-size: 1.5em; border-width: 0; text-align: left; box-sizing: content-box; border: 0px solid pink; background: hsla(0,0%,100%,.5); position: absolute; right: 0; top: 135%; border-radius: 5px; transition: all .5s; overflow: hidden; } #setting #settingInfo::before { content: ""; position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: -1; filter: blur(10px); margin: -30px; } #setting:hover #settingInfo{ height: 16em; width: 15em; border: 1px solid pink; padding: 0.5em; } /* 显示时间 */ #timeBox{ display: flex; align-items: center; } #timecheck{ appearance: none; width: 4em; height: 1.6em; border: 1px solid pink; margin-left: 1em; border-radius: 0.8em; position: relative; cursor: pointer; overflow: hidden; transition: all .5s; } #timecheck::before{ content: ''; position: absolute; top: -1px; left: 0; width: 1.6em; height: 1.6em; background: pink; border-radius: 50%; transition: all .5s; } #timecheck:checked{ border-color: #39b54a; } #timecheck:checked::before{ left: calc(4em - 1.6em); background: #39b54a; opacity: .6; } /* colors */ #colorsBox{ height: 7em; overflow-y: auto; display: flex; flex-wrap: wrap; justify-content: space-around; } #colorsItem{ width: 30%; height: 3em; box-sizing: border-box; margin: 0.2em; border-radius: 5px; font-size: 0.8em; padding-left: 0.4em; color: #222; } `, fn(){ document.title = '百度'; /* 设置 */ let setting = `
${item.name}
${item.color}
`; temp.onclick = () => { toggleColor(item.color); } colorsBox.appendChild(temp); }) bgcBox.appendChild(colorsBox); settingInfo.appendChild(bgcBox); window.addEventListener('load', () => { $('#su').value = '搜 索'; /* 时间 */ let clock = cEl('div'); clock.id = 'clock'; clock.style.display = 'none'; $('#form').appendChild(clock); let nowTime = null; let timeFn = () => { let date = new Date(); nowTime = `${format(date.getHours())}:${format(date.getMinutes())}:${format(date.getSeconds())}`; clock.innerHTML = nowTime; getTime(); } function getTime(){ setTimeout(timeFn,1000) } timeFn(); /* 时间显示隐藏 */ time.onchange = function(){ clock.style.display = this.checked ? 'block' : 'none'; localStorage.setItem('timeCheck',this.checked) } let flag = localStorage.getItem('timeCheck'); if(flag === 'true'){ time.checked = true; clock.style.display = 'block'; } let bodyBgc = localStorage.getItem('bodyBgc'); bodyBgc && toggleColor(bodyBgc); }) }, }, /* 搜索结果页 */ 'https://www.baidu.com/s': { // 搜索页 remove: [ // '#result_logo', // 左上角logo '#content_right', // 右侧 '.s-tab-more', // 更多 '.s-tab-b2b', // 采购 '#foot', // 底部 '.new_nums', // 找到数量 '.search_tool_close', // 收起工具 '.toindex', // 右侧返回首页 /* item底部 */ '.se_st_footer', '.c-showurl', '.kuaizhao', // 快照 '.c-icons-outer', // 保障 '.op-guide-cont', // 翻译下载 '#rs', // 相关搜索 ], css:` .head_nums_cont_inner{ top: 0 !important; } ` }, 'https://www.baidu.com/sf/vsearch': { // 视频 remove: [ '#content_right', // 右侧 '.s-tab-more', //更多 '.s-tab-b2b', // 采购 ] }, 'https://image.baidu.com/search/index': { remove: [ '#tips', // 提示 '#topRS', // 相关搜索 '#resultInfo',// 数量 '#common-feedback-link',// 反馈 '.s_tab_more', // 更多 '.s-tab-b2b', // 采购 ], css: ` #newImgFilter{ margin-left: 7rem; } .hover ._self{ /* 下载 */ right: 10px; } .hover .title, /* 标题 */ .hover .dutu{ /* 识图 */ display:none !important; } ` }, 'https://zhidao.baidu.com/search': { // 知道 remove: [ '.fixheight', // 右侧 '#footer-help', // 底部 '.shop-entrance',// 右上角商城 '.s-tab-b2b', // 采购 ] }, "https://wenku.baidu.com/search": { // 文库 remove: [ '.base-layout-content-right', // 右侧 '.user-vip', // 右上角vip立减 '.user-more', //右上角更多 '.no-full-screen', // 右下角 '.baidu-search-tip-wrap', // 去网页搜索 '.search-relative-wrapper', // 相关搜索 '.cover-img-wrap', // 底部广告 '.search-foot-wrap', // 底部 '.head-recom', // 搜索推荐 ] }, /* 贴吧 */ 'https://tieba.baidu.com/f': { // 贴吧 进吧 remove: [ '.search_nav', // 头部 '.u_hermes', // 问题反馈 '.u_member', // 会员 '.gift-goin', // gif '.card_info', // 目录 '.dialogJ', // 弹窗 '.dialogJmodal', // 弹窗 '.fengchao-wrap-feed', // 广告 /* 右下角 */ '.tbui_fbar_down', '.tbui_fbar_refresh', '.tbui_fbar_share', '.tbui_fbar_feedback', '.tbui_fbar_favor', '#aside', '.th_footer_l', // 贴子数量 /* 底部发帖 */ '.poster_head_surveillance', // 政策 '.ui_bubble_wrap j_wrap', // 分享弹窗 '.topic_add_btn', // 话题 '#footer', // 底部 ], css: ` #content_wrap{ width: 100% !important; /* 内容 */ } /* 左侧广告 */ .clearfix .label_text, .clearfix .close_btn, .clearfix .j_click_stats, .clearfix .hover_btn { display: none !important; } #content_wrap { background: #fff; } `, fn(){ window.addEventListener('load', () => { /* 收起讨论 */ if($('#listPostCnt')){ $('#listPostCnt').style.display = 'none'; $('#listEditorCnt').style.display = 'none'; $('#slideBtn').classList.remove('down') } }) } }, 'https://tieba.baidu.com/': { // 贴吧首页 remove: [ // '.top-sec', // 轮播 '.search_nav ', // 顶部 '.u_menu_member', // 会员 '#spage-tbshare-container', // 右侧分享 '.r-top-sec', // 推荐贴吧 '.r-right-sec', // 右侧 '.spage_liveshow_slide', // 游戏 '#spage_game_tab_wrapper', // 左侧游戏 '.aggregate_entrance_wrap', // 左侧 精选 '.ufw-gap', // 分类 '#f-d-w', // 分类 '.footer', // 底部 ], css: ` #left-cont-wraper { position: static !important; } .top-sec{ display: none !important; } ` }, 'https://tieba.baidu.com/p/': { // 贴吧看帖 remove: [ '.search_nav ', // 顶部 '.u_menu_member', // 会员 /* 右下角 */ '.tbui_fbar_down', '.tbui_fbar_refresh', '.tbui_fbar_share', '.tbui_fbar_feedback', '.tbui_fbar_favor', '.tbui_fbar_props', '.tbui_fbar_tsukkomi', '#aside', '#celebrity', // 右侧会员 '.app_download_box', // 右侧下载app '.topic_list_box', // 贴吧热议 '#tieba-notice', // 右侧反馈 '.tieba_notice_theme2', // 右侧反馈 '[ad-dom-img]', // 广告 '.share_btn_wrapper',// 一楼分享 /* 底部发帖 */ '.poster_head_surveillance', // 政策 '#footer', // 底部 '.d_icons', // 头像下面印记 '.save_face_bg', // 每层楼右上角图标 '.d_nameplate', // 头像特权图标 ] } } const currentHref = location.href.split('?'); console.log(currentHref); class BaiduClear { constructor(config){ this.config = config; this.domain = ''; this.query = null; this.init(); } init(){ const currentHref = location.href.split('?'); this.domain = currentHref[0]; this.query = currentHref[1]; this.domain.includes('tieba.baidu.com/p/') && (this.domain = 'https://tieba.baidu.com/p/'); // 贴吧看帖 this.removeToHidden(this.config?.[this.domain]?.remove); this.addCss(this.config?.[this.domain]?.css); this.remove(this.config?.[this.domain]?.remove); this.config?.[this.domain]?.fn?.(); } remove(arr = []){ arr.map(item => $(item)).forEach(item => { item?.remove(); }) } removeToHidden(arr = []){ if(!arr.length) return; this.addCss(arr.join(',') + `{display: none;}`) } addCss(css = ''){ if(!css) return; let style = document.createElement('style') style.innerHTML = css; document.documentElement.appendChild(style); } } new BaiduClear(config); })();