You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.1 KiB

<script src="../../js/umbrella.min.js"></script>
<script src="../../js/print.js"></script>
<script>
window.addEventListener('load', function () {
const zutatenNode = document.evaluate('//*[@id="zutaten"]', document).iterateNext()
let nodeBlocks = [[]]
let nextNode = zutatenNode.nextElementSibling
while (nextNode && nextNode.tagName != "H2") {
if(nextNode.tagName == 'H4') {
nodeBlocks.push([])
}
nodeBlocks[nodeBlocks.length - 1].push(nextNode)
nextNode = nextNode.nextElementSibling
}
let allIngredientsDiv = document.createElement('div')
allIngredientsDiv.id = "allZutaten"
allIngredientsDiv.classList.add('allZutaten')
let nodeBlockIndex = 0
nodeBlocks.forEach(function(nodeArray) {
let outerDiv = document.createElement('div')
outerDiv.id = `wrap${nodeBlockIndex}`
outerDiv.classList.add("zutatenWrapper")
allIngredientsDiv.appendChild(outerDiv)
for(elem of nodeArray) {
outerDiv.appendChild(elem)
}
nodeBlockIndex += 1
})
zutatenNode.parentNode.insertBefore(allIngredientsDiv, zutatenNode.nextSibling)
console.log("Finished fiddling")
})
</script>