定番の処理: $X('XPath', node).forEach(function(e) { hogehoge; });
$X('id("files")//div[@class="info"]/span').forEach(function(e) { var filename = e.innerHTML; if (/\.user\.js$/.test(filename)) { var link = $X('parent::div/following-sibling::div[@class="actions"]/a', e)[0]; if (link) { var el = link.cloneNode(true); el.href += '?' + filename; el.innerHTML = filename; e.parentNode.replaceChild(el,e); } } });http://gist.github.com/1952
$x('//li[@class="song"]').forEach(function(e) { var hex = e.id.replace(/song/, ''); var song_url = muxtape.ladles['player' + hex].song_url; var a = document.createElement('a'); a.innerHTML = ICON; a.href = song_url; e.appendChild(a); });http://d.hatena.ne.jp/taizooo/20080331/1206960337