您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
移除讨厌鬼的帖子
当前为
// ==UserScript== // @name remove the posts which make you sick // @author burningall // @description 移除讨厌鬼的帖子 // @version 2015.7.14 // @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 // @run-at document-start // @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('infor', '') == '') { alert('【移除讨厌鬼的帖子】脚本说明:\n1:控制面板【Ctrl】+【F3】\n2:点击贴吧ID屏蔽(黑色区域)\n3:如果遮罩屏蔽,双击遮罩即可选择解除\n4:升级至2015.7.13请在备份数据,控制面板初始化(多按几次),否则报错。'); GM_setValue('infor', 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;\ width:21px;\ height:21px;\ line-height:21px;\ font-size:21px;\ 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;\ }\ .mar p{\ color:#303030;\ font-weight:bold;\ }\ #list{\ position:absolute;\ top:0;\ left:200px;\ width:0;\ height:20px;\ overflow-x:hidden;\ overflow-y:auto;\ background:#303030;\ text-align:left;\ margin:0;\ }\ #list tr:hover{\ background:#165557;\ }\ .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; } //拖拽 function Drag(id) { var _this = this; this.disX = 0; this.disY = 0; this.oDiv = document.getElementById(id); this.oDiv.onmousedown = function(e) { _this.fnDown(e); var e = e || window.event; var target = e.target || e.SrcElement; if (target.nodeName == "INPUT") { //return false;//拖拽部分不可选中 } }; } Drag.prototype.fnDown = function(e) { //鼠标按下(未松开) var e = e || window.event; var _this = this; this.disX = e.clientX - this.oDiv.offsetLeft; this.disY = e.clientY - this.oDiv.offsetTop; document.onmousemove = function(e) { _this.fnMove(e); }; document.onmouseup = function() { _this.fnUp(); }; } Drag.prototype.fnMove = function(e) { //鼠标移动,则div移动 var e = e || window.event; this.oDiv.style.left = e.clientX - this.disX + 'px'; this.oDiv.style.top = e.clientY - this.disY + 'px'; } Drag.prototype.fnUp = function() { //鼠标松开,则停止 document.onmousemove = null; document.onmouseup = null; } function LimitDrag(id) { Drag.call(this, id) //继承Drag的属性 } for (var i in Drag.prototype) { LimitDrag.prototype[i] = Drag.prototype[i]; //继承Drag方法 } LimitDrag.prototype.fnMove = function(e) { //覆盖来自父级的fnMove,重写 var e = e || window.event; var l = e.clientX - this.disX; var t = e.clientY - this.disY; if (l < 0) { l = 0; } else if (l > document.documentElement.clientWidth - this.oDiv.offsetWidth) { l = document.documentElement.clientWidth - this.oDiv.offsetWidth; } if (t < 0) { t = 0; } else if (t > document.documentElement.clientHeight - this.oDiv.offsetHeight) { t = document.documentElement.clientHeight - this.oDiv.offsetHeight; } this.oDiv.style.left = l + 'px'; this.oDiv.style.top = t + 'px'; } //============主要代码区========== //判断当前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 blockMod() { if (GM_getValue('setting-blockWay', defaultdConfig.blockWay) == '遮罩屏蔽') { return 1; //遮罩模式 } else { return 2; //删除节点 } } function barName() { var name = document.querySelector('.card_title_fname'); var text = name.innerText || name.textContent; var newText = text.replace(/\s*/ig,''); return newText; } //生成屏蔽列表 function createList() { $('showList').innerHTML = ''; //先清空,后生成 var li = ''; var json = null; for (var i = 0; i < GM_listValues().length; i++) { var key = GM_listValues()[i]; var value = GM_getValue(GM_listValues()[i], ''); if (value.length < 10 || value == true || value == false) continue; json = JSON.parse(GM_getValue(GM_listValues()[i], '')); li += '<tr data=' + value + '>\ <td style="min-width:100px">' + json.name + '</td>\ <td style="min-width:100px">' + json.id + '</td>\ <td style="min-width:75px">' + json.bar + '</td>\ <td style="min-width:75px">' + json.reson + '</td>\ <td style="min-width:50px"><input type="button" class="deletThis" value="删除"/></td>\ </tr>\ '; } //for $('showList').innerHTML += li; var aDeleBtn = document.querySelectorAll('.deletThis'); for (var i = 0; i < aDeleBtn.length; i++) { aDeleBtn[i].onclick = function() { var infor = JSON.parse(this.parentNode.parentNode.getAttribute('data')); console.log(infor) GM_deleteValue(infor.name); //删除变量 this.parentNode.parentNode.remove(); //删除节点 }; } //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); var key = juggUrl() == 2 ? JSON.parse(obj.getAttribute('data-field')).author_name : JSON.parse(obj.getAttribute('data-field')).author.user_name; var data; for (var i = 0; i < GM_listValues().length; i++) { if (GM_listValues()[i] == key) { data = GM_getValue(GM_listValues()[i], ''); } } oMar.setAttribute('data', data); //遮罩层 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'; }; //屏蔽确认 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) { //This指当前被点击的按钮 var _thisTop, _thisUserId, _thisUserName, userInfo, 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 GM_setValue(_thisUserName, '{"name":"' + _thisUserName + '","id":"' + _thisUserId + '","bar":"' + barName() + '","reson":"不顺眼"}'); //添加变量 for (var j = 0; j < list.length; j++) { //循环匹配是否符合 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) { //匹配成功 var blockNow = blockMod() == 1 ? marks(list[j]) : list[j].style.display = 'none'; } //匹配是否符 } //for } //初始化程序,页面开始加载执行 function init() { var aShut, aUsers, aName, userName, userId; aUsers = juggUrl() == 1 ? document.querySelectorAll('#j_p_postlist>div[data-field]') : document.querySelectorAll('#thread_list>li[data-field]'); //获取用户列表 aName = juggUrl() == 1 ? document.querySelectorAll('.l_post .d_name') : document.querySelectorAll('#thread_list>li[data-field] .threadlist_lz>.threadlist_author'); //屏蔽按钮要插入的位置 aShut = juggUrl() == 1 ? document.querySelector('.l_post .d_name') : document.querySelector('#thread_list>li[data-field] .threadlist_lz>.threadlist_author, .l_post .d_name'); if (aShut.onclick) return false; for (var i = 0; i < aUsers.length; i++) { userName = juggUrl() == 1 ? JSON.parse(aUsers[i].getAttribute('data-field')).author.user_name : JSON.parse(aUsers[i].getAttribute('data-field')).author_name; //第i个userName userId = juggUrl() == 1 ? JSON.parse(aUsers[i].getAttribute('data-field')).author.user_id : JSON.parse(aUsers[i].getAttribute('data-field')).id; //第i个userId //添加点击事件 aName[i].onclick = function() { var this_ = this; var comfir = juggUrl() == 1 ? confirmBlock(this_, aUsers, 'post', 'author[user_id]', 'author[user_name]') : confirmBlock(this_, aUsers, 'postList', 'id', 'author_name'); } //onclick //页面加载开始屏蔽 block(userName, userId, aUsers, i); } //for } //页面初始化之后,屏蔽黑名单 function block(name, id, list, I) { for (var j = 0; j < GM_listValues().length; j++) { if (GM_listValues()[j] == name || JSON.parse(GM_getValue(GM_listValues()[j], '')).id == id) { //如果匹配到 var blockNow = blockMod() == 1 ? marks(list[I]) : list[I].style.display = 'none'; } //匹配是否符合 } //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 == '')) { GM_setValue($('userName').value, '{"name":"' + $('userName').value + '","id":"' + $("userId").value + '","bar":"' + $("curBar").value + '","reson":"' + $("reson").value + '"}'); console.log(JSON.parse(GM_getValue($('userName').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++) { //清空所有变量 //alert('请多点几次,存在BUG'); console.log(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 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 = ''; }) }) }); }) } //屏蔽列表展开与收起 function slideToggle(_this) { if (!_this.slide) { _this.slide = false; } if (_this.slide == false) { createList(); doMove($('list'), 'width', 100, 2 * 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; }); }) } } //userName输入的智能提示 function autoTips() { var aUsers, userName, userId, newString; var aTipsArr = new Array(); aUsers = juggUrl() == 1 ? document.querySelectorAll('#j_p_postlist>div[data-field]') : document.querySelectorAll('#thread_list>li[data-field]'); //获取列表 for (var i = 0; i < aUsers.length; i++) { userName = juggUrl() == 1 ? JSON.parse(aUsers[i].getAttribute('data-field')).author.user_name : JSON.parse(aUsers[i].getAttribute('data-field')).author_name; //第i个userName userId = juggUrl() == 1 ? JSON.parse(aUsers[i].getAttribute('data-field')).author.user_id : 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; } //智能提示屏蔽理由 function autoTipsreson() { var reson = ['大水B', '专业2楼黄图哥', '机制的广告哥', '脑白金', '满嘴喷粪', '把无知当个性', '要经验不要智商'] var str = ''; for (var i = 0; i < reson.length; i++) { str += '<option value="' + reson[i] + '" />'; } lstr.innerHTML = str; } //黑名单搜索 function searchInList() { createList(); var list = document.querySelectorAll('#showList tr'); $('showList').innerHTML = ''; //清空列表 var str = ''; for (var i = 0; i < list.length; i++) { var userInfo = JSON.parse(list[i].getAttribute('data')); if (userInfo.name.indexOf($('sear').value) >= 0 || userInfo.id.indexOf($('sear').value) >= 0 || userInfo.bar.indexOf($('sear').value) >= 0 || userInfo.reson.indexOf($('sear').value) >= 0) { //匹配name,id,bar,reson str += '<tr data=' + list[i].getAttribute('data') + '>\ <td style="width:100px">' + userInfo.name + '</td>\ <td style="width:100px">' + userInfo.id + '</td>\ <td style="width:75px">' + userInfo.bar + '</td>\ <td style="width:75px">' + userInfo.reson + '</td>\ <td style="width:50px"><input type="button" class="deletThis" value="删除"/></td></tr>\ '; } } //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')]; for (var i = 0; i < aInput.length; i++) { aInput[i].readOnly = $('blockWay').value == '删除节点' ? 'true' : 'false'; aInput[i].className = $('blockWay').value == '删除节点' ? 'disable-btn' : ''; } } //============执行区========== addEvent(document,'DOMContentLoaded',function(){//DOM节点加载完毕 init(); }) //跟随翻页加载 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 = ''; } //获取data数据 var data = JSON.parse(target.getAttribute('data')); //第一次点击 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="永久解除" />\ ' + '<p>' + data.name + '(' + data.id + '),其在' + data.bar + '因[' + data.reson + ']被屏蔽' + '</p>'; $('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"/><br/>\ <datalist id="lst" autocomplete="on"></datalist>\ 所在贴吧:<input id="curBar" type="text" value="" /><br/>\ 屏蔽原因:<input id="reson" type="text" list="lstr" value="讨厌鬼" />\ <datalist id="lstr" autocomplete="on"></datalist>\ </div>\ <hr/>\ <h3>功能</h3>\ <div id="fn">\ <p>升级2015.7.13,请备份名单,初始化(需要多点几次),否则报错。</p>\ <input id="save" type="button" value="保存" />\ <input id="clear" type="button" value="初始化" />\ <input id="view" type="button" value=">>" />\ </div>\ <div id="list" style="margin:0;">\ <input id="sear" type="text" list="BlackList" placeholder="搜索" autocomplete="off" />\ <table id="showList"></table>\ </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; $('curBar').value = barName(); //当前贴吧名 createList(); //加载黑名单列表 new LimitDrag('pannal-troy'); 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($('reson'), 'input', function() { autoTipsreson(); }) //选择删除节点模式则禁用选项 addEvent($('blockWay'), 'input', function() { banInput(); }) //====保存按钮==== addEvent($('save'), 'click', function() { save(); }) //====清空按钮==== addEvent($('clear'), 'click', function() { clearAll(); }) //====展开/收起按钮==== addEvent($('view'), 'click', function() { var _this = this; new 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或关注我们的公众号极客氢云获取最新地址