') } midContentAdvert(); }); function structureArticle() { $('.article-container').first().unwrap(); $('.article-container:eq(1)').before($('.article-container').first()); } function midContentAdvert() { const index = Math.ceil($('.article-container .content > *, .article-container-v2 .content > *').length / 2); $('#midContentAdvert .advert').insertBefore($('.content > *:eq(' + index + ')')); }