User:CWii/approvescript.js

Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
//Approve script
function templateOK() {
  if (document.editform) {
	text = document.editform.wpTextbox1.value;
	text = text.replace (/\{\{JB2-Moved[^}]*\}\}/g, " ");
	text = text.replace (/\{\{[Bb]otMoveToCommons[^}]*\}\}/g, " ");
    document.editform.wpTextbox1.value = text;
    document.editform.wpSummary.value = "Removing Review image template(s) as image has been reviewed";
    document.editform.submit();
  } else
    document.location = mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=" + wgPageName + "&action=edit&templateOK=1";
}
function addTemplateOK(){
  if (wgCanonicalNamespace == "File")
    mw.util.addPortletLink("p-cactions", "javascript:templateOK()", "BotOK", "");
  if (document.location.href.indexOf("templateOK=1") > 0)
    templateOK();
}
addOnloadHook(addTemplateOK);

//Approve script
function catOK() {
  if (document.editform) {
	text = document.editform.wpTextbox1.value;
	text = text.replace (/\{\{[Uu]nc[^}]*\}\}/g, " ");
	//text = text.replace (/\{\{[Bb]otMoveToCommons[^}]*\}\}/g, " ");
    document.editform.wpTextbox1.value = text;
    document.editform.wpSummary.value = "Removing Review image template(s) as image has been reviewed";
    document.editform.submit();
  } else
    document.location = mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=" + wgPageName + "&action=edit&catOK=1";
}
function addCatOK(){
  if (wgCanonicalNamespace == "File")
    mw.util.addPortletLink("p-cactions", "javascript:catOK()", "CatOK", "");
  if (document.location.href.indexOf("catOK=1") > 0)
    catOK();
}
addOnloadHook(addCatOK);