addEventListener("DOMContentLoaded", (event) => { const mainEl = document.body.querySelector("main"); mainEl.querySelectorAll("article.mainpage>article.inlinepage").forEach(inlineArticleEl => { // remove nested inlines inlineArticleEl.querySelectorAll(":scope>article.inlinepage").forEach(inlineInlineArticleEl => { inlineArticleEl.removeChild(inlineInlineArticleEl); }); // append to main mainEl.appendChild(inlineArticleEl); }) })