// ==UserScript== // @name ニコニコ大百科掲示板NG機能 // @namespace yakisoft // @include /^https?:\/\/dic\.nico(moba|video)\.jp\/[a-z]\/.*$/ // @version 1.9.6 // @grant none // @run-at document-start // @description ニコニコ大百科掲示板NG機能。IDを入力して設定を押せばNGできます。 // @downloadURL none // ==/UserScript== var url = window.location.href; function hide(e, c, r){ var key = c+"_cache"; if(r!==undefined){ if(e[c]!=r){ e[key]=e[c]; e[c]=r; } } else{ if(e[key]!==undefined){ e[c]=e[key]; e[key]=undefined; } } } var doNG; var addNGButton; if(url.indexOf("dic.nicovideo.jp/t/b/a")===-1){//PC or nicomoba var doNGImpl=function doNGImpl(dl, ngList){ var resheads=dl.getElementsByTagName("dt"); var resbodies=dl.getElementsByTagName("dd"); for(var i=0; i dt[class=st-bbs_reshead]'; }; doNG=function doNG(NGList){ console.log("doNG PC or nicomoba"); var ngList=NGList.value.split('\n').filter(function(el) {return el.length !== 0;}); var bbs = document.querySelectorAll('div[class=st-bbs-contents] > dl'); for(var dl=0; dl div[class=st-bbs_resInfo]'); var regex=/ID: (.*)/; dts.forEach(function(e){ e.innerHTML=e.innerHTML.replace(regex, "ID: $1"); var id=e.querySelectorAll('id')[0]; id.onmouseover = function() { id.style.color="red"; id.style.textDecoration = "underline"; }; id.onmouseleave = function() { id.style.color="grey"; id.style.textDecoration = "none"; }; }); var ids=document.querySelectorAll(getSelectorString()+ ' > div > id'); ids.forEach(function(e){ e.onclick=function(){ var ID=e.textContent; if(NGList.value.indexOf(ID)==-1){ NGList.addNGID(ID); } else{ NGList.removeNGID(ID); } doNG(NGList); e.onmouseleave(); }; }); }; } else{//mobile var doNGImpl=function doNGImpl(bbs, ngList){ var posts=bbs.getElementsByTagName("li"); for(var i=0; i