User:Voice of All/Revert/monobook.js

//

//////AOL RANGES//////// //main ranges; rapidly changing var AOL_RANGES = /^(64\.12\.|149\.174|152\.163\.|195\.93\.[0-9]\d{0,1}\.|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\.[7-9][0-9]\.|202\.67\.1[01]|202\.67\.12[0-7]|205\.188\.|207\.200\.6[4-9]\.|207\.200\.[7-9][0-9]\.|207\.200\.1[01]|207\.200\.12[0-7])/; //all ranges var AOL_RANGES_ALL = /^(64\.12\.|149\.174|152\.163\.|195\.93\.[0-9]\d{0,1}\.|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\.[7-9][0-9]\.|202\.67\.1[01]|202\.67\.12[0-7]|205\.188\.|207\.200\.6[4-9]\.|207\.200\.[7-9][0-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&jsaction=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("&jsaction=autorevertnorm&byuser=" + user_name) != -1 || location.href.indexOf("&jsaction=autorevertvandal&byuser=" + user_name) != -1 || location.href.indexOf("&jsaction=autorevertnice&byuser=" + user_name) != -1) { if (location.href.indexOf('&revertfromuser') == -1 && location.href.indexOf('&jsaction=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]; document.getElementById('wpMinoredit').checked=true; if (location.href.indexOf('&jsaction=autorevertvandal') != -1) {   document.getElementById('bodyContent').setAttribute("visibility", "hidden"); var artname = document.title.split('Editing ')[1].split(' - ')[0]; var vandal = unescape(location.href.split('&revertfromuser=')[1]); document.editform.wpSummary.value = vreverted.replace(/\$2/g,vandal).replace(/\$1/g,good_user); 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=' + escape(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('&jsaction=autorevertnorm&byuser=') != -1) {   document.getElementById('bodyContent').setAttribute("visibility", "hidden"); var vandal = unescape(location.href.split('&revertfromuser=')[1]); document.editform.wpSummary.value = nreverted.replace(/\$2/g,vandal).replace(/\$1/g,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 if (location.href.indexOf('&jsaction=autorevertnice&byuser=') != -1) {   document.getElementById('bodyContent').setAttribute("visibility", "hidden"); var vandal = unescape(location.href.split('&revertfromuser=')[1]); document.editform.wpSummary.value = preverted.replace(/\$2/g,vandal); 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=' + escape(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('&action=edit&jsaction=autorevert&byuser=') != -1) { 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