MediaWiki:Mobile.js: відмінності між версіями
Матеріал з WikiLegalAid
Alexb (обговорення | внесок) Немає опису редагування |
Alexb (обговорення | внесок) Немає опису редагування |
||
| Рядок 1: | Рядок 1: | ||
mw.loader.using('mobile.startup', function () { | mw.loader.using('mobile.startup', function () { | ||
mw.hook('mobile. | mw.hook('mobile.init').add(function () { | ||
console.log("MobileFrontend ініціалізовано"); | |||
const observer = new MutationObserver(() => { | |||
document.querySelectorAll('section.collapsed').forEach(function (section) { | |||
section.classList.remove('collapsed'); | |||
section.classList.add('expanded'); | |||
const content = section.querySelector('.content'); | |||
if (content) { | |||
content.style.display = 'block'; | |||
} | |||
// Додаємо рекламний блок (можна прибрати, якщо не треба) | |||
const adDiv = document.createElement('div'); | |||
adDiv.className = 'ad-block'; | |||
adDiv.style = 'margin: 20px 0; text-align: center;'; | |||
adDiv.innerHTML = '<ins class="adsbygoogle" style="display:block" data-ad-client="ca‑pub‑9946719691242357" data-ad-slot="YYYY" data-ad-format="auto"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script>'; | |||
if (!section.classList.contains('ad-inserted')) { | |||
section.classList.add('ad-inserted'); // щоб не дублювати | |||
section.after(adDiv); | |||
} | |||
}); | |||
}); | |||
observer.observe(document.body, { | |||
childList: true, | |||
subtree: true | |||
}); | }); | ||
}); | }); | ||
}); | }); | ||
Версія за 09:48, 12 травня 2025
mw.loader.using('mobile.startup', function () {
mw.hook('mobile.init').add(function () {
console.log("MobileFrontend ініціалізовано");
const observer = new MutationObserver(() => {
document.querySelectorAll('section.collapsed').forEach(function (section) {
section.classList.remove('collapsed');
section.classList.add('expanded');
const content = section.querySelector('.content');
if (content) {
content.style.display = 'block';
}
// Додаємо рекламний блок (можна прибрати, якщо не треба)
const adDiv = document.createElement('div');
adDiv.className = 'ad-block';
adDiv.style = 'margin: 20px 0; text-align: center;';
adDiv.innerHTML = '<ins class="adsbygoogle" style="display:block" data-ad-client="ca‑pub‑9946719691242357" data-ad-slot="YYYY" data-ad-format="auto"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script>';
if (!section.classList.contains('ad-inserted')) {
section.classList.add('ad-inserted'); // щоб не дублювати
section.after(adDiv);
}
});
});
observer.observe(document.body, {
childList: true,
subtree: true
});
});
});
