text: ﻿/*
   HatenaBlog SubCategory (c) 2015 Pocket Systems. | psn.hatenablog.jp
   (・ω・) where to go? https://www.youtube.com/watch?v=nbeGeXgjh9Q
  */
  (function(){function k(f){if(!1!==f instanceof Array){for(var c=0;c<f.length;c++)switch(f[c][0]){case "setting":a=f[c][1]}if("undefined"!==typeof a.pattern){console.log("//openSub");switch(a.openSub){case "all":a.openSub="ALLOPEN";break;case "just":a.openSub="JUST";break;default:a.openSub="CLOSE"}console.log("    -> "+a.openSub);console.log("//userCSS");switch(a.userCSS){case !0:a.userCSS=!0;break;default:a.userCSS=!1}console.log("    -> "+a.userCSS);l=new RegExp("^"+a.pattern+"(?:.+) \\(([0-9]+)\\)");
  a.userCSS||(c=document.createElement("link"),c.href="//niyari.github.io/hatenablog-modules/css/hb-subcat.css",c.rel="stylesheet",c.type="text/css",document.getElementsByTagName("head")[0].appendChild(c));f=document.querySelectorAll(".hatena-module-category .hatena-urllist");for(c=0;c<f.length;c++){var h=f[c];if("done"!=h.dataset.categoryProcessed){h.dataset.categoryProcessed="done";for(var e=h.querySelectorAll("li"),g={},d=0;d<e.length;d++){var b=e[d].innerText.match(l);if(null!==b){if("undefined"===
  typeof g[b[1]]){$(e[d]).before('<li class="htnpsne-subcategory js-category-parent js-category-'+b[1]+'"><div class="archive-module-button js-category-toggle" data-category-name="'+b[1]+'"><span class="js-category-parent-hide-button" data-category-name="'+b[1]+'">\u25bc</span><span class="js-category-parent-show-button" data-category-name="'+b[1]+'">\u25b6</span></div><span class="js-category-parent-title js-category-'+b[1]+'" data-parent-category-name="'+b[1]+'">'+b[1]+'</span><ul class="js-category-child js-category-child-'+
  b[1]+'"></ul></li>');var k=h.querySelector("ul .js-category-child-"+b[1]);m(h.querySelector('.js-category-toggle[data-category-name="'+b[1]+'"]'));g[b[1]]={count:0}}g[b[1]].count+=~~b[2];k.appendChild(e[d])}}d=void 0;for(d in g)if(e=h.querySelector('span[data-parent-category-name="'+d+'"]'),e.innerText=d+" ("+g[d].count+")","ALLOPEN"==a.openSub||"JUST"==a.openSub&&1==g[d].count)e.parentElement.dataset.categoryDisplay="block",e.parentElement.classList.add("js-category-child-show")}}}}}function m(a){a.addEventListener("click",
  function(a){"block"==this.parentElement.dataset.categoryDisplay?(this.parentElement.dataset.categoryDisplay="none",this.parentElement.classList.remove("js-category-child-show")):(this.parentElement.dataset.categoryDisplay="block",this.parentElement.classList.add("js-category-child-show"))},!1)}var a,l;"uninitialized"==document.readyState||"loading"==document.readyState?window.addEventListener("DOMContentLoaded",function(){k(Htnpsne.SubCategory.q)},!1):k(Htnpsne.SubCategory.q)})();