remove the posts which make you sick

移除讨厌鬼的帖子

当前为 2015-07-09 提交的版本,查看 最新版本

// ==UserScript==
// @name	remove the posts which make you sick
// @author	burningall
// @description	移除讨厌鬼的帖子
// @version     2015.7.10
// @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
// @compatible  chrome  推荐
// @compatible  firefox  性能稍微不足
// @license     The MIT License (MIT); http://opensource.org/licenses/MIT
// @supportURL		http://www.burningall.com
// @contributionURL	[email protected]|alipay.com
// @namespace https://gf.qytechs.cn/zh-CN/users/3400-axetroy
// ==/UserScript==

//============快捷键==========
//【Ctrl】+【F3】-----调出控制面板
//============第一次加载脚本,说明==========
if(GM_getValue('jsinfor','')==''){
	alert('【移除讨厌鬼的帖子】脚本说明:\n1:控制面板【Ctrl】+【F3】\n2:点击贴吧ID屏蔽(黑色区域)\n3:如果遮罩屏蔽,双击遮罩即可选择解除');
	GM_setValue('jsinfor',true);
	}
//============默认配置==========
var defaultdConfig = {
	'blockWay': '遮罩屏蔽',//屏蔽方式
	'color': '#ffffff',//遮罩颜色
	'opacity': '0.8',//遮罩透明度
	'blurpx': '3',//高斯模糊大小
	};
//============样式区==========
var style='\
	body{\
		-webkit-backface-visibility: hidden;\
	}\
	/*给body添加滤镜*/\
	.blur{\
		-webkit-filter: blur(5px) grayscale();\
		-moz-filter: blur(5px) grayscale();\
		-o-filter: blur(5px) grayscale();\
		-ms-filter: blur(5px) grayscale();\
		filter: blur(5px) grayscale();\
	}\
	#pannal-troy{\
		width:200px;\
		height:auto;\
		background:#303030;\
		color:#fff;\
		position:fixed;\
		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);\
	}\
	#pannal-setting input[type=range]{\
		width:80%;\
	}\
	#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;\
	}\
	/*屏蔽模板遮罩层*/\
	.mar{\
		width:100%;\
		height:100%;\
		position:absolute;\
		top:0;\
		left:0;\
		z-index:999999998;\
		-webkit-backface-visibility:hidden;\
		text-align:center;\
		font-size:16px;\
	}\
	.mar input{\
		background:#303030;\
		color:#fff;\
		padding:3px;\
		font-family:"宋体";\
		font-size:14px;\
	}\
	#showList{\
		position:relative;\
		overflow-y:auto;\
		overflow-x:hidden;\
		width:100%;\
		height:93%;\
	}\
	#list{\
		position:absolute;\
		width:0;\
		height:20px;\
		top:-10px;\
		left:200px;\
		background:#303030;\
		overflow:hidden;\
	}\
	#showList>li{\
		width:100%;\
		height:18px;\
		clear:both;\
		margin:10px 0;\
		cursor:pointer;\
	}\
	#showList>li:hover{\
		background-color:#54A19E;\
		color:#303030;\
	}\
	.key{\
		float:left;\
		clear:both;\
		margin-left:10px;\
		width:120px;\
		text-align:left;\
		overflow:hidden;\
		text-overflow:ellipsis;\
		white-space:nowrap;\
	}\
	.col{\
		border:none;\
	}\
	.deletThis{\
		float:right;\
		cursor:pointer;\
		margin-right:10px;\
		padding:0 5px;\
		border:0;\
		height:18px;\
	}\
	.disable-btn{\
		background:#6B6B6B;\
		cursor:not-allowed;\
	}\
	#addBlackList input{\
		width:80%;\
	}\
	/*userName列表*/\
	#thread_list>li[data-field] .threadlist_lz>.threadlist_author,.l_post .d_name{\
		background:#303030;\
		cursor:pointer;\
	}\
	#sear{\
		position:relative;\
		margin:0 auto;\
		text-align:center;\
		height:21px;\
		width:100%;\
		border:none;\
	}\
	.confirm-div{\
		width:100%;\
		height:0;\
		text-align:center;\
		background:#303030;\
		overflow:hidden;\
	}\
	.confirm-div input{\
		margin:10px 5px;\
		padding:4px 10px;\
		border:none;\
		cursor:pointer;\
	}\
	.confirm-div p{\
		color:#37A69E;\
		letter-spacing:10px;\
	}\
	';
GM_addStyle(style);
//============公共函数区==========
function hasClass(obj,cName) {
	// ( \\s|^ ) 判断前面是否有空格 (\\s | $ )判断后面是否有空格 两个感叹号为转换为布尔值 以方便做判断 
	return !! obj.className.match(new RegExp("(\\s|^)" + cName + "(\\s|$)")); 
};
function addClass(obj, cName) {
	if (!hasClass(obj, cName)) {
		obj.className += " " + cName;
	};
};
function removeClass(obj, cName) {
	if (hasClass(obj, cName)) {
		obj.className = obj.className.replace(new RegExp("(\\s|^)" + cName + "(\\s|$)"), " "); // replace方法是替换 
	};
};
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 insertAfter(newElement, targetElement) {
    var parent = targetElement.parentNode;
    if (parent.lastChild == targetElement) { 
        parent.appendChild(newElement);
    } else {
        parent.insertBefore(newElement, targetElement.nextSibling); 
    }
}
function doMove(obj, attr, dir, target, endFn) {
	dir = parseInt(getStyle(obj, attr)) < target ? dir: -dir; //对于方向矫正
	clearInterval(obj.timerMove) //清楚定时器
	obj.timerMove = setInterval(function() {
		var speed = parseInt(getStyle(obj, attr)) + dir //步长
		if (speed > target && dir > 0 || speed < target && dir < 0) { //判断往前或往后
			speed = target;
		};
		obj.style[attr] = speed + "px" //赋值
		if (speed == target) {
			clearInterval(obj.timerMove);
			endFn && endFn(); //回掉函数
		};
	},
	30)
};
function uniqueArray(data){
   data = data || [];  
   var a = {};  
   for (var i=0; i<data.length; i++) {  
	   var v = data[i];  
	   if (typeof(a[v]) == 'undefined'){  
			a[v] = 1;  
	   }  
   };  
   data.length=0;  
   for (var i in a){  
		data[data.length] = i;  
   }  
   return data;  
}
//============主要代码区==========
//判断当前url
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
			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',defaultdConfig.blurpx) +'px)';//chrome
	obj.style.filter = 'blur('+ GM_getValue('setting-gus',defaultdConfig.blurpx) +'px)';//firefox
	obj.style.oFilter = 'blur('+ GM_getValue('setting-gus',defaultdConfig.blurpx) +'px)';//opera
	obj.style.msFilter = 'blur('+ GM_getValue('setting-gus',defaultdConfig.blurpx) +'px)';//IE
	obj.style.webkitBackfaceVisibility = 'hidden';
	obj.appendChild( oMar );
	//遮罩层
	oMar.style.background = GM_getValue('setting-col',defaultdConfig.color);
	oMar.style.opacity = GM_getValue('setting-opa',defaultdConfig.opacity);
	oMar.style.filter = 'alpha(opacity=' + GM_getValue('setting-opa',defaultdConfig.opacity)*100 +')';
	oMar.style.webkitBackfaceVisibility = 'hidden';
};
//判断屏蔽模式
function blockMod(){
	if( GM_getValue('setting-blockWay',defaultdConfig.blockWay)=='遮罩屏蔽' ){
		return 1;//遮罩模式
		}else{
			return 2;//删除节点
			}
}
//屏蔽确认
var isBlock = false;//默认不屏蔽
var expand = false;	//记录是否展开
var LastThis = null;//记录上一次点击
function confirmBlock(This,list,n){
	if( LastThis == This && expand==true){//如果重复点击,并且已经显示屏蔽按钮
		doMove($('confirm-div'),'height',5,0,function(){
			$('confirm-div').remove(this);
			expand = false;
			})
		return;
		}
	LastThis = This;
	if( $('confirm-div') ){//如果页面上有按钮
		var allConfirmDiv = document.querySelectorAll('.confirm-div');
		//清空按钮
		for(var i=0;i<allConfirmDiv.length;i++){
			allConfirmDiv[i].remove(allConfirmDiv[i]);
			//doMove(allConfirmDiv[i],'height',2,0);
			}//for
		}
	var confirmDiv = document.createElement('div');
	if( juggUrl()==1 ){
		insertAfter(confirmDiv,This);
		}else{
			insertAfter(confirmDiv,This.parentNode);
			}
	confirmDiv.className = 'confirm-div';
	confirmDiv.id = 'confirm-div';
	confirmDiv.innerHTML = '\
							<p>是否屏蔽</p>\
							<input id="confirm-yes" type="button" value="确认" \><input id="confirm-no" type="button" value="取消" \>\
							';
	clearTimeout(document.TslideHide);
	doMove(confirmDiv,'height',5,65,function(){//屏蔽按钮被点击,展开
		expand = true;
		document.TslideHide = setTimeout(function(){
			doMove(confirmDiv,'height',5,0,function(){//收起
				confirmDiv.remove(this);
				expand = false;
				})
			},3000)
		})
	$('confirm-yes').onclick=function(){//确认
		isBlock = true;
		btclick(This,list,n);//屏蔽
		doMove(confirmDiv,'height',5,0,function(){//收起
			confirmDiv.remove(this);
			expand = true;
			})
		}
	$('confirm-no').onclick=function(){//取消
		isBlock = false;
		doMove(confirmDiv,'height',5,0,function(){//收起
			confirmDiv.remove(this);
			expand = false;
			})
		}
}
//点击屏蔽按钮,确认后执行屏蔽
function btclick(This,list,n){
	var _thisTop,_thisUserId,_thisUserName,nowUserId,nowUserName;
	_thisTop = (n=='postList') ? This.parentNode.parentNode.parentNode.parentNode : This.parentNode.parentNode.parentNode;//当前父节点
	_thisUserId = (n=='postList') ? JSON.parse(_thisTop.getAttribute('data-field')).id : JSON.parse(_thisTop.getAttribute('data-field')).author.user_id;//当前id
	_thisUserName = (n=='postList') ? JSON.parse(_thisTop.getAttribute('data-field')).author_name : JSON.parse(_thisTop.getAttribute('data-field')).author.user_name;//当前userName
	if ( isBlock == true) { //如果按下确认
		GM_setValue( _thisUserName,_thisUserId );
		for (var j = 0; j < list.length; j++) {//循环匹配是否符合
			var userInfo = JSON.parse(list[j].getAttribute('data-field'));
			nowUserId = (n=='postList') ? userInfo.id : nowUserId = userInfo.author.user_id;
			nowUserName = (n=='postList') ? userInfo.author_name : userInfo.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() {
	//=======帖子内==========
	if( juggUrl()==1 ){
		var aShut = document.querySelector('.l_post .d_name');
		if( aShut.onclick ){
			return false;
			}
		var aUsers = document.querySelectorAll('#j_p_postlist>div[data-field]');//获取列表
		var aName = document.querySelectorAll('.l_post .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
			//添加点击事件
			aName[i].onclick=function(){
				var this_=this;
				//btclick(this_,aUsers,'post','author[user_id]','author[user_name]');
				confirmBlock(this_,aUsers,'post','author[user_id]','author[user_name]');
				}
			//页面加载开始屏蔽
			block(userName,userId,aUsers,i);
		} //for,遍历所有节点
	//=======帖子列表==========
	}else if( juggUrl()==2 ){
		var aShut = document.querySelector('#thread_list>li[data-field] .threadlist_lz>.threadlist_author, .l_post .d_name');
		if( aShut.onclick ){
			return false;
			}
		var aUsers=document.querySelectorAll('#thread_list>li[data-field]');//获取列表
		var aName = document.querySelectorAll('#thread_list>li[data-field] .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
			//添加点击事件
			aName[i].onclick=function(){
				var this_=this;
				//btclick(this_,aUsers,'postList','id','author_name');
				confirmBlock(this_,aUsers,'postList','id','author_name');
				}
			//页面加载开始屏蔽
			block(userName,userId,aUsers,i)
			}//for,遍历所有节点
		}//在帖子列表
}//初始化
//============控制面板按钮功能============
//保存
function save(){
		//判断屏蔽方式
	if($('blockWay').value=='遮罩屏蔽'){
		GM_setValue('setting-blockWay','遮罩屏蔽');
	}else if($('blockWay').value=='删除节点'){
		GM_setValue('setting-blockWay','删除节点');	
	}
	//遮罩颜色
	GM_setValue('setting-col',$('col').value);
	//遮罩透明度1
	GM_setValue('setting-opa',$('opa').value);	
	//高斯模糊半径
	GM_setValue('setting-gus',$('gus').value);	
	//匹配ID是否正确
	var regId=/^[1-9][0-9]{4,}$/ig;
	if( $('userName').value!='' &&  (regId.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:选填([5~n位数])\n贴吧ID:必填');
			}
	if( parseInt( getStyle($('list'),'width') )>0 ) createList()//如果列表已经展开,重新生成列表
}
//清空
function clearAll(){
	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
	if( parseInt( getStyle($('list'),'width') )>0 ) createList()//如果列表已经展开,重新生成列表
}
//屏蔽列表展开与收起
function slideToggle(_this){
	if( !_this.slide ){
		_this.slide=false;
		}
	if(_this.slide == false){
	createList();
	doMove($('list'),'width',20,parseInt(getStyle($('pannal-troy'),'width')),function(){//展开
		doMove($('list'),'height',40,parseInt(getStyle($('pannal-troy'),'height')),function(){
			$('sear').focus();
			$('view').value = '<<';
			_this.slide = true;
			});
		})
	}else if( _this.slide == true ){
		doMove($('list'),'height',40,20,function(){
			doMove($('list'),'width',20,0,function(){//收起
				$('view').value = '>>';
				_this.slide = false;
				});
			})
		}
}
//关闭
function closePannal(){
	doMove($('list'),'height',40,20,function(){
		doMove($('list'),'width',25,0,function(){//收起
			$('view').value = '>>';
			turn = false;
			$('pannal-troy').style.overflow = 'hidden';
			doMove($('pannal-troy'),'height',40,15,function(){
				doMove($('pannal-troy'),'width',25,0,function(){
					$('pannal-troy').remove(this);
					$('mars').remove(this);
					document.body.className = '';
					})
				})
			});
		})
}
//userName输入的智能提示
function autoTips(){
	var aUsers,userName,userId;
	if( juggUrl()==1 ){//帖子内
		var aTipsArr = new Array();
		var newString = '';
		aUsers = document.querySelectorAll('#j_p_postlist>div[data-field]');//获取列表
		for(var i=0;i<aUsers.length;i++){
			userName = JSON.parse(aUsers[i].getAttribute('data-field')).author.user_name;//第i个userName
			userId = JSON.parse(aUsers[i].getAttribute('data-field')).author.user_id;//第i个userId
			aTipsArr.push( userName );
			}
		uniqueArray( aTipsArr );
		for(var i=0;i<aTipsArr.length;i++){
			newString += '<option value="' + aTipsArr[i] + '" />';
			}
		lst.innerHTML = newString;
		}else{//帖子列表
			var aTipsArr = new Array();
			var newString = '';
			aUsers=document.querySelectorAll('#thread_list>li[data-field]');//获取列表
			for(var i=0;i<aUsers.length;i++){
				userName = JSON.parse(aUsers[i].getAttribute('data-field')).author_name;//第i个userName
				userId = JSON.parse(aUsers[i].getAttribute('data-field')).id;//第i个userId
				aTipsArr.push( userName );
				}
			uniqueArray( aTipsArr );
			for(var i=0;i<aTipsArr.length;i++){
				newString += '<option value="' + aTipsArr[i] + '" />';
				}
			lst.innerHTML = newString;
			}//if....else
}
//黑名单搜索
function searchInList(){
		createList();
		var list = document.querySelectorAll('#showList .show_list');
		$('showList').innerHTML = '';//清空列表
		var str = '';
		for(var i=0;i<list.length;i++){
			var userName =  list[i].getAttribute('data');
			if( userName.indexOf( $('sear').value ) >=0 ){//如果搜索到
				str += '<li class="show_list" data="'+ userName +'">'+'<span class="key">'+userName+'</span>'+'<input class="deletThis" type="button" value="删除"/>'+'</li>';
				}
			}//for
		$('showList').innerHTML = str;//生成列表
		//添加点击事件
		var aDeleBtn=document.querySelectorAll('.deletThis');
		for(var i=0;i<aDeleBtn.length;i++){
			aDeleBtn[i].onclick=function(){
				var thisKey = this.parentNode.getAttribute('data');//获取当前结点的key
				GM_deleteValue( thisKey );//删除变量
				this.parentNode.remove( this.parentNode );//删除节点		
			}//click
		}//for	
}
//删除节点模式禁用按钮
function banInput(){
	var aInput=[$('col'),$('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(window,'load',function(){
	init();
})
//跟随翻页加载
var aUsers,aShut;
addEvent(window,'scroll',function(){
	if( getSize('scrollTop') == 0){
		clearTimeout(document.TPage);
		document.TPage = setTimeout(init,3000);
		}//如果滚动到顶部
	})
//阻止事件冒泡,解除屏蔽等
addEvent(document,'click',function(e){
	var e = e || window.event;
	var target = e.target || e.srcElement;
	//if( 如果在帖子内 || 如果在帖子列表 )
	if( target.getAttribute('data-field') && hasClass(target.parentNode,'d_name') || target.getAttribute('data-field') && hasClass(target.parentNode,'tb_icon_author') ){//如果点到了名字上面
		if(e && e.stopPropagation){//chrome,firefox
			e.preventDefault();//阻止默认事件
			e.stopPropagation();//阻止冒泡
			}else{//ie
				e.returnValue = false;//阻止默认事件
				e.cancelBubble = true;//阻止冒泡
				}
		}//如果匹配
	if( hasClass(target,'mar') ){//点击遮罩层
		//清空HTML
		var allMar = document.querySelectorAll('.mar');
		for( var i=0;i<allMar.length;i++ ){
			allMar[i].innerHTML = '';
			}
		if( !target.ready ){//第一次点击
			target.ready = true;
			target.style.borderLeft = '5px solid rgb(174, 103, 34)';
		}else if( target.ready == true ){//再次点击
			target.parentNode.style.webkitFilter = 'none';
			target.parentNode.style.filter = 'none';
			target.parentNode.style.oFilter = 'none';
			target.parentNode.style.msFilter = 'none';
			target.style.background = 'none';
			target.style.opacity = '1';
			function keeplock(){
				target.parentNode.style.webkitFilter = 'blur('+ GM_getValue('setting-gus',defaultdConfig.blurpx) +'px)';//chrome
				target.parentNode.style.filter = 'blur('+ GM_getValue('setting-gus',defaultdConfig.blurpx) +'px)';//firefox
				target.parentNode.style.oFilter = 'blur('+ GM_getValue('setting-gus',defaultdConfig.blurpx) +'px)';//opera
				target.parentNode.style.msFilter = 'blur('+ GM_getValue('setting-gus',defaultdConfig.blurpx) +'px)';//IE
				target.style.opacity = '0.8';
				target.style.background = '#ffffff';
				target.style.border = 'none';
				target.innerHTML = '';
				target.ready = null;
				}
			function unblockNow(){
				target.remove(this);
				}
			function unlock(){
				var userName = (juggUrl()==2) ? JSON.parse(target.parentNode.getAttribute('data-field')).author_name : JSON.parse(target.parentNode.getAttribute('data-field')).author.user_name;//当前userName
				GM_deleteValue( userName );//删除键名
				target.remove(this);
				}
			target.innerHTML = '\
								<input type="button" id="keeplock" value="继续屏蔽" />\
								<input type="button" id="unlockNow" value="暂时解除 "/>\
								<input type="button" id="unlock" value="永久解除" />\
								'
			$('keeplock').onclick=keeplock;
			$('unlockNow').onclick=unblockNow;
			$('unlock').onclick=unlock;
			}
	}
})
//============控制面板以及相关==========
addEvent(window,'resize',function(){
	if( $('pannal-troy') ){
		$('pannal-troy').style.top = ( getSize('clientHeight') - $('pannal-troy').offsetHeight )/2 + 'px';
		$('pannal-troy').style.left = ( getSize('clientWidth') - $('pannal-troy').offsetWidth )/2 + 'px';
		}
})
//调处控制面板
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.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" /><br/>\
							遮罩透明度(0~1):<span id="opa-text"></span><input id="opa" type="range" min="0" max="1" step="0.1" /><br/>\
							高斯模糊像素(0~10):<span id="gus-text"></span><input id="gus" type="range" min="0" max="10" step="1" /><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" list="lst" autocomplete="off"/>\
							<datalist id="lst" autocomplete="on"></datalist>\
						</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>\
						<div id="list">\
							<input id="sear" type="text" list="BlackList" placeholder="搜索" autocomplete="off" />\
							<ul id="showList"></ul>\
						</div>\
						<span id="queit">X</span>\
						'
		document.documentElement.appendChild( pannal );
		document.documentElement.appendChild( pannal_mars );
		document.body.className = 'blur';
		pannal.style.top = ( getSize('clientHeight') - pannal.offsetHeight )/2 + 'px';
		pannal.style.left = ( getSize('clientWidth') - pannal.offsetWidth )/2 + 'px';
		//初始化数据
		$('blockWay').value = GM_getValue('setting-blockWay',defaultdConfig.blockWay );//屏蔽方式
		$('col').value = GM_getValue('setting-col',defaultdConfig.color);			//默认遮罩的颜色
		$('opa').value = GM_getValue('setting-opa',defaultdConfig.opacity);			//默认遮罩透明度
		$('opa-text').innerHTML = $('opa').value;
		$('gus').value = GM_getValue('setting-gus',defaultdConfig.blurpx);			//默认遮罩下的高斯模糊半径
		$('gus-text').innerHTML = $('gus').value;
		createList();//加载黑名单列表
		addEvent($('opa'),'input',function(){$('opa-text').innerHTML = $('opa').value;})
		addEvent($('gus'),'input',function(){$('gus-text').innerHTML = $('gus').value;})
		//智能提示userName和userId
		addEvent($('userName'),'input',function(){autoTips();})
		//选择删除节点模式则禁用选项
		addEvent($('blockWay'),'input',function(){banInput();})
		//====保存按钮====
		addEvent($('save'),'click',function(){save();})
		//====清空按钮====
		addEvent($('clear'),'click',function(){clearAll();})
		//====展开/收起按钮====
		addEvent($('view'),'click',function(){var _this=this;slideToggle(_this);})
		//黑名单搜索
		addEvent($('sear'),'input',function(){searchInList();})
		//黑名单搜索,backspace键
		addEvent(window,'keyup',function(e){
			var e= e || window.event;
			if(e.keyCode==8){//backspace
				if( $('sear').value == '' ){
					createList();
					}
				}
		})
		//===关闭按钮====
		addEvent($('queit'),'click',function(){closePannal();})
		addEvent($('mars'),'click',function(){closePannal();})
	}//if
})//addEvent

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址