User:Legoktm/mtc.js

// Adds Template:MTC] // Created by Legoktm // Adds a tab at the top of the page says "mtc" if(wgNamespaceNumber == 6) { if(wgAction == 'edit' || wgAction == 'submit') { addOnloadHook(function { mw.util.addPortletLink('p-cactions','javascript:doMtc','mtc','ca-mtc'); }); } else { var url = mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=' + encodeURIComponent(mw.config.get('wgPageName')) + '&action=edit&automtc=true'; addOnloadHook(function { mw.util.addPortletLink('p-cactions',url,'mtc','ca-mtc'); }); } } if(queryString('automtc')) addOnloadHook(function { doMtc; }) function doMtc { var txt = document.getElementById('wpTextbox1'); if(!txt) return; txt.value = '{' + '{' + 'move to commons}}\n\n' + txt.value; document.getElementById('wpSummary').value += ' automatically tagging {'+'{mtc}}'; 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; }