User:KyraVixen/monobook.js

//Interiot's javascript edit counter if (document.title.indexOf('User:Interiot/Tool2/code.js') != -1) { mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Interiot/Tool2/code.js&action=raw&ctype=text/javascript'); }

//if(document.URL.indexOf("/w/index.php?title=Special:Watchlist&") == -1) //{ //Allow loading of other js scripts function loadJS(s) { s = s.replace(/^\[\[/, ).replace(/\]\]$/, ).replace(" ", "_"); document.write(' '); }

loadJS('User:GeorgeMoney/UserScripts/RemExternalLinks'); //External link killer loadJS('User:GeorgeMoney/UserScripts/hacks/FilterLinksearchMainspace'); //filter

//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'); 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

$(IEhistory_revert) function IEhistory_revert { if (location.href.indexOf('&action=history&limit=8&fakeaction=IEnormalrevert&user=') != -1) {  var found = 0; var user_name = document.getElementById('pt-userpage').getElementsByTagName('a')[0].innerHTML; if (unescape(location.href.split('&byuser=')[1]) != user_name){alert('Invalid user match'); return;} var vandal = unescape(location.href.split('&fakeaction=IEnormalrevert&user=')[1].split('&byuser=')[0]); var l = document.getElementsByTagName('li'); if (l[0].getElementsByTagName('a')[2].innerHTML != vandal) {alert('Could not rollback. Last contributor has changed.'); return;} for (i = 1; i < l.length; i++) {    if (!l[i].getElementsByTagName('a')[3]){alert('Could not find a version of this page that is not by the user you attempted to rollback from.' + '\n' + 'Most likely, the user is the only author of the page.' + '\n' + 'This revert function only looks at the last 6 page edits, so you may want to look back further and use "restore".'); history.go(-1); return;} if (l[i].getElementsByTagName('a')[3].innerHTML != vandal) {    var good_user = l[i].getElementsByTagName('a')[3].innerHTML; var URL = l[i].getElementsByTagName('a')[2].href + "&action=edit&fakeaction=autorevert&byuser=" + escape(user_name) + "&oldrvtouser=" + escape(good_user) + "&revertfromuser=" + escape(vandal); location.href = URL; found = 1; break; }     }   if (found == 0) {alert('Could not find a version of this page that is not by the user you attempted to rollback from.' + '\n' + 'Most likely, the user is the only author of the page.' + '\n' + 'This revert function only looks at the last 6 page edits, so you may want to look back further and use "restore".'); history.go(-1);} } if (location.href.indexOf('&action=history&limit=8&fakeaction=IErollback&vandal=') != -1) {  var found = 0; var user_name = document.getElementById('pt-userpage').getElementsByTagName('a')[0].innerHTML; if (unescape(location.href.split('&byuser=')[1]) != user_name){alert('Invalid user match'); return;} var vandal = unescape(location.href.split('&fakeaction=IErollback&vandal=')[1].split('&byuser=')[0]); var l = document.getElementsByTagName('li'); if (l[0].getElementsByTagName('a')[2].innerHTML != vandal) {alert('Could not rollback vandal. Last contributor has changed.'); return;} for (i = 1; i < l.length; i++) {    if (!l[i].getElementsByTagName('a')[3]){alert('Could not find a version of this page that is not by the user you attempted to rollback from.' + '\n' + 'Most likely, the user is the only author of the page.' + '\n' + 'This revert function only looks at the last 6 page edits, so you may want to look back further and use "restore".'); history.go(-1); return;} if (l[i].getElementsByTagName('a')[3].innerHTML != vandal) {    var good_user = l[i].getElementsByTagName('a')[3].innerHTML; var URL = l[i].getElementsByTagName('a')[2].href + "&action=edit&fakeaction=autorevertvandal&byuser=" + escape(user_name) + "&oldrvtouser=" + escape(good_user) + "&revertfromuser=" + escape(vandal); location.href = URL; found = 1; break; }     }   if (found == 0) {alert('Could not find a version of this page that is not by the user you attempted to rollback from.' + '\n' + 'Most likely, the user is the only author of the page.' + '\n' + 'This revert function only looks at the last 6 page edits, so you may want to look back further and use "restore".'); history.go(-1);} } } //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 return_value = true; 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 += 'Reverted vandalism by ' + vandal + ' to last version by ' + good_user + '.'; var form = document.getElementById('editform'); window.open('http://en.wikipedia.org/w/index.php?title=User talk:' + vandal + '&action=edit' + '&action=edit&vanarticle=' + artname,             'targetname',    'location=no,toolbar=no,status=no,directories=no,scrollbars=yes,width=1024,height=768'); form.submit; } else if (location.href.indexOf('&revertfromuser=') != -1) { var vandal = unescape(location.href.split('&revertfromuser=')[1]); document.editform.wpSummary.value += 'Reverted edits by ' + vandal + ' to last version by ' + good_user + '.'; var form = document.getElementById('editform'); form.submit; } else { document.editform.wpSummary.value += 'Revert to revision ' + ID + ' by ' + good_user + '.'; var form = document.getElementById('editform'); form.submit; }   } } //END

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