MediaWiki:Gadget-RevertDiff.js

Nòta : Aprèp aver publicat la pagina, vos cal forçar son recargament complet tot ignorant lo contengut actual de l'amagatal de vòstre navigador per veire los cambiaments : Mozilla / Firefox / Konqueror / Safari : mantenètz la tòca Majuscula (Shift) en clicant lo boton Actualizar (Reload,) o quichatz Maj-Ctrl-R (Maj-Cmd-R sus Apple Mac) ; Internet Explorer / Opera : mantenètz la tòca Ctrl en clicant lo boton Actualizar o quichatz Ctrl-F5.

/**
 * Espleches per revertar
 *
 * Provesís de ligams dins las paginas de dif
 *
 * Autor : Lorian (en)
 * Darrièra revision : 24 de decembre de 2007
 * [[Categoria:MediaWiki:Foncion Monobook en JavaScript]]
 */

// _GET code from NoGray JS Library http://www.nogray.com/new_site/
var _GET = new Array();
var _uri = location.href;

var _temp_get_arr = _uri.substring(_uri.indexOf('?')+1, _uri.length).split("&");

var _temp_get_arr_1 = new Array();

for(_get_arr_i=0; _get_arr_i<_temp_get_arr.length; _get_arr_i++){
        _temp_get_arr_1 = _temp_get_arr[_get_arr_i].split("=");
        _GET[decodeURI(_temp_get_arr_1[0])] = decodeURI(_temp_get_arr_1[1]);
}

delete _uri; delete _temp_get_arr; delete _temp_get_arr_1;

function getMessage (where, user1, user2) {
        var message = prompt ('Quin messatge cal daissar ?', '');
        if (message) {
        window.location = '//oc.wikipedia.org/w/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&'+where+'=2&user1='+user1+'&user2='+user2+'&message='+message;
        }
}

$(function (){
                if (location.href.match(/diff=/)) {
                // Get username of submitter
                var user1 = document.querySelectorAll('td.diff-otitle'); if(user1) user1 = user1[0].getElementsByTagName('a')[2].innerHTML;
                var user2 = document.querySelectorAll('td.diff-ntitle'); if(user2) user2 = user2[0].getElementsByTagName('a')[2].innerHTML;
                if(!user1 || !user2) return;
                if (user2 == "défaire"){ 
                    user2 = document.querySelectorAll('td.diff-ntitle'); user2 = user2[0].getElementsByTagName('a')[3].innerHTML; 
                }
                document.getElementById('contentSub').innerHTML = '(<a href="//oc.wikipedia.org/w/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&revert=1&user1='+user1+'&user2='+user2+'">Annuler</a> / <a href="javascript:var message = getMessage(\'revert\', \''+user1+'\', \''+user2+'\');">Messatge</a>) (<a href="//oc.wikipedia.org/w/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&vandalism=1&user1='+user1+'&user2='+user2+'">Vandalisme</a> / <a href="javascript:var message = getMessage(\'vandalism\', \''+user1+'\', \''+user2+'\');">Messatge</a>) (Avertir : <a href="//oc.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=1">Tèst0</a> / <a href="//oc.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=2">Tèst1</a> / <a href="//oc.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=3">Tèst2</a> / <a href="//oc.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=4">Tèst3</a>)';
                } else if (location.href.match(/revert=1/)) {
                document.getElementById('wpSummary').value = 'Revocacion de las modificacions per [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] ; retorn a la version de [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']]';
                document.getElementById('editform').submit();
                } else if (location.href.match(/revert=2/)) {
                document.getElementById('wpSummary').value = 'Revocacion de las modificacions per [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] ; retorn a la version de [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']] ('+_GET['messatge']+')';
                        document.getElementById('editform').submit();
                        } else if (location.href.match(/vandalism=1/)) {
                        document.getElementById('wpSummary').value = 'Revocacion de vandalisme per [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] ; retorn a la version de [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']]';
                        document.getElementById('editform').submit();
                        } else if (location.href.match(/vandalism=2/)) {
                        document.getElementById('wpSummary').value = 'Revocacion de vandalisme per [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] ; retorn a la version de [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']] ('+_GET['messatge']+')';
                                document.getElementById('editform').submit();
                                } else if (location.href.match(/warn=1/)) {
                                document.getElementById('wpSummary').value = 'Avertiment';
                                document.getElementById('wpTextbox1').value = '{{sub'+'st:tèst0}} ~~'+'~~';
                                document.getElementById('editform').submit();
                                } else if (location.href.match(/warn=2/)) {
                                document.getElementById('wpSummary').value = 'Avertiment';
                                document.getElementById('wpTextbox1').value = '{{sub'+'st:tèst1}} ~~'+'~~';
                                document.getElementById('editform').submit();
                                } else if (location.href.match(/warn=3/)) {
                                document.getElementById('wpSummary').value = 'Avertiment';
                                document.getElementById('wpTextbox1').value = '{{sub'+'st:tèst2}} ~~'+'~~';
                                document.getElementById('editform').submit();
                                } else if (location.href.match(/warn=4/)) {
                                document.getElementById('wpSummary').value = 'Avertiment';
                                document.getElementById('wpTextbox1').value = '{{sub'+'st:tèst3}} ~~'+'~~';
                                document.getElementById('editform').submit();
                                }
                                });