// ==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
// ==/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 = `<div id='svg'>
<svg t="1626769525805" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8836" width="100%" height="100%"><path d="M858.75 512c0-58.97 44.19-107.53 101.25-114.6-10.91-42.77-27.84-83.1-49.74-120.16-19.48 14.95-43.78 23.94-70.24 23.94-63.83 0-115.58-51.75-115.58-115.58 0-26.67 9.13-51.16 24.3-70.72C711.14 92.41 670.12 75.1 626.6 64c-7.08 57.05-55.63 101.25-114.6 101.25-58.97 0-107.53-44.19-114.6-101.25-42.86 10.93-83.27 27.91-120.4 49.87 14.2 19.2 22.7 42.87 22.7 68.58 0 63.84-51.75 115.58-115.58 115.58-25.93 0-49.79-8.64-69.07-23.07C92.5 312.64 75.13 353.77 64 397.4c57.06 7.07 101.25 55.63 101.25 114.6S121.06 619.53 64 626.6c10.98 43.07 28.07 83.68 50.19 120.96 19.71-15.62 44.58-25.01 71.67-25.01 63.84 0 115.58 51.75 115.58 115.58 0 27.1-9.4 51.97-25.01 71.68 37.28 22.12 77.89 39.21 120.96 50.19 7.07-57.05 55.63-101.25 114.6-101.25 58.97 0 107.53 44.19 114.6 101.25 43.44-11.08 84.39-28.35 121.93-50.75-12.89-18.64-20.47-41.23-20.47-65.61 0-63.84 51.75-115.58 115.58-115.58 24.38 0 46.96 7.59 65.61 20.47 22.4-37.54 39.67-78.49 50.75-121.93-57.04-7.07-101.24-55.63-101.24-114.6z" fill="#8C9EFF" p-id="8837"></path><path d="M512 512m-140 0a140 140 0 1 0 280 0 140 140 0 1 0-280 0Z" fill="#FFD600" p-id="8838"></path><path d="M512 680c-92.63 0-168-75.36-168-168 0-92.63 75.37-168 168-168s168 75.37 168 168c0 92.64-75.37 168-168 168z m0-280c-61.76 0-112 50.24-112 112s50.24 112 112 112 112-50.24 112-112-50.24-112-112-112z" fill="#FFFFFF" p-id="8839"></path></svg>
</div>
`;
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 bgcBox = cEl('div');
bgcBox.id = 'bgcBox';
bgcBox.innerHTML = '纯色背景';
let colorsBox = cEl('div');
colorsBox.id = 'colorsBox';
let colors = [
{color: '#bf242a',name: '桜色'},
{color: '#96514d',name: '小豆色'},
{color: '#e6b422',name: '黄金'},
{color: '#006e54',name: '萌葱色'},
{color: '#895b8a',name: '古代紫'},
{color: '#fdeff2',name: '薄桜'},
{color: '#8d6449',name: '枯茶'},
{color: '#d9a62e',name: '櫨染'},
{color: '#00a381',name: '花緑青'},
{color: '#824880',name: '茄子紺'},
{color: '#e9dfe5',name: '桜鼠'},
{color: '#deb068',name: '饴色'},
{color: '#d3a243',name: '黄朽葉色'},
{color: '#38b48b',name: '翡翠色'},
{color: '#915c8b',name: '二藍'},
];
let toggleColor = color => {
document.body.style.background = color;
localStorage.setItem('bodyBgc',color)
}
colors.forEach(item => {
let temp = cEl('div');
temp.id = 'colorsItem';
temp.style.background = item.color;
temp.innerHTML = `
<p>${item.name}</p>
<p>${item.color}</p>
`;
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);
})();