Created
December 28, 2017 08:05
-
-
Save atomer/4a85072a1f006c03a3321eab2e72a231 to your computer and use it in GitHub Desktop.
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
// http://a.hatena.ne.jp/{user_name}/checklist | |
function getURL(antenaURL) { | |
return new Promise((resolve) => { | |
var xhr = new XMLHttpRequest(); | |
xhr.open('GET', antenaURL); | |
xhr.send(); | |
xhr.addEventListener('readystatechange', (res) => { | |
if (xhr.readyState === 4) { | |
var div = document.createElement('div'); | |
div.innerHTML = xhr.responseText; | |
resolve(div.querySelector('.table-config a').href); | |
} | |
}); | |
}); | |
} | |
function check(url) { | |
var xhr = new XMLHttpRequest(); | |
xhr.open('GET', 'http://a.hatena.ne.jp/check?url=' + encodeURIComponent(url)); | |
xhr.send(); | |
xhr.addEventListener('readystatechange', (res) => { | |
if (xhr.readyState === 4) { | |
console.log('OK! ' + url); | |
} | |
}); | |
} | |
document | |
.querySelectorAll('.line a') | |
.forEach((a) => { | |
getURL(a.href).then((url) => check(url)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment