Created
October 7, 2019 16:25
-
-
Save Adrian-Samuel/e61527793e4c62f591487a3f733e8871 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(async () => { | |
const domain = window.location.host; | |
const [RAD, itemID] = window.location.href.match(/\d+/g); | |
const itemDOMDescription = document.querySelector('.description') | |
const getItemMatrix = await fetch(`https://${domain}/API/Account/${RAD}/Item/${itemID}.json?load_relations=["ItemAttributes"]`, { | |
credentials: "same-origin" | |
}); | |
const itemMatrixData = await getItemMatrix.json(); | |
const dataAttributes = Object.entries(itemMatrixData.Item.ItemAttributes) | |
.filter(attr => /attribute/g.test(attr)) | |
.reduce((mainWord, currentString) => `${mainWord} ${currentString[1]}`, '') | |
const itemDescriptionText = itemDOMDescription.innerText | |
const baseItem = itemDescriptionText.replace(new RegExp(dataAttributes.trim(), 'g'), "").trim() | |
itemDOMDescription.innerText = baseItem; | |
itemDOMDescription.insertAdjacentHTML('afterend', `<p style="color:red;font-weight: 800">${dataAttributes}</p>`) | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment