// ==UserScript== // @name 百度纯净版-持续更新中... // @namespace http://tampermonkey.net/ // @description 去除百度搜索多余信息,纯净,设置背景色 // @version 0.5 // @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; 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', // 资讯 '#s_lm_wrap', // 资讯 /* change事件后 */ '#content_right', // 搜索后右侧 '#rs', // 底部 '#foot', // 底部 '#s_popup_advert', // 打开底部弹出广告 '.advert-shrink', // 右下角广告 ], css: ` ::-webkit-scrollbar-thumb{ background: #1aa0ac; border: 4px solid transparent; border-radius: 1em; background-clip: content-box; cursor: pointer; min-height: 50px; } ::-webkit-scrollbar{ width: 1em; background: #e5e5e5; border-radius: 0.5em; } #head_wrapper #form .bdsug-new::after{ content: ""; position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: -1; filter: blur(80px); background: #fdeff2; } body{ background-size: cover !important; background-repeat: no-repeat !important; background-position: 50% !important; } #u1{ right: 4em; } /* change事件 */ #head{ background: transparent; } #u{ margin-right: 3em; } #page{ background-color: transparent; } /* 时间 */ #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: 25em; width: 28em; padding: 0.5em; box-shadow: 0 0 5px rgba(0,0,0,.3); } /* 显示时间 */ #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; } /* 颜色选择 */ #colorsBox{ height: 10em; overflow-y: auto; display: flex; flex-wrap: wrap; justify-content: space-around; } #colorsItem{ width: 19%; height: 4em; box-sizing: border-box; margin: 0.2em 0; border-radius: 5px; font-size: 0.6em; padding-left: 0.4em; color: #222; display: flex; flex-direction: column; justify-content: flex-end; } /* 颜色选择 */ #bgcBox .col-xs-1_5{ width: 19%; font-size: 0.8em; } #bgcBox input{ display: none; } #bgcBox li{ margin-bottom: 0.5em; } #bgcBox li div{ margin-bottom: 0.5em; border-radius: 5px; padding: 1em 1em 0.3em 0.3em; } #bgcBox li div h4{ } #picInnerBox{ width: 100%; display: flex; justify-content: space-between; height: 10em; flex-wrap: wrap; overflow: auto; } #picInnerBox .pic-item{ width: 32%; height: 5em; background-size: cover; color: #666; margin-top: 0.5em; } /* 文字颜色 */ #textColorBox{ margin-left: 1em; display: flex; align-items: center; } #textColorBox input{ background: transparent; border: none; width: 3em; height: 1.8em; } `, fn(){ document.title = '百度'; /* 设置 */ let setting = `
`; let set = cEl('div'); set.id = 'setting'; set.innerHTML = setting; document.body.appendChild(set); /* 显示时间 */ let timeBox = cEl('div'); timeBox.id = 'timeBox'; timeBox.innerHTML = '显示时间'; let time = cEl('input'); time.type = 'checkbox'; time.id = 'timecheck'; timeBox.appendChild(time); /* 设置选项 */ let settingInfo = cEl('div'); settingInfo.id = 'settingInfo'; settingInfo.appendChild(timeBox) set.appendChild(settingInfo); /* 文字颜色 */ let textColorBox = cEl('div'); textColorBox.id = 'textColorBox'; textColorBox.innerHTML = '文字颜色'; let textColorInput = cEl('input'); textColorInput.type = 'color' textColorBox.appendChild(textColorInput); timeBox.appendChild(textColorBox); let colorStyle = cEl('style'); document.body.appendChild(colorStyle); const setTextColor = value => { colorStyle.innerHTML = ` #clock, .show-city-name, .c-color-t, .s-top-right-text, .user-name { color: ${value || '#000'} !important; } `; } textColorInput.oninput = function(){ setTextColor(this.value) localStorage.setItem('textColor',this.value); } window.addEventListener('load', () => { setTextColor(localStorage.getItem('textColor')) textColorInput.value = localStorage.getItem('textColor'); }) /* 配色 */ let bgcBox = cEl('div'); bgcBox.id = 'bgcBox'; bgcBox.innerHTML = '纯色背景'; let colors = `
`; /* 纯色切换 */ let toggleColor = color => { document.body.style.background = color; localStorage.setItem('bodyBgc',color) } bgcBox.innerHTML += colors; bgcBox.addEventListener('click', e => { let fun = { 'h4': () => { toggleColor(e.target.innerHTML); }, 'h3': () => { toggleColor(e.target.nextElementSibling.innerHTML); }, 'div': () => { if(e.target.children[1].nodeName.toLowerCase() == 'h4') toggleColor(e.target.children[1].innerHTML); } } fun?.[e.target.nodeName.toLowerCase()]?.(); }) settingInfo.appendChild(bgcBox); /* 图片背景 */ let pics = [ { url: 'https://p.qlogo.cn/zc_icon/0/c37a1553ed84d0b97c6c4e8185aa59f616268815316858/0.jpg', }, { url: 'https://p.qlogo.cn/zc_icon/0/e55490769ae17ccffdfe4c9768617a9516268823599153/0.png', name: '纱雾' }, { url: 'https://p.qlogo.cn/zc_icon/0/e57d4abd2521588fa443d86c37e98a9816268824157905/0.jpg', name: '纱雾' }, { url: 'https://p6-tt.byteimg.com/origin/pgc-image/a29351c3e5034eaa8932fbcfbc676db6.png', name: '初音', color: '#fff' }, { url: 'https://p.qlogo.cn/zc_icon/0/d6ed1c31bdfe1f9cc0c5f0e1fe12e4b616268827839999/0.png', name: '02', color: '#fff' }, { url: 'https://p6-tt.byteimg.com/origin/pgc-image/834dac90f4c646be9904664816995be3.png', name: '蕾姆' }, { url: 'https://img30.360buyimg.com/pop/jfs/t1/196210/18/14571/1993027/60fb8ed0E05e2463b/2aeca862d75e43d7.jpg', name: '君の名', color: '#fff' }, { url: 'https://p.qlogo.cn/zc_icon/0/ee8aacd16b953f2bab55425db76ea79e16270988916254/0.jpg', name: '君の名', color: '#fff' }, { url: 'https://p.qlogo.cn/zc_icon/0/46c0afc1f1e1b8d893ae2c62d5ac117416270989199219/0.png', }, { url: 'https://p.qlogo.cn/zc_icon/0/ec38e734c1ad2ecd0c7a2b78be3c2b3c16270989533129/0.png', name: '双马尾' }, { url: 'https://p.qlogo.cn/zc_icon/0/c5c51bfd60dcb81c4cf8eef3ba89cbdb16270989837769/0.png', }, { url: 'https://p.qlogo.cn/zc_icon/0/e5f2d6ebca159cea9fa766664a26d84c16270990402515/0.png', }, { url: 'https://p.qlogo.cn/zc_icon/0/682704e766758fa70e98a55de546951b16270990671689/0.png', }, { url: 'https://p.qlogo.cn/zc_icon/0/6630d05c343586a97984cbee0104e10716270990908323/0.jpeg', }, { url: 'https://p.qlogo.cn/zc_icon/0/f3c4f3572aac496d0cadb3bee52a92e516270991138011/0.png', name: '英莉莉', color: '#fff' }, { url: 'https://p.qlogo.cn/zc_icon/0/05895bf6133d4131659cad7d3440403616270991383467/0.jpg', name: '君の名', color: '#fff' }, { url: 'https://p.qlogo.cn/zc_icon/0/46d49e8061d58280356a9ac8ea9de90c16270991570882/0.jpg', }, { url: 'https://p.qlogo.cn/zc_icon/0/92262aace174450f9adc38675a3c246a16270991691026/0.jpg', }, { url: 'https://p.qlogo.cn/zc_icon/0/b80b7c92109f786f1eb98f966933165f16270993274964/0.png', }, { url: 'https://p.qlogo.cn/zc_icon/0/02ecedfd39a6158241b3b79d49398f3e16270993566982/0.png', }, { url: 'https://p.qlogo.cn/zc_icon/0/eec4cb41ac24327926d68d1e694a6cd416270993701592/0.png', }, { url: 'https://p.qlogo.cn/zc_icon/0/37dd31efc79a162fe0ab68f74005b9ad16270994035286/0.jpg', name: '磷叶石', color: '#fff' }, { url: 'https://p.qlogo.cn/zc_icon/0/8568c9d99ddb4fe05d4cac896146b15a16270994681685/0.png', name: '鬼刀', color: '#fff' }, { url: 'https://p.qlogo.cn/zc_icon/0/6052e0e1a937f6b3578d65c9c9fb31bc16270994678568/0.png', name: '鬼刀', color: '#fff' }, { url: 'https://p.qlogo.cn/zc_icon/0/4448bd7ec06eb3ebefe969836e71ed9f16270994675302/0.png', name: '鬼刀', color: '#fff' }, { url: 'https://p.qlogo.cn/zc_icon/0/61d541dbd71fd82bf4d00d8497ed15bc16270994675354/0.png', name: '鬼刀', color: '#fff' }, { url: 'https://p.qlogo.cn/zc_icon/0/4d2c5d7aefd0850ab6918fac899e07b616270994665082/0.jpg', name: '鬼刀', color: '#fff' }, { url: 'https://p.qlogo.cn/zc_icon/0/03544a46132a5a7b5c577514c1d6027516270994652145/0.jpg', name: '鬼刀', color: '#fff' }, { url: 'https://p.qlogo.cn/zc_icon/0/36aaeb3109fd68d4db94e3bd70bef96616270995238944/0.png', name: '无名', color: '#fff' }, { url: 'https://p.qlogo.cn/zc_icon/0/12c2ece0d1673a1e7e992dd1945afb1516270996357511/0.png', name: 'D.va', color: '#fff' }, { url: 'https://p.qlogo.cn/zc_icon/0/e47d421e9f34ce8914a0d1ea78c6ede316270997713507/0.png', name: '薇尔莉特', color: '#fff' }, { url: 'https://p.qlogo.cn/zc_icon/0/df6450996a76cd0545168c6b2771e5e716270998324702/0.png', name: '影山茂夫' }, { url: 'https://p.qlogo.cn/zc_icon/0/0d00f4ad96b712907a0f68a9e06a186c16270998835084/0.png', name: 'RE0' }, { url: 'https://p.qlogo.cn/zc_icon/0/c931b197a3f8fa8add1209214d6eb28c16270999056279/0.jpg', name: 'narota', color: '#fff' }, { url: 'https://p.qlogo.cn/zc_icon/0/4aec6b2bf59ca00b25666d9a441108e516270999356088/0.png', name: '火影' }, { url: 'https://p.qlogo.cn/zc_icon/0/49eaf1619e0747fc66ba78bba07d689516271003488737/0.png', }, ] let picBox = cEl('div'); picBox.innerHTML = '2K壁纸'; picBox.id = 'picBox'; let picInnerBox = cEl('div'); picInnerBox.id = 'picInnerBox' pics.forEach(item => { let temp = cEl('div'); temp.className = 'pic-item'; temp.style.backgroundImage = `url(${item.url})` temp.innerHTML = `

${item.name || ''}

`; picInnerBox.appendChild(temp); }) picBox.addEventListener('click',e => { if(e.target.nodeName.toLowerCase() == 'p'){ toggleColor(e.target.parent.style.backgroundImage); return; } toggleColor(e.target.style.backgroundImage); }) picBox.appendChild(picInnerBox); settingInfo.appendChild(picBox); 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', // 相关搜索 '#content_left > div[tpl=news-realtime]', // 贴吧咨询 '#content_left > div[tpl=short_video_pc]', // 视频推荐 ], css:` .head_nums_cont_inner{ top: 0 !important; } #page{ background-color: transparent !important; } ::-webkit-scrollbar-thumb{ background: #1aa0ac; border: 4px solid transparent; border-radius: 1em; background-clip: content-box; cursor: pointer; min-height: 50px; } ::-webkit-scrollbar{ width: 1em; background: #e5e5e5; border-radius: 0.5em; } `, fn(){ /* 去除搜索结果广告 */ let ad = document.querySelectorAll('#content_left > div:not(.result)'); for(let item in ad){ if(!ad[item].className) ad[item]?.remove?.(); // 插入广告 if(ad[item].className == 'result-op c-container new-pmd') ad[item]?.remove?.(); // 贴吧相关消息推荐 } } }, '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); })();