User:TheFearow/stubber.js

From Wikipedia, the free encyclopedia

Note: After saving, you have to bypass your browser's cache to see the changes. In Internet Explorer and Firefox, hold down the Ctrl key and click the Refresh or Reload button. Opera users have to clear their caches through Tools→Preferences, see the instructions for Opera. Konqueror and Safari users can just click the Reload button.

//Start stub script
 
addOnloadHook(function()
{
  //check if called from stub request
  if (document.URL.lastIndexOf("action=edit") != -1)
  {
    if (document.URL.lastIndexOf("&stub=yes") != -1)
    {
      var type = window.prompt("Enter stub type (press cancel or enter for plain stub tag)");
      var tag = "{" + "{stub}}";
      if(type != null){
           tag = "{"+"{"+type+"-stub}}";
      }
      document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + "\n\n"+tag;
      document.editform.wpSummary.value = "Added stub tag";
      document.editform.wpSave.click();
      return;
    }
  }
  if (wgCanonicalNamespace == "Special"){
    return;
}
  addPortletLink("p-cactions", "javascript:easyStub(0)", "stub", "ca-stub", "Add stub tag", "");
});
 
function easyStub()
{
  var title = wgPageName.replace("&", "%26").replace("+", "%21");
  location.assign("/w/index.php?action=edit&stub=yes&title=" + title);
}
 
 
//End stub script
//