// ==UserScript== // @name 极简百度首页by: yzl // @namespace http://tampermonkey.net/ // @match https://www.baidu.com/* // @version 0.9 // @description 仅适用于PC版百度首页,部分百度子网站容器 // @author U1iz // @icon http://res1433223.net3v.net/img/favicon.png // @grant none // @downloadURL https://update.greasyfork.icu/scripts/435188/%E6%9E%81%E7%AE%80%E7%99%BE%E5%BA%A6%E9%A6%96%E9%A1%B5by%3A%20yzl.user.js // @updateURL https://update.greasyfork.icu/scripts/435188/%E6%9E%81%E7%AE%80%E7%99%BE%E5%BA%A6%E9%A6%96%E9%A1%B5by%3A%20yzl.meta.js // ==/UserScript== (function () { //构建“存在即删除”函数 function elementRemove(element) { if (element) { element.remove(); } } //构建“获取元素”函数 function getElement(name, type, quantity) { var e; if (type == 'c') { if (document.getElementsByClassName(name)[0]) { e = document.getElementsByClassName(name)[0]; } if (quantity) { if (document.getElementsByClassName(name)[0]) { for (var i = 0; i < quantity; i++) { return (e[i]); } } } } else if (type == 'id') { if (document.getElementById(name)) { e = document.getElementById(name); } } return (e); } //构造改变背景色函数 function changeStyle(e, value) { e.style.backgroundColor = value; } //合集 function all() { //百度搜索右侧 //elementRemove(getElement('xpath-log','c',6)); //elementRemove(getElement('result-op','c',6)); //changeStyle(getElement('c-border',128), 'rgb(226, 230, 215)'); //更改主体容器类名 getElement('head_wrapper', 'id').className = 'head_wrapper s-isindex-wrap nologin s-ps-islite'; //移除热搜开启&关闭元素 elementRemove(getElement('set-show', 'c', 1)); elementRemove(getElement('set-hide', 'c', 1)); //更改全局背景色 document.body.style.backgroundColor = '#ddd'; //更改搜索栏部分背景颜色 getElement('kw', 'id').style.backgroundColor = '#ddd'; // if(document.querySelector('.soutu-btn')[0]){ // document.querySelector('.soutu-btn')[0].style.backgroundColor = '#ddd'; // } if (document.querySelector('.soutu-btn')) { document.querySelector('.soutu-btn').style.backgroundColor = '#ddd'; } if (document.querySelector('.bdsug-new')) { document.querySelector('.bdsug-new').style.backgroundColor = '#ddd'; document.querySelector('.bdsug-new').querySelector('ul').style.borderTop = '2px solid #ddd'; } if (document.querySelector('.bdsug')) { document.querySelector('.bdsug').style.backgroundColor = '#ddd'; document.querySelector('.bdsug').querySelector('ul').style.borderTop = '2px solid #ddd'; } if (document.querySelector('.bdsugbg')) { document.querySelector('.bdsugbg').style.backgroundColor = '#ddd'; document.querySelector('.bdsugbg').querySelector('ul').style.borderTop = '2px solid #ddd'; } //移除首页下方ad容器 elementRemove(document.getElementById('s-hotsearch-wrapper')); elementRemove(document.getElementById('s-top-left')); //移除首页上方导航栏 elementRemove(document.getElementById('s_top_wrap')); //移除右上用户登录入口 elementRemove(document.querySelector('.s-top-login-btn')); //移除登录界面 elementRemove(document.getElementById('TANGRAM__PSP_5__')); elementRemove(document.getElementsByClassName('pop-mask')[0]); elementRemove(document.getElementById('TANGRAM__PSP_4__foreground')); elementRemove(document.querySelector('.pass-login-pop-form')); //移除右下绝对定位二维码登录 elementRemove(getElement('s_qrcode_nologin', 'id')); //移除下方 elementRemove(getElement('s_wrap', 'id')); //更改底部bgc 等于页面背景色 getElement('bottom_layer', 'id').style.backgroundColor = document.body.style.backgroundColor; //更改logo图标,变相禁止点击跳转 svg来自阿里妈妈图标库 getElement('lg', 'id').innerHTML = ''; } all(); window.onload = function () { console.log(getElement('s_ipt', 'c')); //设置定时器,每1s执行一次 setInterval(function () { all(); }, 1000) }; })();