您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
移除讨厌鬼的帖子
当前为
// ==UserScript== // @name remove the posts which make you sick // @author burningall // @description 移除讨厌鬼的帖子 // @version 2015.6.11.1 // @include *tieba.baidu.com/p/* // @include *tieba.baidu.com/* // @include *tieba.baidu.com/f?* // @grant GM_addStyle // @grant GM_getValue // @grant GM_setValue // @grant GM_listValues // @grant GM_deleteValue // @supportURL http://www.burningall.com // @contributionURL [email protected]|alipay.com // @namespace https://gf.qytechs.cn/zh-CN/users/3400-axetroy // ==/UserScript== //============快捷键========== //【Ctrl】+【F3】-----调出控制面板 //============样式区========== var style='\ body{\ -webkit-backface-visibility: hidden;\ }\ .shutup-post{\ position:absolute;\ background-color:#07776E;\ color:#fff;\ right:0;\ top:0;\ padding:0 5px;\ border:1px solid #988181;\ cursor:pointer;\ }\ .shutup-list{\ position:absolute;\ background-color:#07776E;\ color:#fff;\ right:35px;\ top:0;\ padding:0 5px;\ border:1px solid #988181;\ cursor:pointer;\ z-index:999999997;\ }\ .blur{\ -webkit-filter: blur(10px);\ -moz-filter: blur(10px);\ -o-filter: blur(10px);\ -ms-filter: blur(10px);\ filter: blur(10px);\ }\ #pannal-troy{\ width:200px;\ height:auto;\ background:#303030;\ color:#fff;\ position:fixed;\ top:11%;\ left:33%;\ z-index:1000000000;\ text-align:center;\ }\ #pannal-troy>div{\ margin:10px 0;\ }\ #pannal-troy input{\ color:#3e3e3e;\ }\ #pannal-troy h3{\ color:rgb(0, 255, 226);\ }\ #fn input{\ padding:5px;\ margin:0 5px;\ border:none;\ cursor:pointer;\ }\ #fn input:hover{\ background:#2A959D;\ color:#fff;\ }\ #pannal-troy>span{\ position:absolute;\ padding:0 10px;\ top:0;\ right:0;\ cursor:pointer;\ opacity:0.8;\ background:#fff;\ color:#303030;\ }\ #blockWay{\ color:#3e3e3e;\ border:none;\ }\ #mars{\ position:fixed;\ width:100%;\ height:100%;\ background:rgba(155, 155, 155,0.5);\ top:0;\ left:0;\ z-index:999999999;\ }\ #showList{\ position:relative;\ overflow-y:auto;\ width:100%;\ max-height:115px;\ }\ #showList>li{\ width:100%;\ height:18px;\ clear:both;\ }\ .key{\ float:left;\ clear:both;\ }\ .deletThis{\ float:right;\ cursor:pointer;\ }\ .disable-btn{\ background:#6B6B6B;\ cursor:not-allowed;\ }\ '; GM_addStyle(style); //============公共函数区========== function addEvent(obj, event, fn) { return obj.addEventListener ? obj.addEventListener(event, fn, false) : obj.attachEventListener('on' + event, fn); }; function getStyle(obj, attr) { return obj.currentStyle ? obj.currentStyle[attr] : getComputedStyle(obj)[attr]; }; function $(id) { return document.getElementById(id) }; function getSize(attr){ return document.documentElement[attr] ? document.documentElement[attr] : document.body[attr] } //============主要代码区========== function juggUrl(){ var url=location.href; var postIn=/.*tieba.baidu.com\/p\/.*/ig; var postList=/.*tieba.baidu.com\/(f\?.*|[^p])/ig; if( postIn.test(url) ){//如果是帖子内 return 1; }else if( postList.test(url) ){//如果在帖子列表 return 2; } } function createList(){ $('showList').innerHTML=''; var li=''; for(var i=0;i<GM_listValues().length;i++){ //控制台输出 键名:键值 var key = GM_listValues()[i]; var value = GM_getValue( GM_listValues()[i],''); if( (typeof value =='number' && value>1000) || value==''){ console.log( GM_listValues()[i] + ":" + GM_getValue(GM_listValues()[i],'') ); li += '<li class="show_list" data="'+ key +'">'+'<span class="key">'+key+'</span>'+'<input class="deletThis" type="button" value="删除"/>'+'</li>'; }//if }//for $('showList').innerHTML=li; var aDeleBtn=document.querySelectorAll('.deletThis'); for(var i=0;i<aDeleBtn.length;i++){ aDeleBtn[i].onclick=function(){ var thisKey = this.parentNode.getAttribute('data');//获取当前结点的key console.log(thisKey); GM_deleteValue( thisKey );//删除变量 this.parentNode.remove( this.parentNode );//删除节点 }//clickb }//for }; function marks(obj){ if(obj.querySelectorAll('mar').length>=1){ return; } var oMar = document.createElement('div'); oMar.className = 'mar'; obj.style.position = 'relative'; obj.style.webkitFilter = 'blur('+ GM_getValue('setting-gus','3') +'px)';//chrome obj.style.filter = 'blur('+ GM_getValue('setting-gus','3') +'px)';//firefox obj.style.oFilter = 'blur('+ GM_getValue('setting-gus','3') +'px)';//opera obj.style.msFilter = 'blur('+ GM_getValue('setting-gus','3') +'px)';//IE obj.style.webkitBackfaceVisibility = 'hidden'; obj.appendChild( oMar ); oMar.style.width = parseInt( getStyle(obj,'width') ) + 'px'; oMar.style.height = parseInt( getStyle(obj,'height') ) + 'px'; oMar.style.background = GM_getValue('setting-col','#fff'); oMar.style.position = 'absolute'; oMar.style.top = '0'; oMar.style.left = '0'; oMar.style.zIndex = '999999998'; oMar.style.opacity = GM_getValue('setting-opa','0.8'); oMar.style.filter = 'alpha(opacity=' + GM_getValue('setting-opa','0.8')*100 +')'; }; function blockMod(){ if( GM_getValue('setting-blockWay','遮罩屏蔽')=='遮罩屏蔽' ){ return 1;//遮罩模式 }else{ return 2;//删除节点 } } function btclick(This,list,n){ var _thisTop,_thisUserId,_thisUserName,nowUserId,nowUserName; if(n==5){ _thisTop = This.parentNode.parentNode.parentNode.parentNode.parentNode;//当前结点,5层父节点,帖子列表 _thisUserId = JSON.parse(_thisTop.getAttribute('data-field')).id;//当前id _thisUserName = JSON.parse(_thisTop.getAttribute('data-field')).author_name;//当前userName }else if(n==4){ _thisTop = This.parentNode.parentNode.parentNode.parentNode;//当前结点,4层父节点,帖子里 _thisUserId = JSON.parse(_thisTop.getAttribute('data-field')).author.user_id;//当前id _thisUserName = JSON.parse(_thisTop.getAttribute('data-field')).author.user_name;//当前userName } if ( confirm('是否屏蔽') == true) { //如果按下确认 GM_setValue( _thisUserName,_thisUserId ); for (var j = 0; j < list.length; j++) {//循环匹配是否符合 if(n==5){ nowUserId = JSON.parse(list[j].getAttribute('data-field')).id; nowUserName = JSON.parse(list[j].getAttribute('data-field')).author_name; }else if(n==4){ nowUserId = JSON.parse(list[j].getAttribute('data-field')).author.user_id; nowUserName = JSON.parse(list[j].getAttribute('data-field')).author.user_name; } if (nowUserId == _thisUserId || nowUserName==_thisUserName) {//匹配成功 if( blockMod()==1 ){//遮罩模式 marks(list[j]); }else{//删除节点模式 list[j].style.display = 'none'; } }//匹配是否符 } //for }//if如果按下确认 } function block(name,id,list,I){ for(var j=0;j<GM_listValues().length;j++){ if( GM_listValues()[j] == name || GM_getValue(GM_listValues()[j],'') == id ){//如果匹配到 if( blockMod()==1 ){//遮罩模式 marks(list[I]); }else{//删除节点模式 list[I].style.display = 'none'; } }//匹配是否符合 }//for,遍历屏蔽 } function init() {//初始化程序 //先清空 var aBlockBtn = document.querySelectorAll('.shutup-post,.shutup-list,.mar') for(var i=0;i<aBlockBtn.length;i++){ aBlockBtn[i].remove(this); } //=======帖子内========== if( juggUrl()==1 ){ var aUsers = document.querySelectorAll('#j_p_postlist>div[data-field]');//获取列表 var aName = document.querySelectorAll('.j_l_post>.d_author .d_name');//屏蔽按钮将要插入的位置 for (var i = 0; i < aUsers.length; i++) { //获取id和name var userName = JSON.parse(aUsers[i].getAttribute('data-field')).author.user_name;//第i个userName var userId = JSON.parse(aUsers[i].getAttribute('data-field')).author.user_id;//第i个userId //创建屏蔽按钮 var oDiv = document.createElement('div'); oDiv.className = "shutup-post"; oDiv.innerHTML = '<p>屏<p><p>蔽</p>'; aName[i].appendChild(oDiv); var aShut = document.querySelectorAll('.shutup-post'); //给按钮添加点击事件 aShut[i].onclick=function(){ var this_=this; btclick(this_,aUsers,4); } //页面加载开始屏蔽 block(userName,userId,aUsers,i); } //for,遍历所有节点 //=======帖子列表========== }else if( juggUrl()==2 ){ var aUsers=document.querySelectorAll('#thread_list>li[data-field]');//获取列表 var aName = document.querySelectorAll('#thread_list>.j_thread_list>.t_con>.col2_right>.threadlist_lz>.threadlist_author');//屏蔽按钮将要插入的位置 for(var i=0;i<aUsers.length;i++){ //获取id和name var userName = JSON.parse(aUsers[i].getAttribute('data-field')).author_name;//第i个userName var userId = JSON.parse(aUsers[i].getAttribute('data-field')).id;//第i个userId //创建屏蔽按钮 var oDiv = document.createElement('div'); oDiv.className = "shutup-list"; oDiv.innerHTML = '<p>屏<p><p>蔽</p>'; aName[i].appendChild(oDiv); var aShut = document.querySelectorAll('.shutup-list'); //给按钮添加点击事件 aShut[i].onclick=function(){ var this_=this; btclick(this_,aUsers,5); } //页面加载开始屏蔽 block(userName,userId,aUsers,i) }//for,遍历所有节点 }//在帖子列表 }//初始化 //============执行区========== addEvent(window,'load',function(){ init(); }) //跟随翻页加载 var aUsers,aShut; addEvent(window,'scroll',function(){ if( getSize('scrollTop') == 0){ if( juggUrl()==1 ){//帖子内 aUsers = document.querySelectorAll('#j_p_postlist>div[data-field]'); aShut = document.querySelectorAll('.shutup-post'); }else if(juggUrl()==2){//帖子列表 aUsers=document.querySelectorAll('#thread_list>li[data-field]'); aShut = document.querySelectorAll('.shutup-list'); } if(aShut.length <= aUsers.length){//如果不存在屏蔽按钮 init(); } }//如果滚动到顶部 }) //============控制面板以及相关========== addEvent(window,'keyup',function(e){ var e = e || window.event; if( e.ctrlKey && e.keyCode==114 ){//快捷键ctrl+F3 if( $('pannal-troy') ) return; var pannal = document.createElement('div'); var pannal_mars = document.createElement('div'); pannal_mars.id = 'mars'; pannal_mars.className = "blur"; pannal.id = 'pannal-troy'; pannal.innerHTML='\ <h3>配置参数</h3>\ <div id="pannal-setting">\ 屏蔽方式:<select id="blockWay">\ <option>遮罩屏蔽</option>\ <option>删除节点</option>\ </select><br/>\ 遮罩层颜色:<input id="col" type="color" value="颜色" /><input type="text" id="col-text" placeholder="#fff(默认16进制)"/><br/>\ 遮罩透明度(0~1):<input id="opa" type="text" placeholder="0.8(默认)" /><br/>\ 高斯模糊像素(px):<input id="gus" type="text" placeholder="3(默认)" /><br/>\ </div>\ <hr/>\ <h3>添加屏蔽</h3>\ <div id="addBlackList">\ 数字ID(选填):<input id="userId" type="text" placeholder="user_id"/><br/>\ 贴吧ID(必填):<input id="userName" type="text" placeholder="user_name"/>\ </div>\ <hr/>\ <h3>功能</h3>\ <div id="fn">\ <input id="save" type="button" value="保存" />\ <input id="clear" type="button" value="清空" />\ <input id="view" type="button" value="查看" />\ </div>\ <hr/>\ <h3>屏蔽列表</h3>\ <div>\ <ul id="showList"></ul>\ </div>\ <span id="queit">X</span>\ ' document.body.appendChild( pannal ); document.body.appendChild( pannal_mars ); //初始化 $('blockWay').value = GM_getValue('setting-blockWay','遮罩屏蔽' );//屏蔽方式 $('col').value = GM_getValue('setting-col','#fff'); //默认遮罩的颜色 $('col-text').value = $('col').value; //默认遮罩的颜色,显示文本 $('opa').value = GM_getValue('setting-opa','0.8'); //默认遮罩透明度 $('gus').value = GM_getValue('setting-gus','3'); //默认遮罩下的高斯模糊半径 createList(); //加载黑名单列表 addEvent($('blockWay'),'input',function(){ var aInput=[$('col'),$('col-text'),$('opa'),$('gus')] if( $('blockWay').value == '删除节点' ){//删除节点模式 for(var i=0;i<aInput.length;i++){ aInput[i].readOnly = 'true'; aInput[i].className = 'disable-btn'; } }else{//遮罩屏蔽模式模式 for(var i=0;i<aInput.length;i++){ aInput[i].readOnly = 'false'; aInput[i].className = ''; } } }) addEvent($('col'),'input',function(){ $('col-text').value = $('col').value; }) addEvent($('col-text'),'input',function(){ $('col').value = $('col-text').value; }) //====保存按钮==== addEvent($('save'),'click',function(){ //判断屏蔽方式 if($('blockWay').value=='遮罩屏蔽'){ GM_setValue('setting-blockWay','遮罩屏蔽'); }else if($('blockWay').value=='删除节点'){ GM_setValue('setting-blockWay','删除节点'); } //遮罩颜色 GM_setValue('setting-col',$('col').value); //遮罩透明度 if( $('opa').value!='' && $('opa').value>0 && $('opa').value<1 ){//透明度有添加,并且0~1 GM_setValue('setting-opa',$('opa').value); } //高斯模糊半径 if( $('gus').value!='' && $('gus').value>0){ GM_setValue('setting-gus',$('gus').value); } //匹配ID是否正确 var reg=/^[0-9]{9}$/ig; if( $('userName').value!='' && (reg.test($('userId').value)==true || $('userId').value=='') ){ //保存形式:user_name:user_id GM_setValue( $('userName').value,$('userId').value ); alert('保存成功' + "\n用户名:" + $('userName').value + "\nID:" + GM_getValue($('userName').value,'') + '\n屏蔽方式:'+ GM_getValue('setting-blockWay','遮罩屏蔽' )+'\n遮罩颜色:' + GM_getValue('setting-col','#fff') + '\n遮罩透明度:'+ GM_getValue('setting-opa','0.8') +'\n高斯模糊:'+GM_getValue('setting-gus','3') ); }else if( $('userName').value=='' && $('userId').value==''){ alert('保存成功\n屏蔽方式:'+ GM_getValue('setting-blockWay','遮罩屏蔽' )+'\n遮罩颜色:' + GM_getValue('setting-col','#fff') + '\n遮罩透明度:'+ GM_getValue('setting-opa','0.8') +'\n高斯模糊:'+GM_getValue('setting-gus','3') ) }else{ alert('输入不正确:\n数字ID:选填(如果填了必须是9位数字)\n贴吧ID:必填') } createList();//重新生成列表 }) //====清空按钮==== addEvent($('clear'),'click',function(){ for(var i=0;i<GM_listValues().length;i++){ //清空所有变量 //GM_deleteValue( GM_listValues()[i] ) + ":" + GM_getValue( GM_listValues()[i],'' ) var value = GM_getValue( GM_listValues()[i],''); if( (typeof value=='number' && value>1000) || value==''){ GM_deleteValue( GM_listValues()[i] );//删除键名 } }//for createList();//重新生成列表 }) //====清空按钮==== addEvent($('view'),'click',function(){ createList();//生成列表 }) //===关闭按钮==== addEvent($('queit'),'click',function(){ $('pannal-troy').remove(this); $('mars').remove(this); }) addEvent($('mars'),'click',function(){ $('pannal-troy').remove(this); $('mars').remove(this); }) }//if })//addEvent
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址