Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
function bagApprove() {
  var approvetext = prompt("Enter an optional comment");
  if (approvetext == null)
    var approvetext == '';
  else
    var approvetext == approvetext + ' ';
  document.editform.wpTextbox1.value = '{' + '{' + 'subst' + ':BT|Approved' + '}' + '}' + '<br' + ' />' + document.editform.wpTextbox1.value + ':' + '{' + '{' + 'BotApproved' + '}' + '} ' + approvetext + 'Good Luck.' + ' ~' + '~' + '~' + '~' + '<br' + ' />' + '{' + '{' + 'subst' + ':BB' + '}' + '}';
  document.editform.wpSummary.value = 'Approved';
  document.editform.wpMinoredit.checked = false;
}

function bagDeny() {
  var denytext = prompt("Enter an optional comment");
  if (denytext == null)
    var denytext == '';
  else
    var denytext == denytext + ' ';
  document.editform.wpTextbox1.value = '{' + '{' + 'subst' + ':BT|Denied' + '}' + '}' + '<br' + ' />' + document.editform.wpTextbox1.value + ':' + '{' + '{' + 'BotDenied' + '}' + '} ' + denytext + ' ~' + '~' + '~' + '~' + '<br' + ' />' + '{' + '{' + 'subst' + ':BB' + '}' + '}';
  document.editform.wpSummary.value = 'Denied';
  document.editform.wpMinoredit.checked = false;
}


function bagExpire() {
  var expiretext = prompt("Enter an optional comment");
  if (expiretext == null)
    var expiretext == '';
  else
    var expiretext == expiretext + ' ';
  document.editform.wpTextbox1.value = '{' + '{' + 'subst' + ':BT|Expired' + '}' + '}' + '<br' + ' />' + document.editform.wpTextbox1.value + ':' + '{' + '{' + 'BotExpired' + '}' + '} ' + expiretext + ' ~' + '~' + '~' + '~' + '<br' + ' />' + '{' + '{' + 'subst' + ':BB' + '}' + '}';
  document.editform.wpSummary.value = 'Expired';
  document.editform.wpMinoredit.checked = false;
}

addOnloadHook(function() {
  if (document.editform) {
     addPortletLink("p-cactions", "javascript:bagExpire()", "expire", "ca-expire", "Expire this request", "");
     addPortletLink("p-cactions", "javascript:bagApprove()", "approve", "ca-approve", "Approve this request", "");
     addPortletLink("p-cactions", "javascript:bagDeny()", "deny", "ca-deny", "Deny this request", "");
  }
});