« MediaWiki:Common.css » : différence entre les versions

Ange (discussion | contributions)
Aucun résumé des modifications
Balise : wikieditor
Bénédicte (discussion | contributions)
Aucun résumé des modifications
 
(2 versions intermédiaires par un autre utilisateur non affichées)
Ligne 1 : Ligne 1 :
/* Le CSS placé ici sera appliqué à tous les habillages. */
/* Kolleggram – masquage RC des pages privées pour les visiteurs */
#sidebar{
window.kgmHideRC = (function () {
  display:none;
  var groups = mw.config.get('wgUserGroups') || [];
}
  var isAdmin = groups.indexOf('sysop') !== -1;
  if (isAdmin) return; // les admins voient tout


#p-navigation, #p-tb h5, #p-tb .pBody { display:none }
  var canon = mw.config.get('wgCanonicalSpecialPageName') || '';
  var onList = ['Recentchanges','Recentchangeslinked','Watchlist','Newpages'].indexOf(canon) !== -1;
  if (!onList) return;
 
  var targets = [
    'Espace_administratrice',        // DBkey
    'Espace administratrice',        // titre humain
    'Admini'
  ];
 
  function isTargetLink(a) {
    var href = (a.getAttribute('href') || '').toLowerCase();
    var text = (a.textContent || '').toLowerCase();
    return targets.some(function (t) {
      t = t.toLowerCase();
      return href.indexOf(t) !== -1 || href.indexOf(encodeURIComponent(t)) !== -1 || text.indexOf(t) !== -1;
    });
  }
 
  function removeRowForLink(a) {
    var row = a.closest('li, tr, .mw-changeslist-line, .mw-newpages-page'); // gère plusieurs skins
    if (row) row.remove();
  }
 
  function sweep() {
    // Liens de titre dans les RC (plusieurs variantes selon skin/extensions)
    var sel = [
      '.mw-changeslist a.mw-changeslist-title',
      '.mw-changeslist .mw-title a',
      'a.mw-newpages-pagename',
      'a[title]' // filet de sécurité
    ].join(', ');
    document.querySelectorAll(sel).forEach(function (a) {
      if (isTargetLink(a)) removeRowForLink(a);
    });
  }
 
  // Premier passage + pour les mises à jour en direct
  sweep();
  mw.hook('wikipage.content').add(sweep);
 
  // Et si RC Live réinvente le DOM, on observe aussi
  var obs = new MutationObserver(function () { sweep(); });
  obs.observe(document.body, {childList: true, subtree: true});
 
  // Marqueur debug
  console.log('kgmHideRC actif');
})();

Dernière version du 27 octobre 2025 à 11:53

/* Kolleggram – masquage RC des pages privées pour les visiteurs */
window.kgmHideRC = (function () {
  var groups = mw.config.get('wgUserGroups') || [];
  var isAdmin = groups.indexOf('sysop') !== -1;
  if (isAdmin) return; // les admins voient tout

  var canon = mw.config.get('wgCanonicalSpecialPageName') || '';
  var onList = ['Recentchanges','Recentchangeslinked','Watchlist','Newpages'].indexOf(canon) !== -1;
  if (!onList) return;

  var targets = [
    'Espace_administratrice',        // DBkey
    'Espace administratrice',        // titre humain
    'Admini'
  ];

  function isTargetLink(a) {
    var href = (a.getAttribute('href') || '').toLowerCase();
    var text = (a.textContent || '').toLowerCase();
    return targets.some(function (t) {
      t = t.toLowerCase();
      return href.indexOf(t) !== -1 || href.indexOf(encodeURIComponent(t)) !== -1 || text.indexOf(t) !== -1;
    });
  }

  function removeRowForLink(a) {
    var row = a.closest('li, tr, .mw-changeslist-line, .mw-newpages-page'); // gère plusieurs skins
    if (row) row.remove();
  }

  function sweep() {
    // Liens de titre dans les RC (plusieurs variantes selon skin/extensions)
    var sel = [
      '.mw-changeslist a.mw-changeslist-title',
      '.mw-changeslist .mw-title a',
      'a.mw-newpages-pagename',
      'a[title]' // filet de sécurité
    ].join(', ');
    document.querySelectorAll(sel).forEach(function (a) {
      if (isTargetLink(a)) removeRowForLink(a);
    });
  }

  // Premier passage + pour les mises à jour en direct
  sweep();
  mw.hook('wikipage.content').add(sweep);

  // Et si RC Live réinvente le DOM, on observe aussi
  var obs = new MutationObserver(function () { sweep(); });
  obs.observe(document.body, {childList: true, subtree: true});

  // Marqueur debug
  console.log('kgmHideRC actif');
})();