您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Change background ,remove useless div
当前为
// ==UserScript== // @name Allen's web // @namespace null // @description Change background ,remove useless div // @author @amormaid // @version 0.5.0 // @run-at document-end // @include http://* // @include https://* // @exclude https://www.youtube.com/* // @exclude http://demo.mycodes.net/* // @exclude http://192.168.254.199/* // @exclude http://10.200.1.237/* // @exclude http://10.200.0.116/* // @exclude http://10.200.1.238/* // @exclude https://127.0.0.1/* // @exclude http://127.0.0.1/* // @exclude https://kiwivm.64clouds.com/* // @exclude http://192.168.254.133/* // @exclude http://104.224.166.80/* // @exclude https://www.instagram.com/* // @exclude http://www.h-ui.net/* // @exclude http://www.layui.com* // @exclude http://10.200.0.239* // @exclude http://10.200.1.138* // @exclude http://10.200.0.8* // @exclude https://www.kixeye.com* // @exclude http://10.200.0.74* // @exclude http://10.200.0.145* /* // @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js */ /* // @require https://code.jquery.com/jquery-3.2.1.min.js */ // @license MIT License // @grant none // ==/UserScript== /* if(typeof(jQuery) === 'undefined'){ var jquery_script = document.createElement('script'); jquery_script.src = 'https://code.jquery.com/jquery-3.2.1.min.js'; document.body.append(jquery_script); } */ var root= document.body; var links = window.location.hostname; var remove_div,elem,elem_2, arr,ad_ele,remove_ele; var content_old,content_new; try{ console.clear(); console.time("allen_web_time_count"); switch(links){ case "www.baidu.com": var head = document.getElementById("head"); var pad = document.getElementById("s_tab"); var u = document.getElementById("u"); var setInterval_id; document.getElementById("container").style.width = "700px"; head.style.position = 'relative'; head.style.width = window.innerWidth-100+'px'; head.style['min-width'] = 0; pad.style.padding = '0 0 0 121px'; u.style.display = 'none'; document.body.style['min-width'] = '10px'; setInterval_id = setInterval(function(){ if(document.querySelector("#content_right") ){ $$("#content_right",'19'); clearInterval(setInterval_id); } },100); change_style(); break; case "blog.csdn.net": $$("#side",'21'); var CSDN_style_obj = { 'max-width':document.body.clientWidth-16+'px', 'min-width':'2px' }; change_style(); break; case "www.w3school.com.cn": $$("#navsecond",'21'); change_style(); break; case "www.jquery123.com": $$("#sidebar",'21'); var a = $$("#content",'21'); if(a) a.style.width = "100%"; change_style(); break; case "wallstreetcn.com": change_wallstreet_style(); break; case "zhidao.baidu.com": var a =document.getElementById("body"); if(a) a.style.left = "50px"; change_style(); break; case "www.merriam-webster.com": $$(".right-rail",'21'); $$("#recirc-bar-footer",'21'); if(a) a.elem.style.width = "100%"; $$(".wgt-related-to.jc-card-box.clearfix",'21'); change_style(); break; case "blog.sina.com.cn": $$("#column_1",'21'); change_style(); break; case "blog.jobbole.com": case "web.jobbole.com": $$("#sidebar",'21'); var a = $$(".grid-8",'01'); if (a) a.style.width = "100%"; change_style(); break; case "juejin.im": setTimeout(show_juejin_hidden_content,1000); break; case "www.cnblogs.com": $$("#vid",'21'); $$("#left",'21'); $$("#right_content",'21'); $$("#leftcontent",'21'); var a = $$("#centercontent",'01'); if(a)a.style['padding-left'] = 0; change_style(); break; case "github.com": document.body.style.minWidth = '100px'; var github_pad = document.querySelector('.column.three-fourths.codesearch-results.pr-6') ; if(github_pad ){ github_pad.style.padding = '10px 0 10px 30px'; } //change_style(,{'max-width':document.body.clientWidth+'px'}); change_style(); break; case "wiki.jikexueyuan.com": $$(".detail-left",'21'); var a = $$(".detail-main",'no_option','one'); a.style['margin-left'] = '0px'; a.style.width = document.body.clientWidth+'px'; change_style(); break; case "www.cssmoban.com": var a = $$(".wide-main.col-media-main.clearfix",'01'); a.style.width = document.body.clientWidth+'px'; change_style(); break; case "www.kancloud.cn": var interval_id = setInterval(function(){ if(document.querySelector(".sidebar")){ var a = document.querySelector(".sidebar"); document.querySelector(".workspace").style.left = "180px"; a.style.width = '180px'; change_style(a); clearInterval(interval_id); } },100); change_style(); break; case "php.net": $$('.layout-menu','11'); if($$(".sect1",'01'))$$(".sect1",'01').style.width = document.body.clientWidth-50+"px"; if($$("#usernotes",'01'))$$("#usernotes",'01').style.width = document.body.clientWidth-50+"px"; change_style(); break; case "www.zhihu.com": $$('.Question-sideColumn.Question-sideColumn--sticky','11'); $$('.AdblockBanner-inner','11'); $$('.QuestionHeader-side','19'); $$('.AppHeader-userInfo','19'); var browser_width = document.body.clientWidth -50+"px"; $$('.QuestionHeader-content','01').style.width = browser_width; setInterval(function(){ if(document.querySelector(".HitQrcode")){ $$('.HitQrcode','11'); } },100); change_style(); break; case "www.letscorp.net": $$('#commentlist','11'); $$('#sidebar','11'); $$('#header','11'); var browser_width = document.body.clientWidth -50+"px"; $$('#container','01').style.width = browser_width; $$('#main','01').style.height = "auto"; var p_ele = $$('p','09'); Array.prototype.forEach.call(p_ele,function(e){ e.style["font-size"] = "16px"; }); change_style(); break; default: change_style(); } console.timeEnd("allen_web_time_count"); }catch(err){ //console.log(err.name,' ',err.message); console.log(err.stack); } function change_style (ele){ //baidu页面需要17ms var all_div = ele || document.querySelectorAll('*'); Array.prototype.forEach.call(all_div,function(e){ if(!e.style.backgroundColor){ e.style.backgroundColor = "rgba("+parseInt(239*(1-0.1*Math.random()))+","+parseInt(239*(1-0.1*Math.random()))+","+parseInt(187*(1-0.1*Math.random()))+",0.8)" ; } }); } /* //递归写法 , baidu页面需要27ms if(!node.style.backgroundColor){ node.style.backgroundColor = "rgba("+parseInt(239*(1-0.1*Math.random()))+","+parseInt(239*(1-0.1*Math.random()))+","+parseInt(187*(1-0.1*Math.random()))+",0.8)" ; } if(style_obj && style_obj instanceof Object){ for(var attr in style_obj){ node.style[attr] = style_obj[attr]; } } if(node && node.children.length > 0){ Array.prototype.forEach.call(node.children,function(e){ change_style(e,style_obj); }); } */ function ele_hide(e){ e.style.display = "none" ; } function ele_hide_all(all){ Array.prototype.forEach.call(all,function(e){e.style.display = "none";}); } function ele_remove(e){ e.parentNode.removeChild(e); } function ele_remove_all(all){ Array.prototype.forEach.call(all,function(e){e.parentNode.removeChild(e);}); } function $$(selector,operation_code){ // operation_code // first bit means remove (1) or hide (2) or no_operation (0) // second bit means one node (1) or all nodes(9) switch(operation_code){ case '01': return document.querySelector(selector) ; case '09': return document.querySelectorAll(selector); case '11': ele_remove(document.querySelector(selector)); break; case '19': ele_remove_all(document.querySelectorAll(selector)); break; case '21': ele_hide(document.querySelector(selector)); break; case '29': ele_hide_all(document.querySelectorAll(selector)); break; default: var result; if(document.querySelectorAll(selector).length >1){ result = document.querySelectorAll(selector); }else{ result = document.querySelector(selector); } return result; } } function remove_div_padding_margin(ele){ if( ele ){ ele.setAttribute('style','overflow:visible;position:relative;padding:0px;margin:0px;left:0px;'); } if(ele && ele.children.length > 0){ Array.prototype.forEach.call(ele.children,(function(e){ remove_div_padding_margin(e); })); } } function content_get() { var ajax = new XMLHttpRequest(); ajax.open('get', '/'); ajax.send(); ajax.onreadystatechange = function() { if (ajax.readyState == 4 && ajax.status == 200) { content_new = ajax.responseText; //console.log(content_new); content_old = content_old || content_new; if(content_new !== content_old){ location.reload() ; } } }; setTimeout(content_get,1000); } function change_wallstreet_style(){ var remove_div = document.getElementsByClassName("left-bar")[0]; if(remove_div) remove_div.style.display = "none"; var arr = document.getElementsByClassName("news-item__cover"); Array.prototype.forEach.call(arr,function(e){e.style.display = "none";}); change_style(); setTimeout(change_wallstreet_style,500); } function show_juejin_hidden_content(){ var a = document.getElementsByClassName("show-full")[0]; var b = document.getElementsByClassName("show-full-block")[0]; var c = document.getElementsByClassName(" show-full-btn")[0]; if(a)a.style.height = "auto"; if(b)b.style.height = "auto"; if(c)c.style.display = "none"; change_style(); setTimeout(show_juejin_hidden_content,300); }