MediaWiki:Common.js
Apparence
Note : après avoir publié vos modifications, il se peut que vous deviez forcer le rechargement complet du cache de votre navigateur pour voir les changements.
- Firefox / Safari : maintenez la touche Maj (Shift) en cliquant sur le bouton Actualiser ou appuyez sur Ctrl + F5 ou Ctrl + R (⌘ + R sur un Mac).
- Google Chrome : appuyez sur Ctrl + Maj + R (⌘ + Shift + R sur un Mac).
- Edge : maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl + F5.
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');
}
});
});