Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* extra rollback links */
- function CustomRollbacks() {
- var Buttons = [{ //Your buttons go here. You can copy and paste this to make more than three
- text: 'spam',
- title: 'Revert spam',
- summary: '[[Help:Spam|spam]]'
- }, {
- text: 'vandalism',
- title: 'Revert vandalism',
- summary: '[[Help:Vandalism|vandalism]]'
- }, {
- text: 'null',
- title: 'Revert with no summary',
- summary: ' ' //This one has no summary
- }];
- 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');
- customlink.innerHTML = rollback;
- customlink.className = 'customrollback'; //we do this to avoid an infinite loop, because when we insert a <span> into the DOM, the list variable includes it
- customlink.getElementsByTagName('a')[0].title = Buttons[j].title;
- customlink.getElementsByTagName('a')[0].href += '&summary=' + Buttons[j].summary;
- customlink.getElementsByTagName('a')[0].innerHTML = Buttons[j].text;
- if(wgPageName == 'Special:RecentChanges' || wgPageName == 'Special:Contributions') {
- link.parentElement.appendChild(customlink);
- customlink.outerHTML = ' ' + customlink.outerHTML;
- }
- else { //assumes you're on history
- link.parentElement.insertBefore(customlink, link.nextSibling);
- customlink.outerHTML = ' | ' + customlink.outerHTML;
- }
- }
- }
- }
- for(i in list) { //why another one of these? we're fixing the class that we set to avoid an infinite loop
- if(list[i].className == 'customrollback') {
- list[i].className = 'mw-rollback-link';
- }
- }
- }
- addOnloadHook(CustomRollbacks);
Advertisement
Add Comment
Please, Sign In to add comment