Created
March 21, 2012 20:55
-
-
Save galonsky/2152774 to your computer and use it in GitHub Desktop.
anderson209 comment counter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function printObject(o) { | |
var out = ''; | |
for (var p in o) { | |
out += p + ': ' + o[p] + '\n'; | |
} | |
alert(out); | |
} | |
var content = document.getElementById('contentArea'); | |
var result = document.evaluate("//div[@class='commentContent UIImageBlock_Content UIImageBlock_SMALL_Content']", | |
content, null, XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null); | |
var map = {}; | |
try { | |
var thisNode = result.iterateNext(); | |
while (thisNode) { | |
var name = thisNode.firstChild.text; | |
if(thisNode.innerHTML.indexOf('anderson209') != -1) { | |
if (!map[name]) { | |
map[name] = 1; | |
} else { | |
map[name] = map[name] + 1; | |
} | |
} | |
thisNode = result.iterateNext(); | |
} | |
printObject(map); | |
} | |
catch(e) { | |
dump('Error: Document tree modified during iteration ' + e); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment