voidy21
    anekos
    
    URL 移動時にそのURLが既に開かれていたら、そのタブに移動する
  
>;
// }}}
/*
 * Original version by voidy21:
 *  http://vimperator.g.hatena.ne.jp/voidy21/20100119/1263907211
 *  http://vimperator.g.hatena.ne.jp/voidy21/20100127/1264542669
 */
(function () {
  let U = liberator.plugins.libly.$U;
  function jump (url) {
    let index = 0;
    let url = util.stringToURLArray(url).toString();
    for each ( [,tab] in tabs.browsers ) {
      if(url == tab.currentURI.spec){
        tabs.select(index);
        return true;
      }
      ++index;
    }
    return false;
  }
  "open tabopen edit".split(/\s/).forEach(
    function (name) {
      let command = commands.get(name);
      if (!command)
        return;
      U.around(
        command,
        "action",
        function (next, args) {
          let url = args[0].string;
          if (!(url && jump(url)))
            return next();
        }
      );
    }
  );
  //buffer.followLink()を変更
  //hint-a-hint時[f,F]に対象のタブが既に開いてあったらjump
  let (ignore = false) {
    let ignoreBlock = function (block) {
      ignore = true;
      let result = block();
      ignore = false;
      return result;
    };
    U.around(
      buffer,
      "followLink",
      function (next, args) {
        return ignoreBlock(function () {
          let [elem,] = args;
          let url = elem.href;
          if (!(url && jump(url))){
            liberator.echo("Now Loading... " + url);
            return next();
          }
        });
      }
    );
    document.addEventListener(
      'click',
      function (event) {
        if (ignore)
          return;
        let e = event.target;
        if (e && e.tagName.match(/^a$/i) && e.href && jump(e.href)) {
          event.preventDefault();
          event.stopPropagation();
        }
      },
      true
    );
  }
})();