fix input array index
This commit is contained in:
parent
bc6e580c3d
commit
a498743e45
14
code.js
14
code.js
@ -14,7 +14,7 @@ function getData(value) {
|
|||||||
/*
|
/*
|
||||||
* Badge Sctruct:
|
* Badge Sctruct:
|
||||||
* id: int
|
* id: int
|
||||||
* uri: str
|
* url: str
|
||||||
* name: str
|
* name: str
|
||||||
* dropLeft: int
|
* dropLeft: int
|
||||||
*/
|
*/
|
||||||
@ -22,15 +22,15 @@ function getData(value) {
|
|||||||
// check left cards
|
// check left cards
|
||||||
// для карточек, у которых нет параметра 'карточек выпадет'
|
// для карточек, у которых нет параметра 'карточек выпадет'
|
||||||
let cardsDropLeft = 0;
|
let cardsDropLeft = 0;
|
||||||
if (value[1].getElementsByClassName('progress_info_bold').length > 0) {
|
if (value.getElementsByClassName('progress_info_bold').length > 0) {
|
||||||
cardsDropsNumber = value[1].getElementsByClassName('progress_info_bold')[0].innerText.match(/\d/g);
|
cardsDropsNumber = value.getElementsByClassName('progress_info_bold')[0].innerText.match(/\d/g);
|
||||||
if (cardsDropsNumber !== null) { cardsDropLeft = [0]; }
|
if (cardsDropsNumber !== null) { cardsDropLeft = [0]; }
|
||||||
}
|
}
|
||||||
|
|
||||||
let badgeItem = {
|
let badgeItem = {
|
||||||
id: parseInt(value[1].childNodes[1].href.split('/')[6]),
|
id: parseInt(value.childNodes[1].href.split('/')[6]),
|
||||||
uri: value[1].childNodes[1].href,
|
url: value.childNodes[1].href,
|
||||||
name: value[1].getElementsByClassName('badge_title')[0].innerText.trim().replace(/[\r\n\t]/g, ''),
|
name: value.getElementsByClassName('badge_title')[0].innerText.trim().replace(/[\r\n\t]/g, ''),
|
||||||
dropLeft: parseInt(cardsDropLeft),
|
dropLeft: parseInt(cardsDropLeft),
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ function getBadges() {
|
|||||||
const collection = doc.getElementsByClassName('badge_row');
|
const collection = doc.getElementsByClassName('badge_row');
|
||||||
|
|
||||||
for (const value of Object.entries(collection)) {
|
for (const value of Object.entries(collection)) {
|
||||||
badges.push(getData(value));
|
badges.push(getData(value[1]));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => console.warn('Something went wrong.', err));
|
.catch((err) => console.warn('Something went wrong.', err));
|
||||||
|
Loading…
Reference in New Issue
Block a user