User:Kangaroopower/rollbacks.js

/* Customm Rollbacks and Ajax Rollback- Moncho and Grunny*/ $(document).ready(function {         var Buttons = [{                text: 'spam',                summary: 'Reverted spam',        }, {                text: 'vandalism',                summary: 'Reverted vandalism',        }];        var list = document.getElementsByTagName('span');        for(i in list) {                if(list[i].className == 'mw-rollback-link') {                        var link = list[i];                        var rollback = link.innerHTML;                        for(j in Buttons) {                                var customlink = document.createElement('span'),                                a3 = customlink.getElementsByTagName('a')[0];                                customlink.innerHTML = rollback;                                customlink.className = 'customrollback';                                 var a3 = customlink.getElementsByTagName('a')[0] a3.href += '&summary=' + Buttons[j].summary; a3.innerHTML = Buttons[j].text; if(urlQuery('action') == 'history') { link.parentNode.insertBefore(customlink, link.nextSibling); customlink.outerHTML = ' | ' + customlink.outerHTML; } else { link.parentNode.appendChild(customlink); customlink.outerHTML = ' ' + customlink.outerHTML }                       }                }        }        for(i in list) { if(list[i].className == 'customrollback') { list[i].className = 'mw-rollback-link'; }       } } addOnloadHook(CustomRollbacks); /* Fix Monobook error*/ function urlQuery(quer) { for(i in location.href.split('?')) { for(j in location.href.split('?')[i].split('&')) { if(location.href.split('?')[i].split('&')[j].split('=')[0] == quer) { return location.href.split('?')[i].split('&')[j].split('=')[1]; }		}	}	return undefined; }

$('.mw-rollback-link').click(function(e) {		e.preventDefault;		var $rblink = $(this);		var href = this.getElementsByTagName('a')[0].href;		this.innerHTML = ' ';		$.ajax({ url: href, success: function { $rblink.text(function (i, val) {return val + ' [success]';}); loadPageData; },			error: function { $rblink.text(function (i, val) {return val + ' [failed]';}); loadPageData; }		});	}); });