Utilisateur:DreZhsh/DisableAutoEditTalk.js
Note : après avoir enregistré la page, vous devrez forcer le rechargement complet du cache de votre navigateur pour voir les changements.
Mozilla / Firefox / Konqueror / Safari : maintenez la touche Majuscule (Shift) en cliquant sur le bouton Actualiser (Reload) ou pressez Maj-Ctrl-R (Cmd-R sur Apple Mac) ;
Chrome / Internet Explorer / Opera : maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl-F5./**
* DisableAutoEditTalk.js
*
* Désactive l'édition automatique d'une page
* de discussion inexistante.
*
* Utilisation : ajoutez mw.loader.load('//fr.wikipedia.org/w/index.php?title=Utilisateur:DreZhsh/DisableAutoEditTalk.js&action=raw&ctype=text/javascript');
* à votre common.js
* {{Catégorisation JS}}
*/
$( function () {
const supportedSkin = [ 'vector-2022', 'vector', 'monobook', 'timeless', 'minerva' ];
const getSkin = mw.config.get( 'skin' );
if ( mw.config.get( 'wgNamespaceNumber' ) % 2 === 0 && supportedSkin.indexOf( getSkin ) !== -1 ) {
disableAutoEdit();
}
function defineHref() {
if ( mw.config.get( 'wgNamespaceNumber' ) === 0 ) {
const talkHref = `/wiki/Discussion:${mw.config.get( 'wgPageName' )}`;
return talkHref;
} else {
const talkHref = `/wiki/Discussion_${mw.config.get( 'wgPageName' )}`;
return talkHref;
}
}
function disableAutoEdit() {
const hrefPath = defineHref();
supportedSkin.pop();
if ( getSkin === 'minerva' ) {
const $divMinervaSelector = $( 'div.minerva__tab-container' ).children().last();
$divMinervaSelector.attr( 'href', hrefPath );
} else if ( supportedSkin.indexOf( getSkin ) !== -1 ) {
$( '#ca-talk' ).children().attr( 'href', hrefPath );
}
}
} );