Utilisateur:Symac/tampermonkey
Deux scripts tampermonkey pour améliorer la manière de gérer la liste de suivi :
Mise en forme avec liens hist en début de ligne
modifier// ==UserScript==
// @name New script wikipedia.org
// @namespace Violentmonkey Scripts
// @match https://fr.wikipedia.org/w/index.php*
// @grant GM_addStyle
// @version 1.0
// @author -
// @description 16/02/2026 07:23:56
// ==/UserScript==
GM_addStyle ( `
.mw-changeslist-history {
letter-spacing: 4px;
}
` );
(function () {
'use strict';
function moveHistLinks(root = document) {
// Lignes normales des RC
const inners = root.querySelectorAll('.mw-changeslist-line-inner');
inners.forEach(inner => {
// Trouver le lien hist
const histLink = inner.querySelector('a.mw-changeslist-history');
if (!histLink) return;
// Éviter de le déplacer plusieurs fois
if (histLink.dataset.movedHist === '1') return;
// Conteneur des liens (diff | hist)
const linksContainer = histLink.closest('.mw-changeslist-links') || histLink.parentElement;
if (!linksContainer) return;
// Créer un clone pour le placer en tête
const histClone = histLink.cloneNode(true);
histClone.dataset.movedHist = '1';
histClone.style.marginRight = '0.5em';
// Insérer au tout début du bloc interne
inner.insertBefore(histClone, inner.firstChild);
});
// Cas des RC améliorées imbriquées (enhanced RC)
const enhancedRows = root.querySelectorAll('.mw-enhanced-rc-nested');
enhancedRows.forEach(row => {
const histLink = row.querySelector('a.mw-changeslist-history');
if (!histLink || histLink.dataset.movedHist === '1') return;
const histClone = histLink.cloneNode(true);
histClone.dataset.movedHist = '1';
histClone.style.marginRight = '0.5em';
row.insertBefore(histClone, row.firstChild);
});
}
// Exécution initiale
moveHistLinks();
// Observer pour les mises à jour dynamiques des RC
const observer = new MutationObserver(mutations => {
for (const m of mutations) {
if (m.addedNodes && m.addedNodes.length) {
m.addedNodes.forEach(node => {
if (node.nodeType === 1) {
moveHistLinks(node);
}
});
}
}
});
observer.observe(document.body, {
childList: true,
subtree: true
});
})();
Affiche d'un bouton pour voir depuis la dernière visite
modifier// ==UserScript==
// @name Wikipédia – Voir toutes les modifs depuis la dernière visite
// @namespace https://fr.wikipedia.org/
// @version 1.2
// @description Ajoute un bouton pour voir toutes les modifications depuis la dernière visite sur l’historique
// @match https://fr.wikipedia.org/w/index.php?title=*&action=history*
// @grant none
// ==/UserScript==
(function () {
'use strict';
function run() {
console.log('A1');
const mwConf = mw.config && mw.config.values;
if (!mwConf) return;
console.log('A2');
const title = mwConf.wgPageName;
const currentRev = mwConf.wgCurRevisionId;
if (!currentRev) return;
const historyList = document.getElementById('pagehistory');
if (!historyList) return;
// éviter doublon
if (document.getElementById('diff-since-last-visit')) return;
const items = Array.from(historyList.querySelectorAll('li'));
let lastSeenRev = null;
for (const li of items) {
if (!li.querySelector('.updatedmarker')) {
lastSeenRev =
li.dataset.mwRevid ||
li.querySelector('a[href*="oldid="]')
?.href.match(/oldid=(\d+)/)?.[1];
break;
}
}
if (!lastSeenRev) return;
const diffUrl =
`https://fr.wikipedia.org/w/index.php?title=${title}` +
`&diff=${currentRev}&oldid=${lastSeenRev}`;
const button = document.createElement('a');
button.id = 'diff-since-last-visit';
button.href = diffUrl;
button.textContent = 'Voir toutes les modifications depuis la dernière visite';
button.style.display = 'inline-block';
button.style.margin = '0.5em 0';
button.style.padding = '0.5em 0.8em';
button.style.background = '#36c';
button.style.color = '#fff';
button.style.borderRadius = '4px';
button.style.fontWeight = 'bold';
button.style.textDecoration = 'none';
button.addEventListener('mouseover', () => {
button.style.background = '#3056a9';
});
button.addEventListener('mouseout', () => {
button.style.background = '#36c';
});
const heading = document.getElementById('firstHeading');
if (heading && heading.parentNode) {
heading.parentNode.insertBefore(button, heading.nextSibling);
}
}
/**
* Bootstrap MediaWiki robuste
* (attend que mw.loader.using existe vraiment)
*/
function waitForMediaWiki(callback) {
const maxTries = 50;
let tries = 0;
const timer = setInterval(() => {
tries++;
if (window.mw && mw.loader && typeof mw.loader.using === 'function') {
clearInterval(timer);
callback();
} else if (tries >= maxTries) {
clearInterval(timer);
console.warn('MediaWiki non initialisé à temps');
}
}, 100);
}
waitForMediaWiki(() => {
mw.loader.using('mediawiki.util').then(() => {
mw.hook('wikipage.content').add(run);
});
});
})();