Utilisateur:Bad girl/common.js

Aller à la navigation Aller à la recherche

Note : après avoir enregistré tes préférences, tu devras forcer le rechargement complet du cache de ton navigateur pour voir les changements. Mozilla Firefox / Safari : maintiens la touche Majuscule (Shift) en cliquant sur le bouton Actualiser (Reload) ou presse Maj-Ctrl-R (Maj-Cmd-R sur Apple Mac) ; Internet Explorer / Opera : maintiens la touche Ctrl en cliquant sur le bouton Actualiser ou presse Ctrl-F5.

//Ajoute des liens dans la colonne de gauche. Synatxe : mw.util.addPortletLink('p-Nom du paragraphe', "/wiki/Nom de la page", 'Nom a mettre au lieu du lien');
    mw.util.addPortletLink('p-Navigation', "/wiki/Vikidia:Demandes_aux_administrateurs", 'Faire une demande aux administrateurs');
    mw.util.addPortletLink('p-Navigation', "/wiki/Vikidia:Demandes_aux_bureaucrates", 'Faire une demande aux bureaucrates');
    mw.util.addPortletLink('p-Navigation', "/wiki/Vikidia:Demandes aux vérificateurs d'utilisateurs", 'Demander une CU');
    mw.util.addPortletLink('p-Navigation', "/wiki/Vikidia:Bulletin_des_patrouilleurs", 'BulPat');
    mw.util.addPortletLink('p-Navigation', "/wiki/Vikidia:Alerte", 'Alerte');
    mw.util.addPortletLink('p-Contribuer', "/wiki/Modèle:Messages_anti-vandales", 'Messages anti-vandales');
    mw.util.addPortletLink('p-Contribuer', "/wiki/Vikidia:Image_du_jour", 'Image du jour');
    mw.util.addPortletLink('p-Contribuer', "/wiki/Utilisateur:Gachapixel2.0/Bac_à_sable", 'Mon bac à sable');
    mw.util.addPortletLink('p-Contribuer', "/wiki/Vikidia:Bac_à_sable", 'Bac à sable VD');
    mw.util.addPortletLink('p-Contribuer', "/wiki/Utilisateur:Gachapixel2.0/common.js", 'Common.js');
    
    
//Auto-sauvegarde en cas de conflit de modifications sur une même page.
if (document.getElementById('mw-twocolconflict-changes-header')){
	x = document.getElementsByClassName('oo-ui-inputWidget-input')[0] ;
	if (x.value == your){
		x.click() ;
	}
	x = document.getElementsByClassName('oo-ui-buttonElement-button')[0] ;
	if (x.innerHTML.includes('OK')){
		x.click() ;
	}
	x =  document.getElementById('wpSummary').value ;
	document.getElementById('wpSummary').value = [x,' (conflit de modification)'].join() ;
	document.getElementById('wpSave').click() ;
}


// Rafraîchissement des Modifications récentes
	elIndicRefresh = document.createElement("span");
	elIndicRefresh.style.fontWeight = 'bold';
	elIndicRefresh.setAttribute("id", "labelModRecR");
	document.getElementById("contentSub").appendChild(elIndicRefresh);

	refreshPage = function() {
		if(NomPage.indexOf("Spécial:Modifications_récentes") != -1) {
			elIndicRefresh.innerHTML = 'Les modifications sont rechargées.<a href="#" onclick="desactiverRefresh()">Désactiver</a>.';
			intervalRefreshMR = setInterval(function(){ location.reload() }, tempsRefreshMR * 10);
			createCookie("stopRefreshMR", "Non", 3600);
		}
	};
 
	desactiverRefresh = function() {
		if(NomPage.indexOf("Sp%C3%A9cial:Modifications_r%C3%A9centes") != -1) {
			createCookie("stopRefreshMR", "Oui", 3600);
			elIndicRefresh.innerHTML = 'Les modifications ne sont pas rechargées.<a href="#" onclick="refreshPage()">Réactiver</a>.';
			clearInterval(intervalRefreshMR);
		}
	};
 
	if(readCookie("stopRefreshMR") != "Oui") {
        refreshPage();
    }
	else {
		desactiverRefresh();
	}

	
	window.ResumeDeluxe_liens = [
	        'Créa ébauche',
	        'Créa en Travaux',
	        'Aération',
	        'Orthographe',
	        'Faute de frappe',
	        [ 'Erreur de c-c', 'Erreur de copié-collé' ],
	        'Typographie',
	        [ 'Oups', 'Oups...' ],
	        'Pfff...',
	        '+',
	        '+1',
	        '+2',
	        '+3',
	        [ 'MàJ', 'Mise à jour' ],
	        'Je peux ?',
	        'Test',
	        [ 'Mise à jour du bandeau de maintenance', 'Bandeau' ],
	        'Maintenance',
	        [ 'Vikif', 'Vikification' ],
	        'Mise en forme',
	        'Mise en page',
	        'Mieux',
	        'Relecture',
	        [ 'Categ', 'Catégorie' ],
	        'Portail',
	        [ 'Exist', '{{Existence}}' ],
	        'Image',
	        'Liens',
	        'Références',
	        'Infobox',
	        'Lien inexistant',
	        'Interwiki inexistant',
	        [ 'Img inexist', 'Image inexistante' ],
	        'SI',
	        'Réponse',
	        [ 'Indent', 'Indentation' ],
	        'Retouche de la modification précédente',
	        'Redirection',
	        'Réorganisation'
  	        ];



/*
* Ce script sert à ajouter un ongle "SmartPatrol" en-haut de la page, servant à relire toute la page, au lieu de plusieurs modifications intermédiaires.
*/

var totalRevisions;
var treatedRevisions = 0;

if (mw.config.get('wgNamespaceNumber') >= 0) {
  mw.loader.using( [ 'mediawiki.util', 'mediawiki.api', 'mediawiki.notify', 'oojs-ui' ], function() {
    mw.util.addPortletLink( 'p-cactions', 'javascript:markAllAsPatrolled()', 'Smart patrol', 'ca-smartpatrol' );
    //mw.util.addPortletLink( 'p-views', 'javascript:markAllAsPatrolled()', 'Smart patrol', 'ca-smartpatrol2', 'Tout marquer comme relu', '', 'ca-history' );
  } );
}

function markAllAsPatrolled() {
  new OO.ui.confirm('Êtes-vous sûr de vouloir marquer comme reluesj toutes les modifications ?').then( function( response ) {
    if ( response === true ) {
        getRevisionsList();
    }
  } );
}

function getRevisionsList() {
  var api = new mw.Api();
  api.get( {
	'action': 'query',
	'format': 'json',
	'prop': 'revisions',
	'titles': mw.config.get( 'wgPageName' ),
	'formatversion': '2',
	'rvprop': 'ids|user',
	'rvlimit': 'max'
  } ).then( function ( data ) {
    var revisions = data.query.pages[ 0 ].revisions;
    //var user = revisions[ 0 ].user;
    totalRevisions = revisions.length;
    revisions.forEach( function ( revision ) {
      treatedRevisions++;
      //if ( user === revision.user ) {
        markRevAsPatrolled( revision.revid );
      //}
    } );

  } ).fail( function ( error ) {
      mw.notification.notify( 'Something went wrong: ' + error, { title: 'Smart Patrol', type: 'error' } );
  } );
}

function markRevAsPatrolled( revid ) {
  var api = new mw.Api();
  api.postWithToken( 'patrol', {
	'action': 'patrol',
	'revid': revid

  } ).then( function ( info ) {
    console.log( 'Success for ' + revid, { title: 'Smart Patrol', type: 'info' } );
    if ( totalRevisions == treatedRevisions ) { window.location.reload(); }

  } ).fail( function ( error ) {
    console.log( 'Something went wrong: ' + error, { title: 'Smart Patrol', type: 'error' } );
  } );
}


function AppendCategoryTreeToSidebar() {
    try {
        var node = document.getElementById( "p-tb" )
                           .getElementsByTagName('div')[0]
                           .getElementsByTagName('ul')[0];
 
        var aNode = document.createElement( 'a' );
        var liNode = document.createElement( 'li' );
 
        aNode.appendChild( document.createTextNode( 'CategoryTree' ) );
        aNode.setAttribute( 'href' , '[[w:en:Special:CategoryTree]]' );
        liNode.appendChild( aNode );
        liNode.className = 'plainlinks';
        node.appendChild( liNode );
    } catch(e) {
        // lets just ignore what's happened
        return;
    }
}
 
addOnloadHook( AppendCategoryTreeToSidebar );

//Un nouveau gadget
mw.loader.load("https://fr.vikidia.org/w/index.php?title=Utilisateur:Matteo1234321/UserinfoVikidia.js&action=raw&ctype=text/javascript");


//HotCats Multi
importScript('Utilisateur:Linedwell/HotCatsMulti.js');

/* 
Javascript qui s'active lors du renommage d'une page.

Fournit des résumés de modification prédéfinis (personnalisables, voir plus bas)


Documentation : [[Projet:JavaScript/Notices/MoveDeluxe]]
 
Licence : Domaine Public
 
{{Catégorisation JS|MoveDeluxe}}

*/
//<source lang=javascript>//<pre><nowiki>


if(typeof(MoveDeluxe_Reason)=='undefined'){ ////// PARTIE PERSONNALISABLE ///////////////

     window.MoveDeluxe_Reason = [
       { text : "Typo",      reason : "Typographir" },
       { text : "Ortho",     reason : "Orthographe"                },
       { text : "Namespace", reason : "Mauvais espace de noms"     },
       { text : "Précision", reason : "Titre imprécis"             },
       { text : "Titre attendu", reason : "Titre attendu"          }
     ];

} //////////////////////////////////////////////// FIN DE LA PARTIE PERSONNALISABLE /////


window.MoveDeluxe = function(){
     var MoveForm = document.getElementById('movepage');
     if(!MoveForm) return;
     var TextArea = document.getElementById('wpReason');
     if(TextArea) MoveDeluxe_GetReasons();
}

window.MoveDeluxe_GetReasons = function(){
     if(typeof(MoveDeluxe__GetSiteCustom)==="function") try{ MoveDeluxe__GetSiteCustom(); }catch(e){ }
     if(typeof(MoveDeluxe__GetUserCustom)==="function") try{ MoveDeluxe__GetUserCustom(); }catch(e){ }
     if(MoveDeluxe_Reason.length < 1 ) return;
     var Reasons = [];
     for(var a=0,l=MoveDeluxe_Reason.length;a<l;a++){
          if(typeof(MoveDeluxe_Reason[a]) == "string")
               Reasons[a] = { text : MoveDeluxe_Reason[a], reason : MoveDeluxe_Reason[a] };
          else
               Reasons[a] = MoveDeluxe_Reason[a];
     }
     var TextArea = document.getElementById('wpReason');
     var NewSelect = document.createElement('select');
     NewSelect.id = 'ReasonSelect';
     TextArea.parentNode.insertBefore(NewSelect, TextArea);
     NewSelect.onchange = function(){
          var Selected = this.getElementsByTagName('option');
          for(var a=0;a<Selected.length;a++){
               if(Selected[a].selected){
                    var TextSelected = Selected[a].value;
                    document.getElementById('wpReason').firstChild.value = TextSelected;
                    document.getElementById('wpReason').firstChild.focus();
               }
          }
     }
     NewSelect.innerHTML += '<option value=""></option>';
     for(var a=0;a<Reasons.length;a++){
           NewSelect.innerHTML += '<option value="'+Reasons[a].reason+'" '
                                 +'>'+Reasons[a].text+'</option>';

     }
}

///////////////////////////////////////////////////// Lancements

if(mw.config.get('wgCanonicalSpecialPageName')=="Movepage"){ 
      $(MoveDeluxe);
}
//</nowiki></pre></source>