ランキングをタイトルでフィルターする

ランキングが不愉快だったのでGreasemonkeyかいたヨー。
動画タイトルに対しての正規表現マッチなので汎用性あんまりないヨー。

// ==UserScript==
// @name           shut up PIYO
// @namespace      nico
// @include        http://www.nicovideo.jp/ranking/*
// ==/UserScript==

//config
var keyword = /ぴよぴよ/

//logic

function eval_xpath(rcv, doc, xpath){
  return rcv.evaluate(xpath, doc, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
}

function doc_xpath(xpath){
  return eval_xpath(document, document, xpath);
}

function ary_xpath(xpath){
  var ret = [];
  var a = doc_xpath(xpath);
  for (var i = 0; i < a.snapshotLength; i++){
    ret.push(a.snapshotItem(i));
  }
  return ret;
}

function ancestor(node, i){
  return i==0 ? node : ancestor(node.parentNode, i-1);
}

//main

//div/div/div/table/tbody/tr/td/div/div/h3/a
var a = ary_xpath(&#39;//a[@class="watch"]&#39;);

for (var i = 0; i < a.length; i++){
  if (a[i].text.match(keyword)){
    var div = ancestor(a[i], 9)
    div.parentNode.removeChild(div);
  }
}