User:Célian/common.js: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
Created page with "importScript:('user:Célian/test.js');" |
mNo edit summary |
||
| Line 1: | Line 1: | ||
importScript:('user:Célian/test.js'); |
importScript:('user:Célian/test.js'); |
||
$(function () { |
|||
if (mw.config.get('wgCanonicalSpecialPageName') !== 'Recentchanges') return; |
|||
const seuilCaractères = 200; |
|||
const userIsAdmin = mw.config.get('wgUserGroups').includes('sysop'); |
|||
$('.mw-changeslist-line-inner').each(function () { |
|||
const $ligne = $(this); |
|||
const estCreation = $ligne.find('.mw-changeslist-separator + .newpage').length > 0; |
|||
const lienDiff = $ligne.find('a.mw-changeslist-diff').attr('href'); |
|||
if (estCreation && lienDiff) { |
|||
fetch(lienDiff + '&action=raw') |
|||
.then(res => res.text()) |
|||
.then(contenuPage => { |
|||
if (contenuPage.length < seuilCaractères) { |
|||
$ligne.css('background-color', '#fff3c4'); // jaune pâle |
|||
$ligne.prepend('⚠️ Article très court '); |
|||
if (userIsAdmin) { |
|||
const pageName = mw.util.getParamValue('title', lienDiff); |
|||
if (pageName) { |
|||
const bouton = $('<a>') |
|||
.text('🗑️ Supprimer') |
|||
.attr('href', mw.util.getUrl('Special:Delete/' + pageName)) |
|||
.css({ |
|||
'margin-left': '10px', |
|||
'color': 'red', |
|||
'font-weight': 'bold', |
|||
'text-decoration': 'none' |
|||
}); |
|||
$ligne.append(bouton); |
|||
} |
|||
} |
|||
} |
|||
}); |
|||
} |
|||
}); |
|||
}); |
|||
Latest revision as of 18:01, 15 July 2025
importScript:('user:Célian/test.js');
$(function () {
if (mw.config.get('wgCanonicalSpecialPageName') !== 'Recentchanges') return;
const seuilCaractères = 200;
const userIsAdmin = mw.config.get('wgUserGroups').includes('sysop');
$('.mw-changeslist-line-inner').each(function () {
const $ligne = $(this);
const estCreation = $ligne.find('.mw-changeslist-separator + .newpage').length > 0;
const lienDiff = $ligne.find('a.mw-changeslist-diff').attr('href');
if (estCreation && lienDiff) {
fetch(lienDiff + '&action=raw')
.then(res => res.text())
.then(contenuPage => {
if (contenuPage.length < seuilCaractères) {
$ligne.css('background-color', '#fff3c4'); // jaune pâle
$ligne.prepend('⚠️ Article très court ');
if (userIsAdmin) {
const pageName = mw.util.getParamValue('title', lienDiff);
if (pageName) {
const bouton = $('<a>')
.text('🗑️ Supprimer')
.attr('href', mw.util.getUrl('Special:Delete/' + pageName))
.css({
'margin-left': '10px',
'color': 'red',
'font-weight': 'bold',
'text-decoration': 'none'
});
$ligne.append(bouton);
}
}
}
});
}
});
});