User:CBM/nostubtagtab.js

From Wikipedia, the free encyclopedia
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.
// Remove stub tags from article 
// Originally by [[User:ais523]], on a request by [[User:thesublime514]].
// ([[User:ais523/stubtagtab.js]])

// Modified slightly by CBM

// <source lang="javascript">
$(function(){
  return; // disabled [[phab:T105261]]
  if(wgNamespaceNumber==0&&wgAction=="view")
  {
    if(document.getElementById("ca-edit"))
      mw.util.addPortletLink('p-cactions', 'javascript:rmstubtagtab()', 'nostub', 'ca-nostubtag',
                                   'Remove stub tags from this page', '');
  }
  if(location.href.indexOf("&autormstubtag=")!=-1&&  
                 document.getElementById('wpTextbox1')!=null)
  {
    var x=decodeURIComponent(location.href.split("&autormstubtag=")[1]);
    if(x=="") x="stub"; else x+="-stub";
    var text = document.getElementById('wpTextbox1').value;
    text = text.replace(/\{\{[a-zA-Z -]+-stub\}\}/g,  '');
    document.getElementById('wpTextbox1').value = text ;
    document.getElementById('wpSummary').value=
      "Removing stub tag(s)";
    document.getElementById('wpDiff').click();
  }
});

function rmstubtagtab()
{
  location.href=mw.config.get('wgServer')+mw.config.get('wgScript')+"?title="+encodeURIComponent(mw.config.get('wgPageName'))+                                  
                "&action=edit&autormstubtag=1";
}

// </source> [[Category:Wikipedia scripts]]