Skip to content

Instantly share code, notes, and snippets.

@atomer
Created December 28, 2017 08:05
Show Gist options
  • Save atomer/4a85072a1f006c03a3321eab2e72a231 to your computer and use it in GitHub Desktop.
Save atomer/4a85072a1f006c03a3321eab2e72a231 to your computer and use it in GitHub Desktop.
// 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