User:Crazytales56297/monobook.js

From Wikipedia, the free encyclopedia

Note: After saving, you have to bypass your browser's cache to see the changes. Mozilla/Safari: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Internet Explorer: press Ctrl-F5, Opera/Konqueror: press F5.

// Script from [[User:ais523/editcount.js]]
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:ais523/editcount.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
//<nowiki> Admin-like RC Patrol tools

document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:VoA/monobook.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

//</nowiki>[[Category:Wikipedians who use RC script ]]
// Script from [[User:Lupin/recent2.js]]
//document.write('<script type="text/javascript" src="' 
//             + 'http://en.wikipedia.org/w/index.php?title=User:Lupin/recent2.js' 
//             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
// [[User:Lupin/popups.js]]

document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

//Back-up edit counter
//Visit [[User:Interiot/Tool2/code.js]] in emergencies!
document.write('<script type="text/javascript" src="' 
    + 'http://en.wikipedia.org/w/index.php?title=User:Interiot/Tool2/code.js' 
    + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
//Conflicts with force edit summary script!

var scIndex = 0;
var scKeys = new Array();
var scValues = new Array();

function scFormSubmit() {
   var i=0
   var textArea = document.getElementById("wpTextbox1");
   var text = textArea.value;
   while (i<scIndex) {
      text = text.replace(scKeys[i], scValues[i]);
      ++i;
   }
   textArea.value = text;
}

addOnloadHook(function() {
   if (document.title.indexOf("Editing ") != 0) {return;}
   document.getElementById("wpSave").onclick = scFormSubmit;
   document.getElementById("wpPreview").onclick = scFormSubmit;
   document.getElementById("wpDiff").onclick = scFormSubmit;
   //TODO: make it work with previews too!
});


addOnloadHook(function() {
   if (document.title.indexOf("Editing ") != 0) {return;}
   var textArea = document.getElementById("wpTextbox1");
   var text = textArea.value;
   var re = /<!--\[\[User:Where\/sigContract\]\];(.*)-->.*<!--ESC:(.*)-->/g;
   var lastIndex = 0;
/*   while (1) {
      var textSubstr = text.substr(lastIndex);
      alert(lastIndex);
      alert(textSubstr); //TODO: remove
      var newIndex = textSubstr.search(re);
      alert("newindex:" + newIndex);
      if (newIndex == -1) {
	 break;
      }
      lastIndex += newIndex+1;*/
      text = text.replace(re,
	 function(str, p1, p2, offset, s) {
//	    alert("In replacement function");
	    if (p1 == p2) {
	       var newString = "-[[User:" + p1 + "|" + p1 + "]]";
	       scKeys[scIndex] = newString;
	       scValues[scIndex] = str;
	       ++scIndex;
	       return newString;
	    }
	    else {
	       return str;
	    }
	 });
   //}
   textArea.value = text;
});