From a498743e451bd61d86f0fe293243dd9bdf8286e4 Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Wed, 4 Jan 2023 23:24:03 +0300 Subject: [PATCH] fix input array index --- code.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/code.js b/code.js index 2b4d277..f122427 100644 --- a/code.js +++ b/code.js @@ -14,7 +14,7 @@ function getData(value) { /* * Badge Sctruct: * id: int - * uri: str + * url: str * name: str * dropLeft: int */ @@ -22,15 +22,15 @@ function getData(value) { // check left cards // для карточек, у которых нет параметра 'карточек выпадет' let cardsDropLeft = 0; - if (value[1].getElementsByClassName('progress_info_bold').length > 0) { - cardsDropsNumber = value[1].getElementsByClassName('progress_info_bold')[0].innerText.match(/\d/g); + if (value.getElementsByClassName('progress_info_bold').length > 0) { + cardsDropsNumber = value.getElementsByClassName('progress_info_bold')[0].innerText.match(/\d/g); if (cardsDropsNumber !== null) { cardsDropLeft = [0]; } } let badgeItem = { - id: parseInt(value[1].childNodes[1].href.split('/')[6]), - uri: value[1].childNodes[1].href, - name: value[1].getElementsByClassName('badge_title')[0].innerText.trim().replace(/[\r\n\t]/g, ''), + id: parseInt(value.childNodes[1].href.split('/')[6]), + url: value.childNodes[1].href, + name: value.getElementsByClassName('badge_title')[0].innerText.trim().replace(/[\r\n\t]/g, ''), dropLeft: parseInt(cardsDropLeft), }; @@ -71,7 +71,7 @@ function getBadges() { const collection = doc.getElementsByClassName('badge_row'); for (const value of Object.entries(collection)) { - badges.push(getData(value)); + badges.push(getData(value[1])); } }) .catch((err) => console.warn('Something went wrong.', err));