Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Enlaces entre comentarios en Meneame.net (userscript) (See related posts)

Funciona como el script de anidar pero enlazando a los comentarios


// ==UserScript==
// @name          Meneame.net: enlazar comentarios
// @description   Enlaza comentarios en meneame.net
// @include       http://meneame.net/story/*
// ==/UserScript==
(function() {
var cl = document.getElementById("comments-list"); //cl = lista de comentarios
var l = null; //l = cada elemento hijo de cl
for(var i in cl.childNodes)
{
 l = cl.childNodes.item(i);
 if(l && (l.tagName) && (l.tagName.toUpperCase() == "LI")) //ignora lo que no sean elementos LI
 {
  var d = l.firstChild;
  var nc = parseInt(d.id.slice(8)); //nc = numero de comentario
  var nr = 0; //nr = numero del comentario referenciado
  var o = d.firstChild.nextSibling.nextSibling;
  var t = o.innerHTML;
  var r = t.match(/#[0-9]+/g); //lista de comentarios referenciados
  for(var j in r)
  {
   nr = parseInt(r[j].slice(1));
   if((nr >0) && (nc > nr))
    t = t.replace(r[j],"<a href='" + document.URL.replace(/#comment.*$/g,"") + "#comment-" + nr + "'>" + r[j] +"</a>");
    o.innerHTML = t;
  }
 }
}
})();

You need to create an account or log in to post comments to this site.


Click here to browse all 5141 code snippets

Related Posts