jsDoc
This commit is contained in:
parent
5c3ea3162a
commit
53425032c8
48
code.js
48
code.js
@ -1,5 +1,16 @@
|
||||
let badges = [];
|
||||
/**
|
||||
* Скрипт для парсинга значков Steam
|
||||
* @version 0.1.0
|
||||
* @license Unlicense
|
||||
* @author Alexander Popov <iiiypuk@fastmail.fm>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Получает данные из элемента `div.badge_row`
|
||||
* @param {DOM} value - div.badge_row.
|
||||
* @returns {Object}
|
||||
*/
|
||||
function getData(value) {
|
||||
/*
|
||||
* Badge Sctruct:
|
||||
* id: int
|
||||
@ -8,12 +19,8 @@ let badges = [];
|
||||
* dropLeft: int
|
||||
*/
|
||||
|
||||
let collection = document.getElementsByClassName('badge_row');
|
||||
// console.log(collection);
|
||||
// console.log(collection.length);
|
||||
|
||||
for (const [key, value] of Object.entries(collection)) {
|
||||
// check left cards
|
||||
// для металлических карточек нет параметра 'карточек выпадет'
|
||||
let cardsDropLeft = 0;
|
||||
if (value.getElementsByClassName('progress_info_bold')[0]) {
|
||||
let cardsDropLeft = value.getElementsByClassName('progress_info_bold')[0].match(/\d/g);
|
||||
@ -26,10 +33,29 @@ for (const [key, value] of Object.entries(collection)) {
|
||||
dropLeft: cardsDropLeft,
|
||||
};
|
||||
|
||||
badges.push(badgeItem);
|
||||
return badgeItem;
|
||||
}
|
||||
|
||||
// to base64
|
||||
// let encoded = btoa(JSON.stringify(badges));
|
||||
let encoded = JSON.stringify(badges);
|
||||
console.log(encoded);
|
||||
/**
|
||||
* Преобразовывает массив данных в JSON и возвращает к консоль
|
||||
* @param {Array} badgesArray - массив данных о значках.
|
||||
*/
|
||||
function exportJson(badgesArray) {
|
||||
console.log(JSON.stringify(badgesArray));
|
||||
}
|
||||
|
||||
/**
|
||||
* Функция main()
|
||||
*/
|
||||
function getBadges() {
|
||||
let badges = [];
|
||||
const collection = document.getElementsByClassName('badge_row');
|
||||
|
||||
for (const [key, value] of Object.entries(collection)) {
|
||||
badges.push(getData(value));
|
||||
}
|
||||
|
||||
exportJson(badges);
|
||||
}
|
||||
|
||||
getBadges();
|
||||
|
Loading…
Reference in New Issue
Block a user