Disable HATENA keyword

By Shinya Last update Sep 17, 2007 — Installed 206 times. Daily Installs: 0, 0, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0
// ==UserScript==
// @name           Disable HATENA keyword
// @description    Disables HATENA keyword anchers. Ancher nodes will be replaced with span nodes.
// @version        1.0.2
// @author         Shinya
// @namespace      http://www.code-404.net/
// @homepage       http://userscripts.org/scripts/show/11328
// @include        http://d.hatena.ne.jp/*
// @include        http://*g.hatena.ne.jp/*
// @exclude        http://d.hatena.ne.jp/keyword*
// @exclude        http://*g.hatena.ne.jp/keyword*
// @Note           Supported 'AutoPagerize 0.0.12'.
// ==/UserScript==

/*== Copyright by Original Script ==============*/
// Copyright (C) 2005, temp_h.
// Released under the GPL license
// http://www.gnu.org/copyleft/gpl.html

//
// Therefore, the license of this script is under the GPL, too.
//

(function(){
  disableHatenaKeywords();
  
  addFilter(function(elm){
    disableHatenaKeywords(elm[0]);
  });
  
  function disableHatenaKeywords(elm){
    var element = elm || document;
    var kwNodes = document.evaluate(
      '(/descendant::A[attribute::class = "keyword"]|/descendant::A[attribute::class = "okeyword"])',
      element, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null
    );
    for(var i = 0; i < kwNodes.snapshotLength; i++){
      var n = kwNodes.snapshotItem(i);
      var r = document.createElement("span");
      r.className = "keyword";
      for(var j = 0; j < n.childNodes.length; j++)
        r.appendChild(n.childNodes[j].cloneNode(true));
      n.parentNode.replaceChild(r, n);
    }
  }
  
  // For Autopagerize 0.0.12
  function addFilter(filter, i) {
    i = i || 4;
    if(window.AutoPagerize && window.AutoPagerize.addFilter){
      window.AutoPagerize.addFilter(filter);
    }
    else if(i > 1){
      setTimeout(arguments.callee, 1000, filter, i - 1);
    }
  }
})();