User:Splarka/nulledit.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.
if(mw.config.get('wgNamespaceNumber') != -1 && mw.config.get('wgArticleId') != 0) addOnloadHook(nullEditButton)
function nullEditButton() {
  mw.util.addPortletLink('p-tb', mw.config.get('wgScript') + '?title=' + encodeURIComponent(mw.config.get('wgPageName')) + '&action=edit&nulledit=true','Null edit','t-null','Null edit this page');
}

if(mw.config.get('wgAction') == 'edit' && queryString('nulledit') == 'true') addOnloadHook(nullEdit)
function nullEdit() {
  document.getElementById('wpSave').click();
}

function queryString(p) {
  var re = RegExp('[&?]' + p + '=([^&]*)');
  var matches;
  if (matches = re.exec(document.location)) {
    try { 
      return decodeURI(matches[1]);
    } catch (e) {
    }
  }
  return null;
}