TGFC ban troll

让讨厌的苍蝇走开!屏蔽指定用户的主帖和回帖,感谢原作者 taxidriver、jun4rui

当前为 2021-01-06 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name TGFC ban troll
  3. // @namespace http://club.tgfcer.com/20060602
  4. // @version 0.63
  5. // @description 让讨厌的苍蝇走开!屏蔽指定用户的主帖和回帖,感谢原作者 taxidriver、jun4rui
  6. // @author 20060602
  7. // @supportURL housekeeper1997@gmail.com
  8. // @include http://*.tgfcer.com/*
  9. // @include http://*.tgfcer.net/*
  10. // @include https://*.tgfcer.com/*
  11. // @include https://*.tgfcer.net/*
  12. // @grant none
  13. // ==/UserScript==
  14.  
  15. // console.log('Hello Tgfcer from "tgfc-ban-troll.js".');
  16.  
  17. // global datas for storage
  18. var BanList, BanListArray, ShowBanTip, checked, BanTip, BanNegJisao, JisaoMin;
  19.  
  20. // URL prefixes
  21. var wapURLPrefix1 = 'http://club.tgfcer.com/wap/';
  22. var wapURLPrefix2 = 'http://wap.tgfcer.com/';
  23. var wapURLPrefix3 = 'http://club.tgfcer.net/wap/';
  24. var wapURLPrefix4 = 'http://wap.tgfcer.net/';
  25. var wapURLPrefix5 = 'https://club.tgfcer.com/wap/';
  26. var wapURLPrefix6 = 'https://wap.tgfcer.com/';
  27. var wapURLPrefix7 = 'https://club.tgfcer.net/wap/';
  28. var wapURLPrefix8 = 'https://wap.tgfcer.net/';
  29.  
  30. var wapURLPrefix9 = 'http://s.tgfcer.com/wap/';
  31. var wapURLPrefix10 = 'https://s.tgfcer.com/wap/';
  32. var wapURLPrefix11 = 'http://s.tgfcer.net/wap/';
  33. var wapURLPrefix12 = 'https://s.tgfcer.net/wap/';
  34.  
  35. var webURLPrefix = 'http://club.tgfcer.com/';
  36. var webURLPrefixNet = 'http://club.tgfcer.net/';
  37. var webURLPrefixS = 'https://club.tgfcer.com/';
  38. var webURLPrefixNetS = 'https://club.tgfcer.net/';
  39.  
  40. var webURLPrefixBbs = 'http://bbs.tgfcer.com/';
  41. var webURLPrefixBbsNet = 'http://bbs.tgfcer.net/';
  42. var webURLPrefixBbsS = 'https://bbs.tgfcer.com/';
  43. var webURLPrefixBbsNetS = 'https://bbs.tgfcer.net/';
  44.  
  45. var webWaterURLPrefix = 'http://s.tgfcer.com/';
  46. var webWaterURLPrefixNet = 'http://s.tgfcer.net/';
  47. var webWaterURLPrefixS = 'https://s.tgfcer.com/';
  48. var webWaterURLPrefixNetS = 'https://s.tgfcer.net/';
  49.  
  50. // console.log('The Begin of logic.');
  51.  
  52. Array.prototype.contains = contains;
  53. loadData();
  54. //console.log('Data loaded.');
  55. if (underURL(wapURLPrefix1,
  56. wapURLPrefix2,
  57. wapURLPrefix3,
  58. wapURLPrefix4,
  59. wapURLPrefix5,
  60. wapURLPrefix6,
  61. wapURLPrefix7,
  62. wapURLPrefix8,
  63. wapURLPrefix9,
  64. wapURLPrefix10,
  65. wapURLPrefix11,
  66. wapURLPrefix12)){
  67. processWap();
  68. }else if (underURL(webURLPrefix,
  69. webURLPrefixNet,
  70. webURLPrefixS,
  71. webURLPrefixNetS,
  72. webWaterURLPrefix,
  73. webWaterURLPrefixNet,
  74. webWaterURLPrefixS,
  75. webWaterURLPrefixNetS,
  76. webURLPrefixBbs,
  77. webURLPrefixBbsNet,
  78. webURLPrefixBbsS,
  79. webURLPrefixBbsNetS)){
  80. // console.log('gonna execute processWeb.');
  81. processWeb();
  82. }
  83.  
  84. //console.log('The End of logic.');
  85.  
  86.  
  87. function initLocalStorage(name, defaultValue){
  88. if (typeof(localStorage[name])==='undefined'){
  89. localStorage[name] = defaultValue;
  90. // console.log(name + ' initialed with:' + defaultValue);
  91. }
  92. }
  93.  
  94. function loadData(){
  95. //先判断有没有localStorage保存的设置数据,没有则新建
  96. initLocalStorage('BanList', '');
  97. initLocalStorage('ShowBanTip', true);
  98. initLocalStorage('BanTip', 'Blocked!!!!!');
  99.  
  100. initLocalStorage('BanNegJisao', false);
  101. initLocalStorage('JisaoMin', 0);
  102.  
  103. BanList = localStorage.BanList;
  104. BanListArray = BanList.split(',');
  105. ShowBanTip = localStorage.ShowBanTip === 'true';
  106. checked = ShowBanTip ? "checked" : "";
  107. BanTip = localStorage.BanTip;
  108. BanNegJisao = localStorage.BanNegJisao === 'true';
  109. JisaoMin = parseInt(localStorage.JisaoMin);
  110.  
  111. //console.log(localStorage);
  112. }
  113.  
  114. function saveData(banList,showTip, banTip, banNegJisao, jisaoMin){
  115. BanList = banList;
  116. ShowBanTip = showTip;
  117. BanListArray = BanList.split(',');
  118. localStorage.BanList = BanList;
  119. localStorage.ShowBanTip = ShowBanTip;
  120. localStorage.BanTip = banTip;
  121.  
  122. if( banNegJisao !== undefined){
  123. localStorage.BanNegJisao = banNegJisao;
  124. }
  125.  
  126. if( jisaoMin !== undefined){
  127. localStorage.JisaoMin = jisaoMin;
  128. }
  129.  
  130. BanTip = localStorage.BanTip;
  131. }
  132.  
  133.  
  134. function processWap(){
  135. //不让图片尺寸超过屏幕的最大宽度,有时候图片太大了看起来好累
  136. addGlobalStyle('div.message>img {max-width:100%;}');
  137. //让顶部导航栏浮动固定
  138. addGlobalStyle('#scroller>.navbar {position:fixed;height:28px;line-height:28px;width:100%;top:0;left:0;box-shadow: 5px 1px 5px #888888;} body {padding-top:36px;}');
  139. addGlobalStyle('#scroller>.navigation {position:fixed;height:28px;line-height:28px;width:100%;top:0;left:0;box-shadow: 5px 1px 5px #888888;} body {padding-top:36px;}');
  140.  
  141. addWapLink();
  142.  
  143. //在原生导航栏中加入设置模块
  144. //console.log($('a[href="#bottom"]').parent().parent());
  145. var hookPoint = $('div.navbar');
  146. if(hookPoint.length === 0) {
  147. hookPoint = $('a[href="#bottom"]').parent().parent();
  148. hookPoint.append('<li><a href="#" class="nav_link" id="tgbs-btn" title="让TGFCER更美好的设置,由 taxidriver、jun4rui 两位坛友原创">TGGM</a></li>');
  149. }else{
  150. hookPoint.append('&nbsp;|&nbsp;<a href="#" class="nav_link" id="tgbs-btn" title="让TGFCER更美好的设置,由 taxidriver、jun4rui 两位坛友原创">TGGM</a>');
  151. }
  152. //$('div.navbar').append('&nbsp;|&nbsp;<a href="#" class="nav_link" id="tgbs-btn" title="让TGFCER更美好的设置,由 taxidriver、jun4rui 两位坛友原创">TGGM</a>');
  153. //$('a[href=#bottom]').parent().after('<li><a href="#" class="nav_link" id="tgbs-btn" title="让TGFCER更美好的设置,由 taxidriver、jun4rui 两位坛友原创">TGGM</a></li>');
  154. //$('div.navigation').append('&nbsp;|&nbsp;<a href="#" class="nav_link" id="tgbs-btn" title="让TGFCER更美好的设置,由 taxidriver、jun4rui 两位坛友原创">TGGM</a>');
  155. //点击模块的处理
  156. $('#scroller').delegate('#tgbs-btn', 'click', function(){
  157. if ($('#tgbs').css('display')=='none'){
  158. loadData();
  159. $('#tgbs').css({'display':''});
  160. $('#tgbs').css('top',$('#tgbs-btn').position().top+20);
  161. $('#tgbs').css('left',2);
  162. $('#tgbs textarea').focus();
  163. $('#ban-tip').val(BanTip);
  164. //添加"加入到ban"按钮
  165. $('#scroller .infobar').each(function(){
  166. $(this).find('a').eq(1).after('<button class="add-to-ban" value="'+$(this).find('a').eq(1).text()+'">+屏蔽</button>');
  167. });
  168. }else{
  169. //关闭设置菜单时,清除所有"加入到ban"按钮并关闭设置面板
  170. $('.add-to-ban').remove();
  171. $('#tgbs').css({'display':'none'});
  172. // 保存数据到localStorage
  173. localStorage.BanList = $('#banlist-textarea').val();
  174. localStorage.ShowBanTip = document.getElementById("showBanTip").checked;
  175. localStorage.BanTip = $('#ban-tip').val();
  176. BanList = localStorage.BanList;
  177. BanListArray = BanList.split(',');
  178. ShowBanTip = localStorage.ShowBanTip === 'true';
  179. checked = ShowBanTip ? "checked" : "";
  180. BanTip = $('#ban-tip').val();
  181. }
  182. });
  183. //处理点击'.add-to-ban'按钮
  184. $('.infobar').delegate('.add-to-ban', 'click', function(){
  185. $('#banlist-textarea').val($('#banlist-textarea').val()+','+$(this).attr('value'));
  186. });
  187. //在原生导航栏下面加入设置表单
  188. //$('div.navbar')
  189. hookPoint.append('<div id="tgbs" class="list_item_top" style="z-index: 9500;color:#FFF; width:400px;padding:.5em;position:fixed; display:none; overflow:hidden;box-shadow: rgb(51, 51, 51) 1px 1px 19px;background-color: #436193;">屏蔽ID列表:'
  190. + '<br/><textarea id=\"banlist-textarea\" style="width:100%;height:160px;">'+BanList+'</textarea>'
  191. +'<form><input id="showBanTip" type="checkbox" name="showBanTip" '+checked+' />显示屏蔽提示&nbsp;|&nbsp;'
  192. +'提示信息&nbsp;<input id="ban-tip" style="font-size : 1em; padding : 0px; margin : 0px; margin-top: 5px; width : 200px;"/></form></div>');
  193.  
  194. //点击屏蔽区将展开屏蔽内容
  195. $('#scroller').delegate('.list-ban-section', 'click', function(){
  196. if ($(this).css('height')=='21px'){
  197. $(this).css({'height':'auto'});
  198. }else{
  199. $(this).css({'height':'21px'});
  200. }
  201. });
  202.  
  203. //列表页面
  204. var ForumPagePart = 'index.php?action=forum';
  205. //帖子内文页面
  206. var ThreadPagePart = 'index.php?action=thread';
  207.  
  208. //如果当前页面是列表页面的处理
  209. if (hasURLPart(ForumPagePart)){
  210. //console.log('当前在列表页面');
  211. $('.dTitle').each(function(){
  212. var author = $(this).find('span.author').text();
  213. for (var i in BanListArray){
  214. //判断发帖人是否在屏蔽列表中
  215. if (author.indexOf(BanListArray[i])==1){
  216. //console.log(BanListArray[i]);
  217. if(!ShowBanTip){
  218. $(this).css({display:'none'});
  219. continue;
  220. }
  221. //console.log(author.indexOf(BanListArray[i]),BanListArray[i]);
  222. $(this).addClass('list-ban-section');
  223. $(this).prepend('<div style="width:auto;text-align:center;border:1px dashed #AAAAAA;color:#AAAAAA; line-height:19px;"><strong><s> '+BanListArray[i]+' </s></strong>'+BanTip+'</div>');
  224. $(this).css({'height':'21px','overflow':'hidden'});
  225. }
  226. }
  227. });
  228. }
  229.  
  230.  
  231. $('#scroller').delegate('.info-ban-section', 'click', function(){
  232. if ($(this).next().css('display')=='none'){
  233. $(this).next().css({'display':'inherit'});
  234. $(this).next().next().css({'display':'inherit'});
  235. $(this).next().next().next().css({'display':'inherit'});
  236. $(this).next().next().next().next().css({'display':'inherit'});
  237. $(this).next().next().next().next().next().css({'display':'inherit'});
  238. }else{
  239. $(this).next().css({'display':'none'});
  240. $(this).next().next().css({'display':'none'});
  241. $(this).next().next().next().css({'display':'none'});
  242. $(this).next().next().next().next().css({'display':'none'});
  243. $(this).next().next().next().next().next().css({'display':'none'});
  244. }
  245. });
  246.  
  247. //如果当前页面是内容页的处理
  248. if (hasURLPart(ThreadPagePart)){
  249. markJiSao();
  250. $('.infobar').each(function(){
  251. var author = $(this).find('a').eq(1).text();
  252. for (var i in BanListArray){
  253. //判断发帖人是否在屏蔽列表中
  254. if (author==BanListArray[i]){
  255. console.log(author.indexOf(BanListArray[i]),BanListArray[i]);
  256. $(this).css({'display':'none'});
  257. if(ShowBanTip){
  258. $(this).before('<div class="info-ban-section" style="cursor:pointer;width:auto;text-align:center;border:1px dashed #DEDEDE;color:#DEDEDE; line-height:19px;"><strong><s>'+BanListArray[i]+'</s></strong>'+BanTip+'</div>');
  259. }
  260. //$(this).addClass('ban-section');
  261. //依次连续隐藏5个(含自己)元素
  262. $(this).next().css({'display':'none'});
  263. $(this).next().next().css({'display':'none'});
  264. $(this).next().next().next().css({'display':'none'});
  265. $(this).next().next().next().next().css({'display':'none'});
  266. }
  267. }
  268. });
  269. }
  270. }
  271.  
  272. function processWeb(){
  273. console.log('processWeb begin');
  274. // 调整 “最后发表” 列的宽度,避免部分较长的 ID 导致此栏换行
  275. addGlobalStyle('.threadlist td.lastpost {width:160px;}');
  276.  
  277.  
  278. closeLeftAdv();
  279. console.log('processWeb end');
  280. jisaoEditable();
  281.  
  282. //在原生导航栏中加入设置模块
  283. var newSpan = document.createElement('span');
  284. newSpan.innerHTML = '<a href="#" class="nav_link" id="tgbs-btn" title="让TGFCER更美好的设置,由 taxidriver、jun4rui 两位坛友原创">TGGM</a>&nbsp;|&nbsp;';
  285. // console.log(newSpan);
  286. var hookPoint = document.getElementById('my').parentNode.parentNode;
  287. // console.log(hookPoint);
  288. hookPoint.appendChild(newSpan);
  289. // console.log(navP);
  290. var btn = document.getElementById('tgbs-btn');
  291. // console.log(btn);
  292.  
  293.  
  294. var floatDiv = createFloatDiv();
  295. newSpan.appendChild(floatDiv);
  296.  
  297. var banlistTextarea = document.getElementById('ban-list');
  298. var showCheckbox = document.getElementById('show-ban-info');
  299. var banTip = document.getElementById('ban-tip');
  300.  
  301. var banNegJisaoCheckbox = document.getElementById('ban-neg-jisao');
  302. var jisaoMin = document.getElementById('jisao-min');
  303.  
  304. //console.log(floatDiv);
  305.  
  306. btn.onclick = function (){
  307. // console.log('showCheckbox.checked:' + showCheckbox.checked + ' ShowBanTip:' + ShowBanTip);
  308. if(floatDiv.style.display==='none'){
  309. loadData();
  310. floatDiv.style.display='';
  311. floatDiv.style.top = getElementTop(newSpan) + 20 + 'px';
  312. floatDiv.style.left = getElementLeft(newSpan) - 365 +'px';
  313. showCheckbox.checked = ShowBanTip;
  314. banlistTextarea.value = BanList;
  315. banlistTextarea.focus();
  316. }else{
  317. floatDiv.style.display='none';
  318. saveData(banlistTextarea.value, showCheckbox.checked, banTip.value, banNegJisaoCheckbox.checked, jisaoMin.value);
  319. }
  320. };
  321.  
  322. filterBlackList(
  323. function(){return document.getElementsByTagName('tbody');},
  324. 2,
  325. function (author, reason){
  326. return '<tr><td style="background-color:#e5e5e5" class="folder"></td><td style="background-color:#e5e5e5" class="icon"></td><th class=""><label></label><span><s>' +
  327. author +
  328. '</s> '+ BanTip +
  329. reason +
  330. '</span></th><td style="background-color:#e5e5e5;text-align:center" class="author"></td><td class="nums"></td><td style="background-color:#e5e5e5" class="lastpost"></td></tr>';
  331. },
  332. '<tr><td style="background-color:#e5e5e5" class="folder"></td><td style="background-color:#e5e5e5" class="icon"></td><th class=""><label></label><span><s>',
  333. '</s> '+BanTip+'</span></th><td style="background-color:#e5e5e5;text-align:center" class="author"></td><td class="nums"></td><td style="background-color:#e5e5e5" class="lastpost"></td></tr>'
  334. );
  335.  
  336. filterBlackList(
  337. function(){return document.getElementsByClassName('viewthread');},
  338. 1,
  339. function (author, reason){
  340. return '<div class="mainbox viewthread"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="postauthor"></td><td class="postcontent"><s>' +
  341. author +
  342. '</s> '+ BanTip +
  343. reason +
  344. '</td></tr></tbody></table></div>';
  345. },
  346. '<div class="mainbox viewthread"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="postauthor"></td><td class="postcontent"><s>',
  347. '</s> '+BanTip+'</td></tr></tbody></table></div>'
  348. );
  349.  
  350. }
  351.  
  352. //添加全局CSS样式的方法
  353. function addGlobalStyle(css) {
  354. var head, style;
  355. head = document.getElementsByTagName('head')[0];
  356. if (!head) { return; }
  357. style = document.createElement('style');
  358. style.type = 'text/css';
  359. style.innerHTML = css;
  360. head.appendChild(style);
  361. }
  362.  
  363. function markJiSao(){
  364. //正激骚
  365. addGlobalStyle('a.positive-sao {color:#f00;}');
  366. //负激骚
  367. addGlobalStyle('a.negative-sao {color:#00bb00;}');
  368.  
  369. var regex = /^骚\((-?\d+)\)$/g;
  370. $('a').each(function(){
  371. var atag = $(this);
  372. var match = regex.exec(atag.text());
  373. if(match && match[1] != '0'){
  374. //console.log(match[1]);
  375. if(match[1].indexOf('-')===0){
  376. atag.addClass("negative-sao");
  377. }else{
  378. atag.addClass("positive-sao");
  379. }
  380. }
  381. });
  382. }
  383.  
  384.  
  385. function addWapLink(){
  386. var webLink = /^http:\/\/club\.tgfcer\.com\/thread-([\d]+)-.+html/ig;
  387. var webLinkNet = /^http:\/\/club\.tgfcer\.net\/thread-([\d]+)-.+html/ig;
  388. var tidStr = 'http://wap.tgfcer.com/index.php?action=thread&tid=TidDummy&sid=&vt=1&tp=100&pp=100&sc=0&vf=0&sm=0&iam=&css=&verify=&fontsize=0';
  389. var tidStrNet = 'http://club.tgfcer.net/wap/index.php?action=thread&tid=TidDummy&sid=&vt=1&tp=100&pp=100&sc=0&vf=0&sm=0&iam=&css=&verify=&fontsize=0';
  390.  
  391. var webLinkS = /^https:\/\/club\.tgfcer\.com\/thread-([\d]+)-.+html/ig;
  392. var webLinkNetS = /^https:\/\/club\.tgfcer\.net\/thread-([\d]+)-.+html/ig;
  393. var tidStrS = 'https://wap.tgfcer.com/index.php?action=thread&tid=TidDummy&sid=&vt=1&tp=100&pp=100&sc=0&vf=0&sm=0&iam=&css=&verify=&fontsize=0';
  394. var tidStrNetS = 'https://club.tgfcer.net/wap/index.php?action=thread&tid=TidDummy&sid=&vt=1&tp=100&pp=100&sc=0&vf=0&sm=0&iam=&css=&verify=&fontsize=0';
  395.  
  396. var tags = document.getElementsByTagName('a');
  397. for(var i=0; i<tags.length; ++i){
  398. var tag = tags[i];
  399. tryConvert(tag, webLink, tidStr);
  400. tryConvert(tag, webLinkNet, tidStrNet);
  401.  
  402. tryConvert(tag, webLinkS, tidStrS);
  403. tryConvert(tag, webLinkNetS, tidStrNetS);
  404. continue;
  405. var href = tag.href;
  406. var execResult = webLink.exec(href);
  407. if(execResult){
  408. var threadId = execResult[1];
  409. var wapLink = tidStr.replace('TidDummy',threadId);
  410. //console.log(wapLink);
  411. var newSpan = document.createElement('span');
  412. newSpan.innerHTML = '&nbsp;&nbsp;<a href="'+wapLink+'" title="">(wap点我)</a>&nbsp;';
  413. tag.parentNode.insertBefore(newSpan ,tag.nextSibling);
  414. }
  415. }
  416. }
  417.  
  418. function tryConvert(aTag, regex, targetPattern){
  419. var href = aTag.href;
  420. var execResult = regex.exec(href);
  421. if(execResult){
  422. var threadId = execResult[1];
  423. var wapLink = targetPattern.replace('TidDummy',threadId);
  424. //console.log(wapLink);
  425. var newSpan = document.createElement('span');
  426. newSpan.innerHTML = '&nbsp;&nbsp;<a href="'+wapLink+'" title="">(wap点我)</a>&nbsp;';
  427. aTag.parentNode.insertBefore(newSpan ,aTag.nextSibling);
  428. }
  429. }
  430.  
  431. function getElementTop(element){
  432. var actualTop = element.offsetTop;
  433. var current = element.offsetParent;
  434. while (current !== null){
  435. actualTop += current.offsetTop;
  436. current = current.offsetParent;
  437. }
  438. return actualTop;
  439. }
  440.  
  441. function getElementLeft(element){
  442. var actualLeft = element.offsetLeft;
  443. var current = element.offsetParent;
  444. while (current !== null){
  445. actualLeft += current.offsetLeft;
  446. current = current.offsetParent;
  447. }
  448. return actualLeft;
  449. }
  450.  
  451. function createFloatDiv(){
  452. var floatDiv = document.createElement('div');
  453. floatDiv.setAttribute('id', 'tgbs');
  454. floatDiv.setAttribute('style', 'color:#FFF; width:400px;padding:.5em;position:fixed; display:none; overflow:hidden;box-shadow: rgb(51, 51, 51) 1px 1px 19px;background-color: #00b23d;text-align:left;');
  455. var titleText = document.createElement('div');
  456. titleText.innerHTML = '屏蔽ID列表:';
  457. floatDiv.appendChild(titleText);
  458. var banlistTextarea = document.createElement('textarea');
  459. banlistTextarea.setAttribute('id', 'ban-list');
  460. banlistTextarea.style.width = '99%';
  461. banlistTextarea.style.height = '160px';
  462. banlistTextarea.style.marginBottom = '4px';
  463. floatDiv.appendChild(banlistTextarea);
  464.  
  465.  
  466. var form = document.createElement('form');
  467. floatDiv.appendChild(form);
  468. var showCheckbox = document.createElement('input');
  469. form.appendChild(showCheckbox);
  470. showCheckbox.setAttribute('type','checkbox');
  471. showCheckbox.setAttribute('id', 'show-ban-info');
  472. showCheckbox.checked = ShowBanTip;
  473.  
  474. var checkText = document.createElement('span');
  475. checkText.innerHTML = '显示屏蔽提示&nbsp;&nbsp;|&nbsp;&nbsp;提示信息&nbsp;';
  476. form.appendChild(checkText);
  477.  
  478. var banTip = document.createElement('input');
  479. form.appendChild(banTip);
  480. banTip.setAttribute('type','text');
  481. banTip.setAttribute('id', 'ban-tip');
  482. banTip.style.fontSize = '1em';
  483. banTip.style.padding = '0px 5px';
  484. banTip.style.margin = '0px';
  485. banTip.style.width = '200px';
  486. // banTip.style.color = '#cc0000';
  487. banTip.value = BanTip;
  488.  
  489. var lineBreak = document.createElement('hr');
  490. form.appendChild(lineBreak);
  491.  
  492. showCheckbox = document.createElement('input');
  493. form.appendChild(showCheckbox);
  494. showCheckbox.setAttribute('type','checkbox');
  495. showCheckbox.setAttribute('id', 'ban-neg-jisao');
  496. showCheckbox.checked = BanNegJisao;
  497.  
  498. var checkTextBanNegJiSao = document.createElement('span');
  499. checkTextBanNegJiSao.innerHTML = '屏蔽,如果该用户激骚小于&nbsp;';
  500. form.appendChild(checkTextBanNegJiSao);
  501.  
  502. banTip = document.createElement('input');
  503. form.appendChild(banTip);
  504. banTip.setAttribute('type','number');
  505. banTip.setAttribute('id', 'jisao-min');
  506. banTip.style.fontSize = '1em';
  507. banTip.style.padding = '0px 5px';
  508. banTip.style.margin = '0px';
  509. banTip.style.width = '112px';
  510. // banTip.style.color = '#cc0000';
  511. banTip.value = JisaoMin;
  512.  
  513. lineBreak = document.createElement('hr');
  514. form.appendChild(lineBreak);
  515.  
  516. var btnJisaoEdit = document.createElement('BUTTON');
  517. var t = document.createTextNode('让“激骚理由”可编辑'); // Create a text node
  518. btnJisaoEdit.appendChild(t); // Append the text to <button>
  519. form.appendChild(btnJisaoEdit);
  520. btnJisaoEdit.onclick = jisaoEditable;
  521.  
  522.  
  523. return floatDiv;
  524. }
  525.  
  526. function jisaoNoPM(event){
  527. var taReason = document.getElementsByName('sendreasonpm');
  528. //console.log(taReason);
  529. if(taReason){
  530. for (var i = 0, len = taReason.length; i < len; i++) {
  531. var ta = taReason[i];
  532. ta.removeAttribute('disabled');
  533. }
  534. }
  535.  
  536. //event.preventDefault();
  537. return false;
  538. }
  539.  
  540. function jisaoEditable(event){
  541. var taReason = document.getElementsByName('reason');
  542. //console.log(taReason);
  543. if(taReason){
  544. for (var i = 0, len = taReason.length; i < len; i++) {
  545. var ta = taReason[i];
  546. ta.removeAttribute('readonly');
  547. }
  548. }
  549.  
  550. jisaoNoPM();
  551.  
  552. return false;
  553. }
  554.  
  555. function banReason(node, cite, author){
  556. if(cite[0].getElementsByTagName('a')[0] == null){
  557. return null;
  558. }
  559.  
  560. author = cite[0].getElementsByTagName('a')[0].innerHTML;
  561. if (BanListArray.contains(author)){
  562. return '';
  563. }
  564.  
  565. if(BanNegJisao){
  566. var dl = node.getElementsByTagName('dl');
  567. if(dl){
  568. dl = dl[0];
  569. var dds = dl.getElementsByTagName('dd');
  570. var jisaoText = dds[3].innerText;
  571. var jisao = parseInt(jisaoText);
  572. // console.log(jisao);
  573. if(jisao < JisaoMin){
  574. return ' 激骚值:' + jisao;
  575. }
  576. }
  577. }
  578.  
  579. return null;
  580. }
  581.  
  582. function filterBlackList(nodeFunc, citeCount, tipFunc, preT, postT){
  583. var allTextareas,cite, author;
  584. allTextareas = nodeFunc();
  585. // console.log(allTextareas.length);
  586. if (!allTextareas.length) {
  587. return;
  588. }
  589.  
  590. for (var index = 0; index < allTextareas.length; index++) {
  591. var node = allTextareas[index];
  592. cite = node.getElementsByTagName('cite');
  593. if (cite.length < citeCount){
  594. continue;
  595. }
  596.  
  597. author = cite[0].getElementsByTagName('a')[0].innerHTML;
  598. //console.log(author);
  599. var reason = banReason(node, cite, author);
  600. if (reason !== null) {
  601. // console.log("kill " + author);
  602. // console.log("ShowBanTip("+typeof(ShowBanTip)+") " + ShowBanTip);
  603. if(ShowBanTip){
  604. node.innerHTML = tipFunc(author, reason);
  605. }
  606. else{
  607. node.style.display = 'none';
  608. }
  609. }
  610.  
  611. }
  612. }
  613.  
  614. function underURL(){
  615. //console.log('underURL begin')
  616. var PageCurrent = window.location.href;
  617.  
  618. var result = false;
  619. for (var i = 0; i < arguments.length; i++) {
  620. var prefix = arguments[i];
  621. if(PageCurrent.indexOf(prefix)===0){
  622. result = true;
  623. break;
  624. //return true;
  625. }
  626. }
  627.  
  628. //console.log('underURL returned with: ' + result);
  629. return result;
  630. }
  631.  
  632. function hasURLPart(part){
  633. var PageCurrent = window.location.href;
  634. return PageCurrent.indexOf(part) >= 0;
  635. }
  636.  
  637. function contains(obj) {
  638. var index = this.length;
  639. while (index--) {
  640. if (this[index] === obj) {
  641. return true;
  642. }
  643. }
  644. return false;
  645. }
  646.  
  647.  
  648. function closeLeftAdv(){
  649. if (true){
  650. return;
  651. }
  652. console.log('closeLeftAdv begin');
  653. writeCookie('leftadv1','1',700);
  654. document.getElementById('leftadv').style.display='none';
  655. document.getElementById('content_main').style.margin='0 0 0 0';
  656. console.log('closeLeftAdv end');
  657. }