Open Ascariel1984 opened 6 months ago
I made it this far, but unfortunately this is where my JS skills end. I could not figure out how to use the scryfall api to get the actual symbols as svg
So, I managed to do it finally, sorry for the noise. If you are interested, below is the code and here is the result:
const cardManaEl = createSpan(lineEl, {
cls: "mana-cost"
});
and
const svg_list = [];
let parts = cardInfo.mana_cost.replace(/\//g, "").split("{").slice(1);
for (let x of parts) {
svg_list.push("https://svgs.scryfall.io/card-symbols/" + x.slice(0,-1) + ".svg");
}
for (let x of svg_list) {
fetch(x)
.then(response => response.text())
.then(svgData => {
var svgElement = document.createElement('div');
svgElement.innerHTML = svgData;
var svg = svgElement.querySelector('svg');
svg.setAttribute('width', 18);
svg.setAttribute('height', 18);
cardManaEl.appendChild(svg);
});
}
} else {
cardNameEl.textContent = `${cardInfo && cardInfo.name || line.cardName || UNKNOWN_CARD}`;
}
First of all, great plugin, I love it!
It would be great for an overview, if the mana value is displayed to the left side of the card name! If can be done with the actual mana symbols, that would be awesome!
Thank you!