' + str + '
'; }); let displayPoint = ((node) => { if (node.querySelectorAll && node.getElementsByClassName('fetched')[0] === undefined && node.querySelector('div[id^="item_"]') !== null && /Kindle/.test(node.innerText)) { node.getElementsByTagName('div')[0].classList.add('fetched'); const priceSection = node.getElementsByClassName('price-section')[0]; const asin = JSON.parse(priceSection.attributes["data-item-prime-info"].value).asin; console.log(asin); fetch('https://www.amazon.co.jp/dp/' + asin).then((response) => response.text()).then((text) => { const html = domParser.parseFromString(text, 'text/html'); const printPrice = html.getElementsByClassName('print-list-price')[0]; const kindleSave = html.getElementsByClassName('ebooks-price-savings')[0]; const loyaltyPoint = html.getElementsByClassName('loyalty-points')[0]; if (printPrice !== undefined) priceSection.insertAdjacentHTML('afterbegin', setColor(modifyCharacter(printPrice.innerText))); if (kindleSave !== undefined) priceSection.insertAdjacentHTML('beforeend', setColor('割引:' + modifyCharacter(kindleSave.innerText).replace( /¥/, '' ))); if (loyaltyPoint !== undefined) priceSection.insertAdjacentHTML('beforeend', setColor(modifyCharacter(loyaltyPoint.innerText))); node.getElementsByClassName('a-price-symbol')[0].remove(); node.getElementsByClassName('a-price-whole')[0].insertAdjacentHTML('afterbegin', '¥'); node.getElementsByClassName('a-price')[0].classList.add('a-color-price', 'a-size-large'); }).catch((error) => console.error(error)); } }); let main = ((node) => { for (const node of document.getElementsByClassName('g-item-sortable')) { displayPoint(node); } observer.observe(document.getElementById('g-items'), { childList: true, subtree: true, }); }); main(); }); })();