Jump to content

User:Legoktm/i8.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.
//Quick way to add <nowiki>{{db-i8}}</nowiki> onto an image page
//Please do not use without reading [[WP:CSD#I8]] and [[WP:MITTC]]
if(wgNamespaceNumber == 6) {
  if(wgAction == 'edit' || wgAction == 'submit') {
    addOnloadHook(function () { mw.util.addPortletLink('p-cactions','javascript:doi8()','i8','ca-i8'); });
  } else {
    var url = mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=' + encodeURIComponent(mw.config.get('wgPageName')) + '&action=edit&autoi8=true';
    addOnloadHook(function () { mw.util.addPortletLink('p-cactions',url,'i8','ca-i8'); });
  }
}
if(queryString('autoi8')) addOnloadHook(function() { doi8(); })
function doi8() {
  var txt = document.getElementById('wpTextbox1');
  if(!txt) return;
  txt.value = '{' + '{' + 'db-i8}}\n\n' + txt.value;
  document.getElementById('wpSummary').value += 'tagging for [[WP:SD|speedy deletion]] per [[WP:CSD#I8|CSD I8]]';
  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;
}