Created
February 16, 2015 04:37
-
-
Save user19/3ce85301827a37ef321f to your computer and use it in GitHub Desktop.
This file contains hidden or 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 xhr(url,callback){ | |
var x = new XMLHttpRequest(); | |
x.onload = function(){ | |
callback(x.response); | |
} | |
x.open('GET',url); | |
x.responseType = 'document'; | |
x.send(); | |
} | |
var sum = 0; | |
var pro = 0; | |
var c = 0; | |
var callback = function(document){ | |
var element = document.getElementById('item-list'); | |
var elements = element.getElementsByClassName('list nozebra')[0].getElementsByTagName('li'); | |
sum += elements.length; | |
for(i=0;i<elements.length;i++) | |
if(elements[i].getElementsByClassName('icon-pro').length) | |
pro++; | |
c++; | |
var next = element.getElementsByClassName('more-blogs more'); | |
if(next.length && c < 1) | |
xhr(next[0].getElementsByTagName('a')[0].href,callback); | |
else | |
alert('はてなブログ:'+(sum-pro)+'\nはてなブログPro:'+pro+'\n総エントリー数:'+sum); | |
} | |
xhr('http://blog.hatena.ne.jp/-/recent',callback); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment