/*
* @title Let2JSON
* @description レッツラJSON
* @include http://let.hatelabo.jp/*
* @license MIT License
* @require
* @private
*/
(function(){
if( /^http:\/\/let\.hatelabo\.jp\/.*\/let\/.*/.test(location.href)) return;
var clist = document.querySelectorAll('div.codelist');
var jsondata = {
'users': []
};
var user, codepath, userIcon, description, packedSource;
for (var i = 0; i < clist.length; i++) {
if (clist[i].style.display !== 'none') { //* //let.hatelabo.jp/a-kuma3/let/hJme3Kz9g6Zc 対応 */
user = getAttr(clist[i], 'img.profile-image', 'alt');
userIcon = getAttr(clist[i], 'img.profile-image', 'src');
description = clist[i].querySelector('p.description').textContent;
packedSource = clist[i].querySelector('pre')
? clist[i].querySelector('pre').textContent
: 'none';
jsondata.users.push({
'user': user,
'user_icon': userIcon,
'description': description,
'packed_source': packedSource
});
}
}
var jsonText = JSON.stringify(jsondata);
window.open('data\:text\/plain;charset=utf8,' + encodeURIComponent(jsonText));
/* to SAVE Local Storage JSON
/ for Check http://jsonlint.com/
*/
//localStorage.setItem('Hatea::let::JSON::data', JSON.stringify(jsondata));
function getAttr(target, sel, attr) {
result = target.querySelector(sel).getAttribute(attr);
return result;
}
})();