Skip to content

Instantly share code, notes, and snippets.

@oneeyedman
Created June 7, 2025 12:46
Show Gist options
  • Save oneeyedman/a5329a972f829cae25585d6b98137312 to your computer and use it in GitHub Desktop.
Save oneeyedman/a5329a972f829cae25585d6b98137312 to your computer and use it in GitHub Desktop.
Función que pilla los hechizos de la ficha abierta de Foundry y me hace un array espartanao para que me los pueda ordenar.
function getSpells() {
const spellBlocks = document.querySelectorAll('.spells-list .items-section.card');
const spells = [...spellBlocks].map(block => [...block.querySelectorAll('.item')].map(spell => {
const lvl = spell.closest('.items-section.card').dataset.level
const prepared = spell.querySelector('.item-action.active')?.getAttribute('aria-label') ?? '<';
return {
name: spell.dataset.itemName,
lvl,
prepared
}
}))
console.log(spells)
}
getSpells();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment