用户:
Albert钟查看:25 回复:8 评论:25 创建时间:2022-03-12T14:01:59
演示和介绍:shequ.codemao.cn/community/429927 代码下载:greasyfork.org/zh-CN/scripts/441381-cmgreener 代码 //==UserScript== //@namecmgreener //@namespacehttp://tampermonkey.net/ //@version1.0.1 //@descriptiongreenerforshequ.codemao.cn //@authorAlbertZ //@include*://shequ.codemao.cn/* //@iconhttps://static.codemao.cn/whitef/favicon.ico //@licenseMIT //@grantnone //==/UserScript== varremoves={}; removes['shequ.codemao.cn/course']=['r-course--banner']; removes['shequ.codemao.cn/discover']=[]; removes['shequ.codemao.cn/work_shop']=['r-work_shop--banner']; removes['shequ.codemao.cn/community']=['r-community--bulletin_container','r-community--notic_item_icon_hot', 'c-post_list--status_iconc-post_list--hot','c-post_list--status_iconc-post_list--up','r-community--roules_btn' ]; removes['shequ.codemao.cn/mall']=['r-mall-r-home--banner']; removes['shequ.codemao.cn/gallery']=['r-gallery--banner']; removes['shequ.codemao.cn']=['r-home--guide_part','r-home-c-workshop_area--workshop_work']; window.onload=function(){ //重定向anchor标签 varanchors=[...document.getElementsByClassName('c-navigator--nav_wrap')[0].getElementsByTagName('a')].slice(0,7); for(vari=0;i<anchors.length;i++){ vara=anchors[i]; leturl=a.href; a.onclick=function(){window.location.href=url;}; } //论坛区延迟执行(适应XHR) if(window.location.href.indexOf('shequ.codemao.cn/community')>-1){ setTimeout(function(){ leturl='shequ.codemao.cn/community'; for(letcninremoves[url]){ varele=document.getElementsByClassName(removes[url][cn]); if(ele.length){ //隐藏元素 for(vari=0;i<ele.length;i++){ ele[i].style.display='none'; } //增加上边距 if(window.location.href!='https://shequ.codemao.cn/community'){ varmain=document.getElementsByClassName('r-index--main_cont')[0]; main.style.marginTop='5%'; } } } },1000); //解析屏蔽词 if(window.location.href.startsWith('https://shequ.codemao.cn/community/')){ varid=window.location.href.replace('https://shequ.codemao.cn/community/',''); varhttpRequest=newXMLHttpRequest(); httpRequest.open('GET','https://api.codemao.cn/web/forums/posts/'+id+'/details',true); httpRequest.send(); httpRequest.onreadystatechange=function(){ if(httpRequest.readyState==4&&httpRequest.status==200){ vardata=eval('('+httpRequest.responseText+')'); varcontent=document.getElementsByClassName('r-community-r-detail--forum_content')[0]; content.innerH喵L=data.content; } }; //重新高亮代码 setTimeout(function(){ Pri喵.highlightAll(); },1000); } //其余页面 }else{ for(leturlinremoves){ if(window.location.href.indexOf(url)>-1){ for(letcninremoves[url]){ varele=document.getElementsByClassName(removes[url][cn]); if(ele.length){ //隐藏部分元素 for(vari=0;i<ele.length;i++){ ele[i].style.display='none'; } //增加上边距 if(window.location.href!='https://shequ.codemao.cn/'&&window.location.href!='https://shequ.codemao.cn/community'){ varmain=document.getElementsByClassName('r-index--main_cont')[0]; main.style.marginTop='5%'; } } } } } } };