« MediaWiki:Common.js » : différence entre les versions
Apparence
Aucun résumé des modifications |
Aucun résumé des modifications |
||
| Ligne 3 : | Ligne 3 : | ||
for (const mutation of mutationsList) { | for (const mutation of mutationsList) { | ||
if (mutation.target.classList.contains('vector-animations-ready')) { | if (mutation.target.classList.contains('vector-animations-ready')) { | ||
const button = document.querySelector( | const button = document.querySelector( | ||
'[data-event-name="pinnable-header.vector-main-menu. | '[data-event-name="pinnable-header.vector-main-menu.unpin"]' | ||
); | ); | ||
Version du 10 août 2026 à 15:59
if (!mw.config.get('wgUserName')) {
const observer = new MutationObserver((mutationsList, observer) => {
for (const mutation of mutationsList) {
if (mutation.target.classList.contains('vector-animations-ready')) {
const button = document.querySelector(
'[data-event-name="pinnable-header.vector-main-menu.unpin"]'
);
if (button) {
button.click();
}
observer.disconnect();
break;
}
}
});
observer.observe(document.documentElement, {
attributes: true,
attributeFilter: ['class']
});
}
$(function () {
const header = document.querySelector('.vector-header-end');
if (!header) return;
const container = document.createElement('div');
container.className = "pne-header-links";
container.innerHTML = `
<a href="/wiki/index.php/Spécial:Toutes_les_pages">Parcourir</a>
<a href="/wiki/index.php/Spécial:Catégories">Catégories</a>
`;
header.prepend(container);
});
/* ============================= */
/* DÉTECTION AUTOMATIQUE DES VALEURS NUMÉRIQUES */
/* ============================= */
mw.hook('wikipage.content').add(function ($content) {
$content.find('table.fandom-table td, table.wikitable td').each(function () {
const cell = $(this);
const text = cell.text().trim();
// Nombre entier, décimal, positif/négatif, avec éventuellement %
if (/^[+-]?\d+(?:[.,]\d+)?%?$/.test(text)) {
cell.addClass('pne-number');
}
});
});