MediaWiki:Mobile.js: відмінності між версіями

Матеріал з WikiLegalAid
Немає опису редагування
Немає опису редагування
Рядок 2: Рядок 2:
mw.loader.using('mobile.startup', function () {
mw.loader.using('mobile.startup', function () {
     mw.hook('wikipage.content').add(function ($content) {
     mw.hook('wikipage.content').add(function ($content) {
         // Вимикаємо collapsible у всіх секціях
         // HTML вміст рекламного блоку (заміни на свій код)
        const adHtml = '<div class="ad-block" style="margin: 20px 0; text-align: center;">' +
                      '<ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-9946719691242357" data-ad-format="auto"></ins>' +
                      '<script>(adsbygoogle = window.adsbygoogle || []).push({});</script>' +
                      '</div>';
 
         $content.find('.section-heading').each(function () {
         $content.find('.section-heading').each(function () {
             const $section = $(this).closest('section');
             const $section = $(this).closest('section');
           
             $section.removeClass('collapsed');
             $section.removeClass('collapsed');
             $section.addClass('expanded');
             $section.addClass('expanded');
             $section.find('.content-block').show(); // Показати вміст секції
             $section.find('.content-block').show();
        });
    });
});
mw.loader.using(['mediawiki.util'], function () {
    $(document).ready(function () {
        // HTML вміст рекламного блоку
        const adHtml = '<div class="ad-block" style="margin: 20px 0; text-align: center;">' +
                      '<!-- Ваш рекламний код -->' +
                      '<ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-9946719691242357" data-ad-format="auto"></ins>' +
                      '<script>(adsbygoogle = window.adsbygoogle || []).push({});</script>' +
                      '</div>';


        // Вибираємо всі заголовки розділів
            $section.after(adHtml);
        $('section > h2, section > h3').each(function () {
            // Вставляємо рекламний блок ПІСЛЯ заголовка
            $(this).after(adHtml);
         });
         });
     });
     });
});
});