User:Kevin B12/revert/monobook.js

//

//AOL RANGES var AOL_RANGES = /64\.12\.|149\.174|152\.163\.|195\.93\.[0-9]\.|195\.93\.[0-9][0-9]\.|195\.93\.1[0-1][0-9]\.|195\.93\.12[0-7]\.|198\.81\.[0-9]\.|198\.81\.[1-2][0-9]\.|198\.81\.3[01]\.|202\.67\.6[4-9]\.|202\.67\.1[01]|202\.67\.12[0-7]|205\.188\.|207\.200\.6[4-9]\.|207\.200\.1[01]|207\.200\.12[0-7]|172\.12[0-8]|172\.1[3-9][0-9]|172\.20[0-9]|172\.21[0-6]/; //

//Edit and "revert to" JS //addOnloadHook(adddifflinks) function adddifflinks { var editlink = ' [ edit this version ] '; var rvname = ' [ restore this revision ] '; var user_name = document.getElementById('pt-userpage').getElementsByTagName('a')[0].innerHTML; if (location.href.indexOf('diff=') != -1 && location.href.indexOf('&oldid=') != -1) { var doctd = document.getElementById('bodyContent').getElementsByTagName('td'); if (!doctd[0]){return;} var good_user = doctd[0].getElementsByTagName('a')[2].innerHTML; var link = doctd[0].getElementsByTagName('a')[0].href.replace('&amp;','&') + "&action=edit"; var rvlink = doctd[0].getElementsByTagName('a')[0].href.replace('&amp;','&') + "&action=edit&fakeaction=autorevert&byuser=" + escape(user_name) + "&oldrvtouser=" + escape(good_user); document.getElementById('bodyContent').getElementsByTagName('td')[0].innerHTML = '' + rvname + '' + document.getElementById('bodyContent').getElementsByTagName('td')[0].innerHTML; } } //END

function autosave { user_name = escape(document.getElementById('pt-userpage').getElementsByTagName('a')[0].innerHTML); if (location.href.indexOf("&fakeaction=autorevert&byuser=" + user_name) != -1 || location.href.indexOf("&fakeaction=autorevertvandal&byuser=" + user_name) != -1) { if (location.href.indexOf('&revertfromuser') == -1 && location.href.indexOf('&fakeaction=autorevertvandal') == -1) { var message = "Are you sure you want to revert to this revision?"; var return_value = confirm(message); if (return_value != true){history.go(-1); return;} } var good_user = unescape(location.href.split("&oldrvtouser=")[1].split('&revertfromuser=')[0]); var ID = location.href.split("&oldid=")[1].split("&action=edit")[0]; form = document.getElementById('bodyContent'); l = form.getElementsByTagName('input'); for (i = 0; i < l.length; i++) {   if (l[i].name == 'wpMinoredit') {l[i].value = '1'; l[i].checked=true;} } if (location.href.indexOf('&fakeaction=autorevertvandal') != -1) {   var artname = document.title.split('Editing ')[1].split(' - ')[0]; var vandal = unescape(location.href.split('&revertfromuser=')[1]); document.editform.wpSummary.value = 'JS: Reverted vandalism by ' + vandal + ' to last version by ' + good_user + '. Please do not compromise the integrity of pages.'; var AOL = 1; if (vandal.search(AOL_RANGES) == -1) {     AOL = 0; window.open('http://en.wikipedia.org/w/index.php?title=User talk:' + vandal + '&action=edit' + '&action=edit&vanarticle=' + artname,'vandalwarn','location=no,toolbar=no,status=no,directories=no,scrollbars=yes,width=1024,height=768'); }  document.getElementById('editform').submit; if (AOL == 0) {  document.getElementById('bodyContent').innerHTML = ' Page rollback status: Getting article history ... done Page rollback status: Retrieving page revision ... done Page rollback status: Opening user talk page ...  Page rollback status: Submitting form ... ';          }   else {  document.getElementById('bodyContent').innerHTML = ' Page rollback status: Getting article history ... done Page rollback status: Retrieving page revision ... done Page rollback status: NOT opening user talk page (AOL IP)...  Page rollback status: Submitting form ... ';          }        } else if (location.href.indexOf('&revertfromuser=') != -1) {   var vandal = unescape(location.href.split('&revertfromuser=')[1]); document.editform.wpSummary.value = 'JS: Reverted edits by ' + vandal + ' to last version by ' + good_user + '.'; document.getElementById('editform').submit; document.getElementById('bodyContent').innerHTML = ' Page rollback status: Getting article history ... done Page rollback status: Retrieving page revision ... done Page rollback status: Submitting form ... ';      } else { document.editform.wpSummary.value = 'JS: Revert to revision ' + ID + ' by ' + good_user + '.'; var form = document.getElementById('editform'); form.submit; }   } } //END

//Revert options addOnloadHook(NArevertfunctions) function NArevertfunctions { adddifflinks; autosave; } //END