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:
|
* Badge Sctruct:
|
||||||
* id: int
|
* id: int
|
||||||
@ -8,12 +19,8 @@ let badges = [];
|
|||||||
* dropLeft: int
|
* 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
|
// check left cards
|
||||||
|
// для металлических карточек нет параметра 'карточек выпадет'
|
||||||
let cardsDropLeft = 0;
|
let cardsDropLeft = 0;
|
||||||
if (value.getElementsByClassName('progress_info_bold')[0]) {
|
if (value.getElementsByClassName('progress_info_bold')[0]) {
|
||||||
let cardsDropLeft = value.getElementsByClassName('progress_info_bold')[0].match(/\d/g);
|
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,
|
dropLeft: cardsDropLeft,
|
||||||
};
|
};
|
||||||
|
|
||||||
badges.push(badgeItem);
|
return badgeItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
// to base64
|
/**
|
||||||
// let encoded = btoa(JSON.stringify(badges));
|
* Преобразовывает массив данных в JSON и возвращает к консоль
|
||||||
let encoded = JSON.stringify(badges);
|
* @param {Array} badgesArray - массив данных о значках.
|
||||||
console.log(encoded);
|
*/
|
||||||
|
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