User:John254/AFD closure for secure server/monobook.js

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.
//<nowiki>
function createCookie(name, value, days)
{
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
    }
  else var expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
  var ca = document.cookie.split(';');
  var nameEQ = name + "=";
  for(var i=0; i < ca.length; i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1, c.length); //delete spaces
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
  return null;
}

function eraseCookie(name)
{
  createCookie(name, "", -1);
}
 
function encode(text)
{
  var processed = new String();
  var i;
  for(i = 0; i < text.length; i++)
  {
    if(text[i] == ";")
    {
      processed = processed + "es";
    }
    else
    {
      if(text[i] == "e")
      {
        processed += "ee"
      }
      else
      {
        processed += text[i];
      }
    }
  }
  return processed;
}

function decode(text)
{
  var processed = new String();
  var i;
  for(i = 0; i < text.length; i++)
  {
    if(text[i] == "e")
    {
      i++;
      if(text[i] == "s")
      {
        processed = processed + ";";
        continue;
      }
    }
    processed += text[i];
  }
  return processed;
}

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

$(function()
{
  if (document.title.indexOf("Editing ") != -1)
  {
    if (document.URL.lastIndexOf("&fakeaction=huff") == -1)
      return;
    if (document.URL.lastIndexOf("&reason=keep") != -1)
    {
      var f = document.editform, t = f.wpTextbox1;
      var matchstring = "{{REMOVE THIS TEMPLATE WHEN CLOSING THIS AfD";
      var i;
      var j;
      var k;
      var m;
      var n;
      var found;
      var disctitle = new String();
      var articletitle = new String();
      var len = t.value.length;
      var closingstatement = decode(readCookie("closingstatement"));
      for (i = 0; i < (len - (matchstring.length + 4)); i++)
      {
        found = true;
        m = 0;
        for(j = i; j < i + matchstring.length; j++)
        {
          if(t.value[j] != matchstring[m])
          {
            found = false;
            break;
          }
          m++;
        }
        if(found)
        {
          n = 0;
          for(k = j; k < len; k++)
          {
            if(t.value[k] == "}")
            {
              n++;
            }
            if(n > 1)
            {
               break;
            }
          }
          t.value = excisestring(t.value, i, k);
          break;
        }
      }
      if(closingstatement == "no reason given")
      {
        t.value = "{" + "{subst:afd top}}" + " '''keep'''. " + "~" + "~" + "~" + "~" + "\n\n" + t.value + "{" + "{subst:afd bottom}}";
      }
      else
      {
        t.value = "{" + "{subst:afd top}}" + " '''keep'''. " + closingstatement + " ~" + "~" + "~" + "~" + "\n\n" + t.value + "{" + "{subst:afd bottom}}";
      }
      f.wpSummary.value = "JS: Closing AFD discussion as keep";

      matchstring = "{" + "{la|";
      for (i = 0; i < (len - matchstring.length); i++)
      {
        found = true;
        m = 0;
        for(j = i; j < i + matchstring.length; j++)
        {
          if(t.value[j] != matchstring[m])
          {
            found = false;
            break;
          }
          m++;
        }
        if(found)
        {
          n = 0;
          for(k = j; k < len; k++)
          {
            if(t.value[k] == "}")
            {
              n++;
            }
            if(n > 1)
            {
               break;
            }
          }
          for(j; j < (k - 1); j++)
          {
            articletitle += t.value[j];
          }
          break;
        }
      }
      disctitle = document.title.substr(8, document.title.lastIndexOf(' - Wikipedia, the free') - 8);   
      createCookie("discussion", encode(disctitle), 2);
      f.wpSave.click();
      createCookie("startdate", encode(prompt("Please enter the date on which the AFD discussion was opened")), 2);
      location.assign("/wikipedia/en/w/index.php?title=" + articletitle + "&action=edit&fakeaction=huff&reason=rmafd");
      return;
    }
  }
  if (window.location.href.search(/Special:|&action=/) != -1)
    return;
  if (document.title.indexOf("Wikipedia:Articles for deletion/") != -1)
  {
    addTab("javascript:keep(false)", "keep", "", "close AFD discussion as keep", "");
    addTab("javascript:keep(true)", "keep (reason)", "", "close AFD discussion as keep, prompt for a closing statement", "");
  }
  if(document.title.indexOf("Talk:") == -1 && 
    document.title.indexOf("User:") == -1 && document.title.indexOf("User talk:") == -1 &&
    document.title.indexOf("Wikipedia:") == -1 && document.title.indexOf("Wikipedia talk:") == -1 &&
    document.title.indexOf("Image:") == -1 && document.title.indexOf("Image talk:") == -1 && 
    document.title.indexOf("MediaWiki:") == -1 && document.title.indexOf("MediaWiki talk:") == -1 && 
    document.title.indexOf("Template:") == -1 && document.title.indexOf("Template talk:") == -1 && 
    document.title.indexOf("Help:") == -1 && document.title.indexOf("Help talk:") == -1 && 
    document.title.indexOf("Category:") == -1 && document.title.indexOf("Category talk:") == -1 && 
    document.title.indexOf("Portal:") == -1 && document.title.indexOf("Portal talk:") == -1)
  {
    addTab("javascript:rmafd()", "rmafd", "", "remove AFD notice", "");
  }
});
 
function keep(reason)
{
    //edit page
    var title = document.title.substr(0, document.title.lastIndexOf(' - Wikipedia, the free'));
    lastafd = title;
    location.assign("/wikipedia/en/w/index.php?title=" + title + "&action=edit&fakeaction=huff&reason=keep");
    if(reason)
    {
      createCookie("closingstatement", encode(prompt("Please enter a closing statement for the AFD discussion:")));
    }
    else
    {
      createCookie("closingstatement", encode("no reason given"));
    }
}  

function rmafd()
{
    //edit page
    var title = document.title.substr(0, document.title.lastIndexOf(' - Wikipedia, the free'));
    lastafd = title;
    location.assign("/wikipedia/en/w/index.php?title=" + title + "&action=edit&fakeaction=huff&reason=rmafd");
}

function excisestring(inputstring, startpoint, endpoint)
{
  var i = 0;
  var outputstring = new String();
  var len = inputstring.length;
  if(startpoint >= len || startpoint < 0 || endpoint < 0)
  {
     return inputstring;
  }
  for(i = 0; i < startpoint; i++)
  {
    outputstring += inputstring[i];
  }
  if(endpoint < (len - 1))
  {
    for(i = endpoint + 1; i < len; i++)
    {
       outputstring += inputstring[i];
    }
  }
  return outputstring;
}

$(function()
{
  if (document.title.indexOf("Editing ") != -1)
  {
    if (document.URL.lastIndexOf("&fakeaction=huff") == -1)
      return;
    if (document.URL.lastIndexOf("&reason=rmafd") != -1)
    {
      var f = document.editform, t = f.wpTextbox1;
      var lastafd = decode(readCookie("discussion"));
      if(t.value.indexOf("{{notability")!= -1 || t.value.indexOf("{{Notability")!= -1)
      {
        t.value = excisestring(t.value, t.value.indexOf("{{notability"), (t.value.slice(t.value.indexOf("{" + "{notability"), t.value.length)).indexOf("}}") + t.value.indexOf("{{notability") + 1);
        t.value = excisestring(t.value, t.value.indexOf("{{Notability"), (t.value.slice(t.value.indexOf("{{Notability"), t.value.length)).indexOf("}}") + t.value.indexOf("{{Notability") + 1);
        f.wpSummary.value = "JS: AFD closure as keep per " + "[[" + lastafd + "]], removing [[template:notability]] per AFD result";
      }
      else
      {
        f.wpSummary.value = "JS: AFD closure as keep per " + "[[" + lastafd + "]]";
      }
      t.value = excisestring(t.value, t.value.indexOf("{" + "{afd1}}"), t.value.indexOf("{" + "{afd1}}") + (("{" + "{afd1}}").length - 1));
      t.value = excisestring(t.value, t.value.indexOf("{{" + "afd}}"), t.value.indexOf("{{" + "afd}}") + (("{{" + "afd}}").length - 1));
      t.value = excisestring(t.value, t.value.indexOf("{{" + "AFD}}"), t.value.indexOf("{{" + "AFD}}") + (("{{" + "AFD}}").length - 1));
      t.value = excisestring(t.value, t.value.indexOf("{" + "{rescue}}"), t.value.indexOf("{" + "{rescue}}") + (("{" + "{rescue}}").length - 1));
      t.value = excisestring(t.value, t.value.indexOf("<!-- Please do not remove or change this AfD message until the issue is settled -->"), t.value.indexOf("<!-- End of AfD message, feel free to edit beyond this point -->") + ("<!-- End of AfD message, feel free to edit beyond this point -->".length - 1));
      f.wpSave.click();
      wait(2);
      location.assign("/wikipedia/en/w/index.php?title=Talk:" + document.title.substr(8, document.title.lastIndexOf(' - Wikipedia, the free') - 8) + "&action=edit&fakeaction=huff&reason=talk");
      return;
    }
  }
});

$(function()
{
  if (document.title.indexOf("Editing ") != -1)
  {
    if (document.URL.lastIndexOf("&fakeaction=huff") == -1)
      return;
    if (document.URL.lastIndexOf("&reason=talk") != -1)
    {
      var f = document.editform, t = f.wpTextbox1;
      var lastafd = decode(readCookie("discussion"));
      lastafd = excisestring(lastafd, lastafd.indexOf("Wikipedia:Articles for deletion/"), lastafd.indexOf("Wikipedia:Articles for deletion/") + ("Wikipedia:Articles for deletion/".length - 1)); 
      f.wpSummary.value = "JS: + {" + "{oldafdfull}}";
      t.value = "{" + "{oldafdfull | date = " + decode(readCookie("startdate")) + " | result = '''keep''' | page = " + lastafd + " }}\n" + t.value;
      f.wpSave.click();
      return;
    }
  }
});

function wait(s)
{
  tnot = Date.now();
  var v;
  while(Date.now() < (tnot + 1000*s))
  {
    v++;
  }
}

$(function()
{
  var f;
  var t;
  var disctitle;
  var imagename;
  var currentmonth;
  var currentdate;
  if (document.title.indexOf("Editing ") != -1)
  {
    if (document.URL.lastIndexOf("&fakeaction=huff") == -1)
      return;
    if (document.URL.lastIndexOf("&reason=retainfeaturedpicture") != -1)
    {
      f = document.editform;
      t = f.wpTextbox1;
      t.value += "\n{" + "{FPCresult|Kept|}}. --" + "~" + "~" + "~" + "~";
      disctitle = document.title.substr(8, document.title.lastIndexOf(' - Wikipedia, the free') - 8);   
      createCookie("discussion", encode(disctitle), 2);
      createCookie("disposition", "retained", 2);
      f.wpSummary.value = "JS: retaining featured picture";
      f.wpSave.click();
      wait(2);
      location.assign("/wikipedia/en/w/index.php?title=Wikipedia:Featured picture candidates&action=edit&fakeaction=huff&reason=removefptransclusion");
      return;
    }
    if (document.URL.lastIndexOf("&reason=delistfeaturedpicture") != -1)
    {
      f = document.editform;
      t = f.wpTextbox1;
      t.value += "\n{{FPCresult|Delisted|}}. --" + "~" + "~" + "~" + "~";
      disctitle = document.title.substr(8, document.title.lastIndexOf(' - Wikipedia, the free') - 8);   
      createCookie("discussion", encode(disctitle), 2);
      createCookie("disposition", "delisted", 2);
      f.wpSummary.value = "JS: delisting featured picture";
      if( (t.value.indexOf("[[Image:") < t.value.indexOf("[[image:") || t.value.indexOf("[[image:") == -1) && (t.value.indexOf("[[Image:") < t.value.indexOf("[[File:") || t.value.indexOf("[[File:") == -1) && (t.value.indexOf("[[Image:") < t.value.indexOf("[[file:") || t.value.indexOf("[[file:") == -1) )
      {
        imagename = t.value.slice(t.value.indexOf("[[Image:") + 2, (((t.value.slice(t.value.indexOf("[[Image:"), t.value.length)).indexOf("]]") < (t.value.slice(t.value.indexOf("[[Image:"), t.value.length)).indexOf("|") || (t.value.slice(t.value.indexOf("[[Image:"), t.value.length)).indexOf("|") == -1 )?((t.value.slice(t.value.indexOf("[[Image:"), t.value.length)).indexOf("]]")):((t.value.slice(t.value.indexOf("[[Image:"), t.value.length)).indexOf("|"))) + t.value.indexOf("[[Image:") );
      }
      else if ( (t.value.indexOf("[[image:") < t.value.indexOf("[[File:") || t.value.indexOf("[[File:") == -1) && (t.value.indexOf("[[image:") < t.value.indexOf("[[file:") || t.value.indexOf("[[file:") == -1) )
      {
        imagename = t.value.slice(t.value.indexOf("[[image:") + 2, (((t.value.slice(t.value.indexOf("[[image:"), t.value.length)).indexOf("]]") < (t.value.slice(t.value.indexOf("[[image:"), t.value.length)).indexOf("|")  || (t.value.slice(t.value.indexOf("[[image:"), t.value.length)).indexOf("|") == -1 )?((t.value.slice(t.value.indexOf("[[image:"), t.value.length)).indexOf("]]")):((t.value.slice(t.value.indexOf("[[image:"), t.value.length)).indexOf("|"))) + t.value.indexOf("[[image:") );
      }
      else if (t.value.indexOf("[[File:") < t.value.indexOf("[[file:") || t.value.indexOf("[[file:") == -1)
      {
        imagename = t.value.slice(t.value.indexOf("[[File:") + 2, (((t.value.slice(t.value.indexOf("[[File:"), t.value.length)).indexOf("]]") < (t.value.slice(t.value.indexOf("[[File:"), t.value.length)).indexOf("|")  || (t.value.slice(t.value.indexOf("[[File:"), t.value.length)).indexOf("|") == -1 )?((t.value.slice(t.value.indexOf("[[File:"), t.value.length)).indexOf("]]")):((t.value.slice(t.value.indexOf("[[File:"), t.value.length)).indexOf("|"))) + t.value.indexOf("[[File:") );
      }
      else
      {
        imagename = t.value.slice(t.value.indexOf("[[file:") + 2, (((t.value.slice(t.value.indexOf("[[file:"), t.value.length)).indexOf("]]") < (t.value.slice(t.value.indexOf("[[file:"), t.value.length)).indexOf("|")  || (t.value.slice(t.value.indexOf("[[file:"), t.value.length)).indexOf("|") == -1 )?((t.value.slice(t.value.indexOf("[[file:"), t.value.length)).indexOf("]]")):((t.value.slice(t.value.indexOf("[[file:"), t.value.length)).indexOf("|"))) + t.value.indexOf("[[file:") );
      }
      f.wpSave.click();
      wait(2);
      location.assign("/wikipedia/en/w/index.php?title=" + imagename + "&action=edit&fakeaction=huff&reason=demoteimage");
      return;
    }
    if (document.URL.lastIndexOf("&reason=declinefeaturedpicture") != -1)
    {
      f = document.editform;
      t = f.wpTextbox1;
      t.value += "\n{" + "{FPCresult|Not promoted| }}. --" + "~" + "~" + "~" + "~" + " [" + "[Cat" + "egory:Ended featured picture nominations]]";
      disctitle = document.title.substr(8, document.title.lastIndexOf(' - Wikipedia, the free') - 8);   
      createCookie("discussion", encode(disctitle), 2);
      createCookie("disposition", "declined", 2);
      f.wpSummary.value = "JS: closing featured picture nomination as not promoted";
      if(t.value.indexOf("[[Image:") < t.value.indexOf("[[image:") || t.value.indexOf("[[image:") == -1)
      {
        imagename = t.value.slice(t.value.indexOf("[[Image:") + 2, (((t.value.slice(t.value.indexOf("[[Image:"), t.value.length)).indexOf("]]") < (t.value.slice(t.value.indexOf("[[Image:"), t.value.length)).indexOf("|") || (t.value.slice(t.value.indexOf("[[Image:"), t.value.length)).indexOf("|") == -1 )?((t.value.slice(t.value.indexOf("[[Image:"), t.value.length)).indexOf("]]")):((t.value.slice(t.value.indexOf("[[Image:"), t.value.length)).indexOf("|"))) + t.value.indexOf("[[Image:") );
      }
      else
      {
        imagename = t.value.slice(t.value.indexOf("[[image:") + 2, (((t.value.slice(t.value.indexOf("[[image:"), t.value.length)).indexOf("]]") < (t.value.slice(t.value.indexOf("[[image:"), t.value.length)).indexOf("|")  || (t.value.slice(t.value.indexOf("[[image:"), t.value.length)).indexOf("|") == -1 )?((t.value.slice(t.value.indexOf("[[image:"), t.value.length)).indexOf("]]")):((t.value.slice(t.value.indexOf("[[image:"), t.value.length)).indexOf("|"))) + t.value.indexOf("[[image:") );
      }
      f.wpSave.click();
      wait(2);
      location.assign("/wikipedia/en/w/index.php?title=" + imagename + "&action=edit&fakeaction=huff&reason=removefpctemplate");
      return;
    }
    if (document.URL.lastIndexOf("&reason=removefpctemplate") != -1)
    {
      f = document.editform;
      t = f.wpTextbox1;
      disctitle = decode(readCookie("discussion"));
      t.value = excisestring(t.value, t.value.indexOf("{{FPC"), (t.value.slice(t.value.indexOf("{{FPC"), t.value.length)).indexOf("}}") + t.value.indexOf("{{FPC") + 1);
      t.value = excisestring(t.value, t.value.indexOf("{{Fpc"), (t.value.slice(t.value.indexOf("{{Fpc"), t.value.length)).indexOf("}}") + t.value.indexOf("{{Fpc") + 1);
      t.value = excisestring(t.value, t.value.indexOf("{{fpc"), (t.value.slice(t.value.indexOf("{{fpc"), t.value.length)).indexOf("}}") + t.value.indexOf("{{fpc") + 1);
      f.wpSummary.value = "JS: removing featured picture candidate template per [[" + disctitle + "]]";
      f.wpSave.click();
      wait(2);
      location.assign("/wikipedia/en/w/index.php?title=Wikipedia:Featured picture candidates&action=edit&fakeaction=huff&reason=removefptransclusion");
      return;
    }
    if (document.URL.lastIndexOf("&reason=demoteimage") != -1)
    {
      f = document.editform;
      t = f.wpTextbox1;
      disctitle = decode(readCookie("discussion"));
      t.value = "{" + "{FormerFeaturedPicture|" + disctitle.slice("Wikipedia:Featured picture candidates/".length, disctitle.length) + "}}\n" + excisestring(t.value, t.value.indexOf("{{FeaturedPicture"), (t.value.slice(t.value.indexOf("{" + "{FeaturedPicture"), t.value.length)).indexOf("}}") + t.value.indexOf("{{FeaturedPicture") + 1);
      f.wpSummary.value = "JS: delisting featured picture per [[" + disctitle + "]]";
      f.wpSave.click();
      wait(2);
      location.assign("/wikipedia/en/w/index.php?title=Wikipedia:Featured picture candidates&action=edit&fakeaction=huff&reason=removefptransclusion");
      return;
    }
    if (document.URL.lastIndexOf("&reason=removefptransclusion") != -1)
    {
      f = document.editform;
      t = f.wpTextbox1;
      disctitle = decode(readCookie("discussion"));
      t.value = excisestring(t.value, t.value.indexOf("{{" + disctitle + "}}"), t.value.indexOf("{{" + disctitle + "}}") + disctitle.length + 3);
      f.wpSummary.value = "JS: removing transclusion of [[" + disctitle + "]] per closure of discussion"
      f.wpSave.click();
      wait(2);
      if( readCookie("disposition") == "delisted" || readCookie("disposition") == "retained" )
      {
        location.assign("/wikipedia/en/w/index.php?title=Wikipedia:Featured picture candidates/archived removal requests&fakeaction=huff&reason=archivefeaturedpicturediscussion");
      }
      if(readCookie("disposition") == "declined")
      {
        currentdate = new Date();
        switch(currentdate.getUTCMonth())
        {
          case 0:
            currentmonth = "January";
            break;
          case 1:
            currentmonth = "February";
            break;
          case 2:
            currentmonth = "March";
            break;
          case 3:
            currentmonth = "April";
            break;
          case 4:
            currentmonth = "May";
            break;
          case 5:
            currentmonth = "June";
            break;
          case 6:
            currentmonth = "July";
            break;
          case 7:
            currentmonth = "August";
            break;
          case 8:
            currentmonth = "September";
            break;
          case 9:
            currentmonth = "October";
            break;
          case 10:
            currentmonth = "November";
            break;
          case 11:
            currentmonth = "December";
            break;
        }
        location.assign("/wikipedia/en/w/index.php?title=Wikipedia:Featured picture candidates/" + currentmonth + "-" + currentdate.getUTCFullYear() + "&action=edit&fakeaction=huff&reason=modifyarchivefeaturedpicturediscussion");
      }
      return;
    }
    if (document.URL.lastIndexOf("&reason=modifyarchivefeaturedpicturediscussion") != -1)
    {
      f = document.editform;
      t = f.wpTextbox1;
      disctitle = decode(readCookie("discussion"));
      if(readCookie("disposition") == "delisted")
      {
        t.value = t.value.slice(0, t.value.indexOf("==Other==") - 1) + "\n{{" + disctitle + "}}\n\n" + t.value.slice(t.value.indexOf("==Other=="), t.value.length);
        f.wpSummary.value = "JS: adding transclusion of [[" + disctitle + "]] to archive of delisted featured pictures";
      }
      if(readCookie("disposition") == "retained")
      {
        t.value = t.value.slice(0, t.value.indexOf("==Replaced==") - 1) + "\n{{" + disctitle + "}}\n\n" + t.value.slice(t.value.indexOf("==Replaced=="), t.value.length);
        f.wpSummary.value = "JS: adding transclusion of [[" + disctitle + "]] to archive of retained featured pictures";
      }
      if(readCookie("disposition") == "declined")
      {
        t.value += ( "\n{{" + disctitle + "}}\n" ) 
        f.wpSummary.value = "JS: adding transclusion of [[" + disctitle + "]] to archive of featured picture nominations";
      }
      f.wpSave.click();
      return;
    }
  }
    if((document.URL.lastIndexOf("&fakeaction=huff") != -1) &&(document.URL.lastIndexOf("&reason=archivefeaturedpicturediscussion") != -1))
    {
      wait(2);
      var pagetitle = document.title.substr(0, document.title.lastIndexOf(' - Wikipedia, the free'));
      location.assign("/wikipedia/en/w/index.php?title=" + pagetitle + "&action=edit&fakeaction=huff&reason=modifyarchivefeaturedpicturediscussion");
      return;
    }
  if (window.location.href.search(/Special:|&action=/) != -1)
  {
    return;
  }
  if(document.title.indexOf("Wikipedia:Featured picture candidates/delist/") != -1)
  {
    addTab("javascript:retainfeaturedpicture()", "retain FP", "", "retain featured picture", "");
    addTab("javascript:delistfeaturedpicture()", "delist FP", "", "delist featured picture", "");
  }
  else
  {
    if(document.title.indexOf("Wikipedia:Featured picture candidates/") != -1)
    {
      addTab("javascript:declinefeaturedpicture()", "decline FP", "", "decline featured picture nomination", "");
    }
  }
});
 
function retainfeaturedpicture()
{
    //edit page
    var title = document.title.substr(0, document.title.lastIndexOf(' - Wikipedia, the free'));
    location.assign("/wikipedia/en/w/index.php?title=" + title + "&action=edit&fakeaction=huff&reason=retainfeaturedpicture");
}

function delistfeaturedpicture()
{
    //edit page
    var title = document.title.substr(0, document.title.lastIndexOf(' - Wikipedia, the free'));
    location.assign("/wikipedia/en/w/index.php?title=" + title + "&action=edit&fakeaction=huff&reason=delistfeaturedpicture");
}

function declinefeaturedpicture()
{
    //edit page
    var title = document.title.substr(0, document.title.lastIndexOf(' - Wikipedia, the free'));
    location.assign("/wikipedia/en/w/index.php?title=" + title + "&action=edit&fakeaction=huff&reason=declinefeaturedpicture");
}
//</nowiki>