remove the posts which make you sick

贴吧移除讨厌鬼的帖子

目前为 2015-07-05 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name remove the posts which make you sick
  3. // @author burningall
  4. // @description 贴吧移除讨厌鬼的帖子
  5. // @version 2015.7.5.2.0
  6. // @include *tieba.baidu.com/p/*
  7. // @include *tieba.baidu.com/*
  8. // @include *tieba.baidu.com/f?*
  9. // @grant GM_addStyle
  10. // @grant GM_getValue
  11. // @grant GM_setValue
  12. // @grant GM_listValues
  13. // @grant GM_deleteValue
  14. // @compatible chrome 推荐
  15. // @compatible firefox 性能稍微不足
  16. // @license The MIT License (MIT); http://opensource.org/licenses/MIT
  17. // @supportURL http://www.burningall.com
  18. // @contributionURL troy450409405@gmail.com|alipay.com
  19. // @namespace https://gf.qytechs.cn/zh-CN/users/3400-axetroy
  20. // ==/UserScript==
  21.  
  22. //============快捷键==========
  23. //【Ctrl】+【F3】-----调出控制面板
  24. //============样式区==========
  25. var style='\
  26. body{\
  27. -webkit-backface-visibility: hidden;\
  28. }\
  29. /*给body添加滤镜*/\
  30. .blur{\
  31. -webkit-filter: blur(5px) grayscale();\
  32. -moz-filter: blur(5px) grayscale();\
  33. -o-filter: blur(5px) grayscale();\
  34. -ms-filter: blur(5px) grayscale();\
  35. filter: blur(5px) grayscale();\
  36. }\
  37. #pannal-troy{\
  38. width:200px;\
  39. height:auto;\
  40. background:#303030;\
  41. color:#fff;\
  42. position:fixed;\
  43. z-index:1000000000;\
  44. text-align:center;\
  45. }\
  46. #pannal-troy>div{\
  47. margin:10px 0;\
  48. }\
  49. #pannal-troy input{\
  50. color:#3e3e3e;\
  51. }\
  52. #pannal-troy h3{\
  53. color:rgb(0, 255, 226);\
  54. }\
  55. #pannal-setting input[type=range]{\
  56. width:80%;\
  57. }\
  58. #fn input{\
  59. padding:5px;\
  60. margin:0 5px;\
  61. border:none;\
  62. cursor:pointer;\
  63. }\
  64. #fn input:hover{\
  65. background:#2A959D;\
  66. color:#fff;\
  67. }\
  68. #pannal-troy>span{\
  69. position:absolute;\
  70. padding:0 10px;\
  71. top:0;\
  72. right:0;\
  73. cursor:pointer;\
  74. opacity:0.8;\
  75. background:#fff;\
  76. color:#303030;\
  77. }\
  78. #blockWay{\
  79. color:#3e3e3e;\
  80. border:none;\
  81. }\
  82. /*控制面板遮罩层*/\
  83. #mars{\
  84. position:fixed;\
  85. width:100%;\
  86. height:100%;\
  87. background:rgba(155, 155, 155,0.5);\
  88. top:0;\
  89. left:0;\
  90. z-index:999999999;\
  91. }\
  92. /*屏蔽模板遮罩层*/\
  93. .mar{\
  94. position:absolute;\
  95. top:0;\
  96. left:0;\
  97. z-index:999999998;\
  98. -webkit-backface-visibilityhidden;\
  99. }\
  100. #showList{\
  101. position:relative;\
  102. overflow-y:auto;\
  103. overflow-x:hidden;\
  104. width:100%;\
  105. height:93%;\
  106. }\
  107. #list{\
  108. position:absolute;\
  109. width:0;\
  110. height:20px;\
  111. top:-10px;\
  112. left:200px;\
  113. background:#303030;\
  114. overflow:hidden;\
  115. }\
  116. #showList>li{\
  117. width:100%;\
  118. height:18px;\
  119. clear:both;\
  120. margin:10px 0;\
  121. cursor:pointer;\
  122. }\
  123. #showList>li:hover{\
  124. background-color:#54A19E;\
  125. color:#303030;\
  126. }\
  127. .key{\
  128. float:left;\
  129. clear:both;\
  130. margin-left:10px;\
  131. width:120px;\
  132. text-align:left;\
  133. overflow:hidden;\
  134. text-overflow:ellipsis;\
  135. white-space:nowrap;\
  136. }\
  137. .col{\
  138. border:none;\
  139. }\
  140. .deletThis{\
  141. float:right;\
  142. cursor:pointer;\
  143. margin-right:10px;\
  144. padding:0 5px;\
  145. border:0;\
  146. height:18px;\
  147. }\
  148. .disable-btn{\
  149. background:#6B6B6B;\
  150. cursor:not-allowed;\
  151. }\
  152. #addBlackList input{\
  153. width:80%;\
  154. }\
  155. #thread_list>li[data-field] .threadlist_lz>.threadlist_author,.l_post .d_name{\
  156. background:#303030;\
  157. }\
  158. #sear{\
  159. position:relative;\
  160. margin:0 auto;\
  161. text-align:center;\
  162. height:21px;\
  163. width:100%;\
  164. border:none;\
  165. }\
  166. ';
  167. GM_addStyle(style);
  168. //============公共函数区==========
  169. function hasClass(obj,cName) {
  170. // ( \\s|^ ) 判断前面是否有空格 (\\s | $ )判断后面是否有空格 两个感叹号为转换为布尔值 以方便做判断
  171. return !! obj.className.match(new RegExp("(\\s|^)" + cName + "(\\s|$)"));
  172. };
  173. function addClass(obj, cName) {
  174. if (!hasClass(obj, cName)) {
  175. obj.className += " " + cName;
  176. };
  177. };
  178. function removeClass(obj, cName) {
  179. if (hasClass(obj, cName)) {
  180. obj.className = obj.className.replace(new RegExp("(\\s|^)" + cName + "(\\s|$)"), " "); // replace方法是替换
  181. };
  182. };
  183. function addEvent(obj, event, fn) {
  184. return obj.addEventListener ? obj.addEventListener(event, fn, false) : obj.attachEventListener('on' + event, fn);
  185. };
  186. function getStyle(obj, attr) {
  187. return obj.currentStyle ? obj.currentStyle[attr] : getComputedStyle(obj)[attr];
  188. };
  189. function $(id) {
  190. return document.getElementById(id)
  191. };
  192. function getSize(attr){
  193. return document.documentElement[attr] ? document.documentElement[attr] : document.body[attr]
  194. }
  195. function doMove(obj, attr, dir, target, endFn) {
  196. dir = parseInt(getStyle(obj, attr)) < target ? dir: -dir; //对于方向矫正
  197. clearInterval(obj.timerMove) //清楚定时器
  198. obj.timerMove = setInterval(function() {
  199. var speed = parseInt(getStyle(obj, attr)) + dir //步长
  200. if (speed > target && dir > 0 || speed < target && dir < 0) { //判断往前或往后
  201. speed = target;
  202. };
  203. obj.style[attr] = speed + "px" //赋值
  204. if (speed == target) {
  205. clearInterval(obj.timerMove);
  206. endFn && endFn(); //回掉函数
  207. };
  208. },
  209. 30)
  210. };
  211. function uniqueArray(data){
  212. data = data || [];
  213. var a = {};
  214. for (var i=0; i<data.length; i++) {
  215. var v = data[i];
  216. if (typeof(a[v]) == 'undefined'){
  217. a[v] = 1;
  218. }
  219. };
  220. data.length=0;
  221. for (var i in a){
  222. data[data.length] = i;
  223. }
  224. return data;
  225. }
  226. //============主要代码区==========
  227. function juggUrl(){
  228. var url=location.href;
  229. var postIn=/.*tieba.baidu.com\/p\/.*/ig;
  230. var postList=/.*tieba.baidu.com\/(f\?.*|[^p])/ig;
  231. if( postIn.test(url) ){//如果是帖子内
  232. return 1;
  233. }else if( postList.test(url) ){//如果在帖子列表
  234. return 2;
  235. }
  236. }
  237. function createList(){
  238. $('showList').innerHTML='';
  239. var li='';
  240. for(var i=0;i<GM_listValues().length;i++){
  241. //控制台输出 键名:键值
  242. var key = GM_listValues()[i];
  243. var value = GM_getValue( GM_listValues()[i],'');
  244. if( (typeof value =='number' && value>1000) || value==''){
  245. //console.log( GM_listValues()[i] + ":" + GM_getValue(GM_listValues()[i],'') );
  246. li += '<li class="show_list" data="'+ key +'">'+'<span class="key">'+key+'</span>'+'<input class="deletThis" type="button" value="删除"/>'+'</li>';
  247. }//if
  248. }//for
  249. $('showList').innerHTML=li;
  250. var aDeleBtn=document.querySelectorAll('.deletThis');
  251. for(var i=0;i<aDeleBtn.length;i++){
  252. aDeleBtn[i].onclick=function(){
  253. var thisKey = this.parentNode.getAttribute('data');//获取当前结点的key
  254. GM_deleteValue( thisKey );//删除变量
  255. this.parentNode.remove( this.parentNode );//删除节点
  256. }//clickb
  257. }//for
  258. };
  259. function marks(obj){
  260. if(obj.querySelectorAll('.mar').length>=1){
  261. return;
  262. }
  263. var oMar = document.createElement('div');
  264. oMar.className = 'mar';
  265. //要屏蔽的模块
  266. obj.style.position = 'relative';
  267. obj.style.webkitFilter = 'blur('+ GM_getValue('setting-gus','3') +'px)';//chrome
  268. obj.style.filter = 'blur('+ GM_getValue('setting-gus','3') +'px)';//firefox
  269. obj.style.oFilter = 'blur('+ GM_getValue('setting-gus','3') +'px)';//opera
  270. obj.style.msFilter = 'blur('+ GM_getValue('setting-gus','3') +'px)';//IE
  271. obj.style.webkitBackfaceVisibility = 'hidden';
  272. obj.appendChild( oMar );
  273. //遮罩层
  274. oMar.style.width = parseInt( getStyle(obj,'width') ) + 'px';
  275. oMar.style.height = parseInt( getStyle(obj,'height') ) + 'px';
  276. oMar.style.background = GM_getValue('setting-col','#ffffff');
  277. oMar.style.opacity = GM_getValue('setting-opa','0.8');
  278. oMar.style.filter = 'alpha(opacity=' + GM_getValue('setting-opa','0.8')*100 +')';
  279. oMar.style.webkitBackfaceVisibility = 'hidden';
  280. };
  281. function blockMod(){
  282. if( GM_getValue('setting-blockWay','遮罩屏蔽')=='遮罩屏蔽' ){
  283. return 1;//遮罩模式
  284. }else{
  285. return 2;//删除节点
  286. }
  287. }
  288.  
  289. function btclick(This,list,n){
  290. var _thisTop,_thisUserId,_thisUserName,nowUserId,nowUserName;
  291. if(n=='postList'){
  292. _thisTop = This.parentNode.parentNode.parentNode.parentNode;
  293. _thisUserId = JSON.parse(_thisTop.getAttribute('data-field')).id;//当前id
  294. _thisUserName = JSON.parse(_thisTop.getAttribute('data-field')).author_name;//当前userName
  295. }else if(n=='post'){
  296. _thisTop = This.parentNode.parentNode.parentNode;
  297. _thisUserId = JSON.parse(_thisTop.getAttribute('data-field')).author.user_id;//当前id
  298. _thisUserName = JSON.parse(_thisTop.getAttribute('data-field')).author.user_name;//当前userName
  299. }
  300. if ( confirm('是否屏蔽') == true) { //如果按下确认
  301. GM_setValue( _thisUserName,_thisUserId );
  302. for (var j = 0; j < list.length; j++) {//循环匹配是否符合
  303. var userInfo = JSON.parse(list[j].getAttribute('data-field'))
  304. if(n=='postList'){
  305. nowUserId = userInfo.id;
  306. nowUserName = userInfo.author_name;
  307. }else if(n=='post'){
  308. nowUserId = userInfo.author.user_id;
  309. nowUserName = userInfo.author.user_name;
  310. }
  311. if (nowUserId == _thisUserId || nowUserName==_thisUserName) {//匹配成功
  312. if( blockMod()==1 ){//遮罩模式
  313. marks(list[j]);
  314. }else{//删除节点模式
  315. list[j].style.display = 'none';
  316. }
  317. }//匹配是否符
  318. } //for
  319. }//if如果按下确认
  320. }
  321. function block(name,id,list,I){
  322. for(var j=0;j<GM_listValues().length;j++){
  323. if( GM_listValues()[j] == name || GM_getValue(GM_listValues()[j],'') == id ){//如果匹配到
  324. if( blockMod()==1 ){//遮罩模式
  325. marks(list[I]);
  326. }else{//删除节点模式
  327. list[I].style.display = 'none';
  328. }
  329. }//匹配是否符合
  330. }//for,遍历屏蔽
  331. }
  332.  
  333. function autoTips(){
  334. var aUsers,userName,userId;
  335. if( juggUrl()==1 ){//帖子内
  336. var aTipsArr = new Array();
  337. var newString = '';
  338. aUsers = document.querySelectorAll('#j_p_postlist>div[data-field]');//获取列表
  339. for(var i=0;i<aUsers.length;i++){
  340. userName = JSON.parse(aUsers[i].getAttribute('data-field')).author.user_name;//第i个userName
  341. userId = JSON.parse(aUsers[i].getAttribute('data-field')).author.user_id;//第i个userId
  342. aTipsArr.push( userName );
  343. }
  344. uniqueArray( aTipsArr );
  345. for(var i=0;i<aTipsArr.length;i++){
  346. newString += '<option value="' + aTipsArr[i] + '" />';
  347. }
  348. lst.innerHTML = newString;
  349. }else{//帖子列表
  350. var aTipsArr = new Array();
  351. var newString = '';
  352. aUsers=document.querySelectorAll('#thread_list>li[data-field]');//获取列表
  353. for(var i=0;i<aUsers.length;i++){
  354. userName = JSON.parse(aUsers[i].getAttribute('data-field')).author_name;//第i个userName
  355. userId = JSON.parse(aUsers[i].getAttribute('data-field')).id;//第i个userId
  356. aTipsArr.push( userName );
  357. }
  358. uniqueArray( aTipsArr );
  359. for(var i=0;i<aTipsArr.length;i++){
  360. newString += '<option value="' + aTipsArr[i] + '" />';
  361. }
  362. lst.innerHTML = newString;
  363. }//if....else
  364. }
  365. function closePannal(){
  366. doMove($('list'),'height',40,20,function(){
  367. doMove($('list'),'width',25,0,function(){//收起
  368. $('view').value = '>>';
  369. turn = false;
  370. $('pannal-troy').style.overflow = 'hidden';
  371. doMove($('pannal-troy'),'height',40,15,function(){
  372. doMove($('pannal-troy'),'width',25,0,function(){
  373. $('pannal-troy').remove(this);
  374. $('mars').remove(this);
  375. document.body.className = '';
  376. })
  377. })
  378. });
  379. })
  380. }
  381. function init() {//初始化程序
  382. //=======帖子内==========
  383. if( juggUrl()==1 ){
  384. var aShut = document.querySelector('.l_post .d_name');
  385. if( aShut.onclick ){
  386. return false;
  387. }
  388. var aUsers = document.querySelectorAll('#j_p_postlist>div[data-field]');//获取列表
  389. var aName = document.querySelectorAll('.l_post .d_name');//屏蔽按钮将要插入的位置
  390. for (var i = 0; i < aUsers.length; i++) {
  391. //获取id和name
  392. var userName = JSON.parse(aUsers[i].getAttribute('data-field')).author.user_name;//第i个userName
  393. var userId = JSON.parse(aUsers[i].getAttribute('data-field')).author.user_id;//第i个userId
  394. //添加点击事件
  395. aName[i].onclick=function(){
  396. var this_=this;
  397. btclick(this_,aUsers,'post','author[user_id]','author[user_name]');
  398. }
  399. //页面加载开始屏蔽
  400. block(userName,userId,aUsers,i);
  401. } //for,遍历所有节点
  402. //=======帖子列表==========
  403. }else if( juggUrl()==2 ){
  404. var aShut = document.querySelector('#thread_list>li[data-field] .threadlist_lz>.threadlist_author, .l_post .d_name');
  405. if( aShut.onclick ){
  406. return false;
  407. }
  408. var aUsers=document.querySelectorAll('#thread_list>li[data-field]');//获取列表
  409. var aName = document.querySelectorAll('#thread_list>li[data-field] .threadlist_lz>.threadlist_author');//屏蔽按钮将要插入的位置
  410. for(var i=0;i<aUsers.length;i++){
  411. //获取id和name
  412. var userName = JSON.parse(aUsers[i].getAttribute('data-field')).author_name;//第i个userName
  413. var userId = JSON.parse(aUsers[i].getAttribute('data-field')).id;//第i个userId
  414. //添加点击事件
  415. aName[i].onclick=function(){
  416. var this_=this;
  417. btclick(this_,aUsers,'postList','id','author_name');
  418. }
  419. //页面加载开始屏蔽
  420. block(userName,userId,aUsers,i)
  421. }//for,遍历所有节点
  422. }//在帖子列表
  423. }//初始化
  424. //============执行区==========
  425. addEvent(window,'load',function(){
  426. init();
  427. })
  428. //跟随翻页加载
  429. var aUsers,aShut;
  430. addEvent(window,'scroll',function(){
  431. if( getSize('scrollTop') == 0){
  432. clearTimeout(document.TPage);
  433. document.TPage = setTimeout(init,3000);
  434. }//如果滚动到顶部
  435. })
  436. //============控制面板以及相关==========
  437. addEvent(window,'resize',function(){
  438. if( $('pannal-troy') ){
  439. $('pannal-troy').style.top = ( getSize('clientHeight') - $('pannal-troy').offsetHeight )/2 + 'px';
  440. $('pannal-troy').style.left = ( getSize('clientWidth') - $('pannal-troy').offsetWidth )/2 + 'px';
  441. }
  442. })
  443. addEvent(window,'keyup',function(e){
  444. var e = e || window.event;
  445. if( e.ctrlKey && e.keyCode==114 ){//快捷键ctrl+F3
  446. if( $('pannal-troy') ) return;
  447. var pannal = document.createElement('div');
  448. var pannal_mars = document.createElement('div');
  449. pannal_mars.id = 'mars';
  450. pannal.id = 'pannal-troy';
  451. pannal.innerHTML='\
  452. <h3>配置参数</h3>\
  453. <div id="pannal-setting">\
  454. 屏蔽方式:<select id="blockWay">\
  455. <option>遮罩屏蔽</option>\
  456. <option>删除节点</option>\
  457. </select><br/>\
  458. 遮罩层颜色:<input id="col" type="color" /><br/>\
  459. 遮罩透明度(0~1):<span id="opa-text"></span><input id="opa" type="range" min="0" max="1" step="0.1" /><br/>\
  460. 高斯模糊像素(0~10):<span id="gus-text"></span><input id="gus" type="range" min="0" max="10" step="1" /><br/>\
  461. </div>\
  462. <hr/>\
  463. <h3>添加讨厌鬼</h3>\
  464. <div id="addBlackList">\
  465. 数字ID(选填):<input id="userId" type="text" placeholder="user_id"/><br/>\
  466. 贴吧ID(必填):<input id="userName" type="text" placeholder="user_name" list="lst" autocomplete="off"/>\
  467. <datalist id="lst" autocomplete="on"></datalist>\
  468. </div>\
  469. <hr/>\
  470. <h3>功能</h3>\
  471. <div id="fn">\
  472. <input id="save" type="button" value="保存" />\
  473. <input id="clear" type="button" value="清空" />\
  474. <input id="view" type="button" value=">>" />\
  475. </div>\
  476. <div id="list">\
  477. <input id="sear" type="text" list="BlackList" placeholder="搜索" autocomplete="off" />\
  478. <ul id="showList"></ul>\
  479. </div>\
  480. <span id="queit">X</span>\
  481. '
  482. document.documentElement.appendChild( pannal );
  483. document.documentElement.appendChild( pannal_mars );
  484. document.body.className = 'blur';
  485. pannal.style.top = ( getSize('clientHeight') - pannal.offsetHeight )/2 + 'px';
  486. pannal.style.left = ( getSize('clientWidth') - pannal.offsetWidth )/2 + 'px';
  487. //初始化
  488. $('blockWay').value = GM_getValue('setting-blockWay','遮罩屏蔽' );//屏蔽方式
  489. $('col').value = GM_getValue('setting-col','#ffffff'); //默认遮罩的颜色
  490. $('opa').value = GM_getValue('setting-opa','0.8'); //默认遮罩透明度
  491. $('opa-text').innerHTML = $('opa').value;
  492. $('gus').value = GM_getValue('setting-gus','3'); //默认遮罩下的高斯模糊半径
  493. $('gus-text').innerHTML = $('gus').value;
  494. createList(); //加载黑名单列表
  495. addEvent($('opa'),'input',function(){
  496. $('opa-text').innerHTML = $('opa').value;
  497. })
  498. addEvent($('gus'),'input',function(){
  499. $('gus-text').innerHTML = $('gus').value;
  500. })
  501. //智能提示userName和userId
  502. addEvent($('userName'),'input',function(){
  503. autoTips();
  504. })
  505. //删除节点模式则禁用选项
  506. addEvent($('blockWay'),'input',function(){
  507. var aInput=[$('col'),$('opa'),$('gus')]
  508. if( $('blockWay').value == '删除节点' ){//删除节点模式
  509. for(var i=0;i<aInput.length;i++){
  510. aInput[i].readOnly = 'true';
  511. aInput[i].className = 'disable-btn';
  512. }
  513. }else{//遮罩屏蔽模式模式
  514. for(var i=0;i<aInput.length;i++){
  515. aInput[i].readOnly = 'false';
  516. aInput[i].className = '';
  517. }
  518. }
  519. })
  520. //====保存按钮====
  521. addEvent($('save'),'click',function(){
  522. //判断屏蔽方式
  523. if($('blockWay').value=='遮罩屏蔽'){
  524. GM_setValue('setting-blockWay','遮罩屏蔽');
  525. }else if($('blockWay').value=='删除节点'){
  526. GM_setValue('setting-blockWay','删除节点');
  527. }
  528. //遮罩颜色
  529. GM_setValue('setting-col',$('col').value);
  530. //遮罩透明度1
  531. GM_setValue('setting-opa',$('opa').value);
  532. //高斯模糊半径
  533. GM_setValue('setting-gus',$('gus').value);
  534. //匹配ID是否正确
  535. var regId=/^[1-9][0-9]{4,}$/ig;
  536. if( $('userName').value!='' && (regId.test($('userId').value)==true || $('userId').value=='') ){
  537. //保存形式:user_name:user_id
  538. GM_setValue( $('userName').value,$('userId').value );
  539. 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') );
  540. }else if( $('userName').value=='' && $('userId').value==''){
  541. 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') )
  542. }else{
  543. alert('输入不正确:\n数字ID:选填([5~n位数])\n贴吧ID:必填')
  544. }
  545. if( parseInt( getStyle($('list'),'width') )>0 ){//如果列表已经展开
  546. createList()//重新生成列表
  547. }
  548. })
  549. //====清空按钮====
  550. addEvent($('clear'),'click',function(){
  551. for(var i=0;i<GM_listValues().length;i++){
  552. //清空所有变量
  553. //GM_deleteValue( GM_listValues()[i] ) + ":" + GM_getValue( GM_listValues()[i],'' )
  554. var value = GM_getValue( GM_listValues()[i],'');
  555. if( (typeof value=='number' && value>1000) || value==''){
  556. GM_deleteValue( GM_listValues()[i] );//删除键名
  557. }
  558. }//for
  559. if( parseInt(getStyle($('list'),'width'))>0 ){//如果列表已经展开
  560. createList();//重新生成列表
  561. }
  562. })
  563. //====展开/收起按钮====
  564. var turn = false;
  565. addEvent($('view'),'click',function(){
  566. if(turn == false){
  567. createList();
  568. //$('showList').style.overflowY = 'scroll';
  569. doMove($('list'),'width',20,200,function(){//展开
  570. doMove($('list'),'height',40,321,function(){
  571. $('sear').focus();
  572. $('view').value = '<<';
  573. turn = true;
  574. });
  575. })
  576. }else if( turn == true ){
  577. //$('showList').style.overflowY = 'hidden';
  578. doMove($('list'),'height',40,20,function(){
  579. doMove($('list'),'width',20,0,function(){//收起
  580. $('view').value = '>>';
  581. turn = false;
  582. });
  583. })
  584. }
  585. })
  586. //黑名单搜索
  587. addEvent($('sear'),'input',function(){
  588. createList();
  589. var list = document.querySelectorAll('#showList .show_list');
  590. $('showList').innerHTML = '';//清空列表
  591. var str = '';
  592. for(var i=0;i<list.length;i++){
  593. var userName = list[i].getAttribute('data');
  594. if( userName.indexOf( $('sear').value ) >=0 ){//如果搜索到
  595. str += '<li class="show_list" data="'+ userName +'">'+'<span class="key">'+userName+'</span>'+'<input class="deletThis" type="button" value="删除"/>'+'</li>';
  596. }
  597. }//for
  598. $('showList').innerHTML = str;//生成列表
  599. //添加点击事件
  600. var aDeleBtn=document.querySelectorAll('.deletThis');
  601. for(var i=0;i<aDeleBtn.length;i++){
  602. aDeleBtn[i].onclick=function(){
  603. var thisKey = this.parentNode.getAttribute('data');//获取当前结点的key
  604. GM_deleteValue( thisKey );//删除变量
  605. this.parentNode.remove( this.parentNode );//删除节点
  606. }//click
  607. }//for
  608. })
  609. //黑名单搜索,backspace键
  610. addEvent(window,'keyup',function(e){
  611. var e= e || window.event;
  612. if(e.keyCode==8){//backspace
  613. if( $('sear').value == '' ){
  614. createList();
  615. }
  616. }
  617. })
  618. //===关闭按钮====
  619. addEvent($('queit'),'click',function(){
  620. closePannal()
  621. })
  622. addEvent($('mars'),'click',function(){
  623. closePannal()
  624. })
  625. }//if
  626. })//addEvent

QingJ © 2025

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