Differenza tranter versiuns da "Gadget-SmartPatrol.js"
Ord Le Dico des Ados
dico>Rififi Keine Bearbeitungszusammenfassung |
P Ina versiun |
(negina differenza)
|
Versiun actuala dals 26. avust 2025, las 16:25 uras
/*
* This script adds a tab which allows a mass patrolling on the current page. Because it was pointless to mark as patrolled 10 intermediate versions when we can read the difference between the first and the last
* Based from Vivi-1's original script on https://fr.vikidia.org/wiki/Utilisateur:Vivi-1/js/SmartPatrol.js, CC-BY-SA-3.0, add ?action=history to the url to see full revisions list.
*/
if(window.markAllAsPatrolled === undefined && window.markAllAsPatrolledConfirm === undefined && window.markRevAsPatrolled === undefined || true) {
var totalRevisions,
treatedRevisions = 0;
if (mw.config.get('wgNamespaceNumber') >= 0) {
mw.loader.using( [ 'mediawiki.util', 'mediawiki.api', 'oojs-ui' ], function() {
mw.util.addPortletLink( 'p-cactions', 'javascript:window.markAllAsPatrolledConfirm()', 'Smart patrol', 'ca-smartpatrol' );
var NewLinkElt = document.getElementById("ca-smartpatrol").firstElementChild;
NewLinkElt.innerHTML = "<i class=\"fad fa-check-double fa-fw\"></i> "+NewLinkElt.innerHTML;
} );
}
window.markAllAsPatrolledConfirm = function(){
new OO.ui.confirm('Êtes-vous sûr de vouloir marquer comme relues toutes les modifications ?').then( function( response ) {
if ( response === true ) {
window.markAllAsPatrolled();
}
} );
}
window.markAllAsPatrolled = function() {
var api = new mw.Api();
api.get( {
'action': 'query',
'format': 'json',
'prop': 'revisions',
'titles': mw.config.get( 'wgPageName' ),
'formatversion': '2',
'rvprop': 'ids',
'rvlimit': 'max'
} ).then( function ( data ) {
var revisions = data.query.pages[ 0 ].revisions;
totalRevisions = revisions.length;
revisions.forEach( function ( revision ) {
treatedRevisions++;
markRevAsPatrolled( revision.revid );
} );
} ).fail( function ( error ) {
mw.notification.notify( 'Something went wrong: ' + error, { title: 'Smart Patrol', type: 'error' } );
} );
}
window.markRevAsPatrolled = function(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' } );
} );
}
}