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.
//<pre><nowiki>
//---------------------------------------------------------------
// =-=-=- HELPER FUNCTIONS -=-=-=

function addlilink(tabs, url, name, id, title, key){
    var na = document.createElement('a');
    na.href = url;
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    if(id) li.id = id;
    li.appendChild(na);
    tabs.appendChild(li);
    if(id)
    {
        if(key && title)
        {
            ta[id] = [key, title];
        }
        else if(key)
        {
            ta[id] = [key, ''];
        }
        else if(title)
        {
            ta[id] = ['', title];
        }
    }
    // re-render the title and accesskeys from existing code in wikibits.js
    akeytt();
    return li;
}

function addToolboxLink(url, name, id){
    var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0];
    addlilink(tb, url, name, id);
}

function addTab(url, name, id, title, key){
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
    return addlilink(tabs, url, name, id, title, key);
}

function addLink(where, url, name, id, title, key, after){
    var na = document.createElement('a');
    na.href = url;
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    if(id) li.id = id;
    li.appendChild(na);
    var tabs = document.getElementById(where).getElementsByTagName('ul')[0];
    if(after) {
	tabs.insertBefore(li,document.getElementById(after));
    } else {
	tabs.appendChild(li);
    }
    if(id) {
	if(key && title) { ta[id] = [key, title]; }
	else if(key) { ta[id] = [key, '']; }
	else if(title) { ta[id] = ['', title];} 
    }
    // re-render the title and accesskeys from existing code in wikibits.js
    akeytt();
    return li;
}
function URLEncoding(input)
      {
        var encodedInputString=escape(input);     
        var outputurl=encodedInputString;
        return outputurl;
      }
//Auto-replace
function autoreplacetxt(what,withw)
{
var undefined;
i = 1;
var original = document.editform.wpTextbox1.value;
if (what == ''){alert("Invalid command."); return;}
else if (what == 'null'){alert("Action cancelled."); return;}
else {
if (withw == ''){alert("All such appearances of text will be removed.");}
else if (withw.split(what)[1] != undefined) {alert("Action cancelled to avoid infinite loop."); return;}
else {
if (document.editform.wpTextbox1.value.split(what)[1] != undefined)
 {
  while (i == 1)
  {
  document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(what, withw);
  if (document.editform.wpTextbox1.value.split(what)[1] != undefined)
  {i = 1;}
  else
  {i = -1;}
  }
 }
//document.editform.wpSummary.value += 'JS: Replacing text "' + what + '" with "' + withw + '" ';
  }
 }
}
//END
//---------------------------------------------------------------
////////////////////////////////////////////////////////////////
//*****************************************************
//PROTECTION JS
//*****************************************************
//*****************************************************
//This is for if people skrew with the WP:PP page layout
  var movesec = 7;
  var artfull = 10;
  var artsemi = 11;
  var otherpro = 13;
  var userfull = 16;  
  var usersemi = 17;
  var regtalk = 18;  
  var anontalk = 19;
//End of WP:PP constants
//*****************************************************
//*****************************************************
//Category update
function addcatupdate()
{
  var undefined;
  var c1 = document.getElementById('column-one');
  var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0];
  if (location.href.indexOf('Category:Protected against vandalism') != -1) 
      { 
    addTab("javascript:updatepcat()", "{{Update WP:PP}}", "ca-wppup", "Update article WP:PP listings", "");
      }
  else if (location.href.indexOf('Category:Semi-protected') != -1) 
      { 
    addTab("javascript:updatepcat()", "{{Update WP:PP}}", "ca-wppup", "Update article WP:PP listings", "");
      }
  else if (location.href.indexOf('Category:Protected') != -1) 
      { 
    addTab("javascript:updatepcat()", "{{Update WP:PP}}", "ca-wppup", "Update article WP:PP listings", "");
      }
}
//END

function updatepcat()
{
var k = 0;
var thescript = '';
var undefined;
if (document.title.indexOf('Category:Semi-protected') == -1 && document.title.indexOf('Category:Protected') == -1)
  {
  return;
  }
if (document.title.indexOf('Category:Semi-protected') != -1 || document.title.indexOf('Category:Protected') != -1)
  {
  var l = document.getElementById('bodyContent').getElementsByTagName('a');
  if (document.title.indexOf('Category:Semi-protected') != -1) {var value = 'S';}
  else if (document.title.indexOf('Category:Protected') != -1) {var value = 'P';} 
    for (i = 0; i < l.length; i++) 
         {
    var Name = l[i].innerHTML;
    if (l[i].title.split(':')[1] != undefined || l[i].href.split('a:')[1] != undefined || l[i].href.split('g:')[1] != undefined || l[i].href.split('i:')[1] != undefined || l[i].href.split('e:')[1] != undefined || l[i].href.split('y:')[1] != undefined || Name.indexOf(':') != -1 || Name.indexOf('rotected') != -1 || Name.indexOf('search') != -1 || Name.indexOf('navigation') != -1 || Name.indexOf('rotection') != -1 || Name.indexOf('#') != -1){update = 'no';}
    else {k = k + 1; thescript += 'Z' + k + 'X' + Name;}
         }
    if (value == 'S')
         {
    var z = k + 1;
    thescript += 'Z' + z + 'X';
    thescript = URLEncoding(thescript);
location.href = 'http://en.wikipedia.org/w/index.php?title=Wikipedia:List_of_protected_pages&action=edit&section=' + artsemi + '&fakeaction=Sjslist&faketarget=' + thescript;
         }
    else if (value == 'P')
         {
    var z = k + 1;
    thescript += 'Z' + z + 'X';
    thescript = URLEncoding(thescript);
location.href = 'http://en.wikipedia.org/w/index.php?title=Wikipedia:List_of_protected_pages&action=edit&section=' + artfull + '&fakeaction=Pjslist&faketarget=' + thescript;
         }
   }
}

function pautolistcheck()
{
if (location.href.indexOf('faketarget') != -1)
 {
      var undefined;
      var action = '';
      var target = '';
      if (location.search)
        {
          var l = location.search.substring(1).split('&');
          for (var i = 0; i < l.length; ++i)
            {
              var eq = l[i].indexOf('=');
              var name = l[i].substring(0, eq);
              if (name == 'fakeaction')
                action = l[i].substring(eq + 1);
              else if (name == 'faketarget')
                target = unescape(location.href.split('&faketarget=')[1]);
            }
        }
      if (action != 'Pjslist' && action != 'Sjslist')
        {
        return;
        }
      if (action == 'Pjslist' || action == 'Sjslist')
        {
            if (action == 'Pjslist'){var type = 'F';}
            else if (action == 'Sjslist'){var type = 'S';}
            var z = 0;
            var pages_notlisted = '';
            var original = document.editform.wpTextbox1.value;
            var f = document.editform, t = f.wpTextbox1;
            f.wpSummary.value += 'JS: Adding pages not listed:';  
            for (i = 0; i < 250; i++) 
            {
               if (target.split('Z' + i + 'X')[1] != undefined)
               {
               var j = 1*(i + 1);
               var before = 'Z' + i + 'X';
               var after = 'Z' + j + 'X';
               if (target.split(before)[1].split(after)[0] != undefined)
                  {
                 var page_name = target.split(before)[1].split(after)[0];
                 var page_check = page_name + '}}';
                 var page_check_full = '|' + page_name + '}}';
                 var page_length = page_check.length;
                 var page_capsornot = page_check.substring(2,page_length);
                 if (original.indexOf(page_capsornot) == -1 && page_name.length >= 10)
                {z = z + 1; pages_notlisted += '|' + page_name;}
                 if (original.indexOf(page_check_full) == -1 && page_name.length < 10)
                {z = z + 1; pages_notlisted += '|' + page_name;}
                 if (z > 10){alert("Max number of articles found per instance (10). Please run again to list the rest"); break;}
                  }
               }
               else
               {
               var error = 'yes'; 
               }
            } 
  if (pages_notlisted == '')
  {alert('No entries added, the list is currently up to date'); window.back(); return;}
    pages_notlisted += '|';
   alert('Pages not listed on WP:PP:' + '\n' + pages_notlisted);
       pages_notlisted = URLEncoding(pages_notlisted);
  window.open('http://en.wikipedia.org/w/index.php?title=Special:Log&type=protect&limit=5000' + '&fakeaction=' + type + 'sumfind&faketarget=' + pages_notlisted,
    'location=no,toolbar=no,status=no,directories=no,scrollbars=yes');
     window.back();
        }
    }
}
//END

function plistsumfind()
{
if (location.href.indexOf('faketarget') != -1)
 {
      var undefined;
      var action = '';
      var target = '';
      if (location.search)
        {
          var l = location.search.substring(1).split('&');
          for (var i = 0; i < l.length; ++i)
            {
              var eq = l[i].indexOf('=');
              var name = l[i].substring(0, eq);
              if (name == 'fakeaction')
                action = l[i].substring(eq + 1);
              else if (name == 'faketarget')
                target = unescape(location.href.split('&faketarget=')[1]);
            }
        }
    if (action == 'Fsumfind' || action == 'Ssumfind')
     {
      if (action == 'Fsumfind'){var type = artfull; var categ = 'F';}
      else if (action == 'Ssumfind'){var type = artsemi; var categ = 'S';}
      var Txt = '';  
      var Txtforshow = '';
      var Summary = '';
      var Username = '';
      var Namelist = '';
      l = document.getElementById('bodyContent').getElementsByTagName('li');
      for (i = 0; i < l.length; i++) 
        {
        if (l[i].innerHTML.indexOf(' protected ') != -1)
           {
            var a_location = l[i].getElementsByTagName('a')[1].innerHTML;
            if (target.indexOf('|' + a_location + '|') != -1)
              {
           Username = l[i].getElementsByTagName('a')[0].innerHTML;
           Summary = l[i].getElementsByTagName('span')[0].innerHTML.split('(')[1].split(' [')[0].split('[')[0];
           var Name = a_location;
           var Date = l[i].innerHTML.split(' protected ')[0].split(' <a href')[0].substring(7); 
                if (Namelist.indexOf(Name) != -1){var add = 'no';}
                else
                   {
           Txtforshow += '\n' + '*{{article|' + Name + '}}. ' + Summary + '. ' + Username + ' -- ' + Date; Namelist += Name;
           Txt += '\n' + 'X{X' + Name + '}}. ' + Summary + 'X}X' + Username + '|' + Username + ']] ' + ' -- ' + Date; Namelist += Name;
                   }
              }
           }
        }
//END of FOR loop
if (Txtforshow == ''){Txtforshow = '(none found in the log)'; window.close();}
alert('The following will be added to WP:PP:' + '\n' + Txtforshow);
Txt = URLEncoding(Txt);
location.href = 'http://en.wikipedia.org/w/index.php?title=Wikipedia:List_of_protected_pages&action=edit&section=' + type + '&fakeaction=' + categ + 'addtext&faketarget=' + Txt;
     }
  }
}

function addptext()
{
if (location.href.indexOf('faketarget') != -1)
 {
      var categ = 'category page';
      var undefined;
      var action = '';
      var target = '';
      if (location.search)
        {
          var l = location.search.substring(1).split('&');
          for (var i = 0; i < l.length; ++i)
            {
              var eq = l[i].indexOf('=');
              var name = l[i].substring(0, eq);
              if (name == 'fakeaction')
                action = l[i].substring(eq + 1);
              else if (name == 'faketarget')
                target = unescape(location.href.split('&faketarget=')[1]);
            }
        }
    if (action != 'Saddtext' && action != 'Faddtext')
     {
     return;
     }
    else
     {
    if (action == 'Saddtext'){categ = '[[Category:Semi-protected]]';}
    else if (action == 'Faddtext'){categ = '[[Category:Protected]]';}
    var f = document.editform, t = f.wpTextbox1;
    if (target == ''){window.close();}
    t.value += "\r" + target;
    autoreplacetxt('X{X','*{{article|');
    autoreplacetxt('X}X',' - [[User:');
    f.wpSummary.value += "JS: Updating protected pages from " + categ + ".";
  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;}
    }
     }
  }
}
//END

$(automain)
function automain()
{
addcatupdate()
pautolistcheck()
addptext()
plistsumfind()
}
//</nowiki></pre>