User:Henrik/js/test.js

javascript: function xpathfind(findPattern) { return document.evaluate( findPattern, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null ); }

allLinks = xpathfind("/html/body/div/div/div/div/h3");

for(i=0;i<allLinks.snapshotLength;i++) { var node = allLinks.snapshotItem(i);

var d=document.createElement('div') var b=document.createElement('p'); b.textContent = "bla"; d.appendChild(b); var ta=document.createElement('textarea'); ta.cols=40; ta.rows=5; ta.value=node.textContent; var button=document.createElement('input'); button.type='button'; button.value='Add comment'; d.appendChild(ta); d.appendChild(button);

node = node.nextSibling; while(node.nodeName != "H3") node = node.nextSibling;

allLinks.snapshotItem(i).parentNode.insertBefore(d,node);

}