User:Legoktm/com.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.
if(wgNamespaceNumber == 6) { if(wgAction == 'edit' || wgAction == 'submit') { addOnloadHook(function () { addPortletLink('p-cactions','javascript:doNcd()','ncd','ca-ncd'); addPortletLink('p-cactions','javascript:doMtc()','mtc','ca-mtc'); addPortletLink('p-cactions','javascript:doRmtc()','rmtc','ca-rmtc'); }); } else { addOnloadHook(function () { var url = wgServer + wgScript + '?title=' + encodeURIComponent(wgPageName) + '&action=edit'; addPortletLink('p-cactions',url + '&autoncd=true','ncd','ca-ncd'); addPortletLink('p-cactions',url + '&automtc=true','mtc','ca-mtc'); addPortletLink('p-cactions',url + '&autormtc=true','rmtc','ca-rmtc'); }); } } if(queryString('autoncd')) addOnloadHook(function() { doNcd(); }) function doNcd() { var txt = document.getElementById('wpTextbox1'); if(!txt) return; txt.value = txt.value.replace(/\{\{[\s\t\n\r]*(mtc|ctwc|cwc|copy[ -_]to[ -_]wikimedia[ -_]commons|needs[ -_]commons[ -_]category|tocommons|movetocommons|move[ -_]to[ -_]commons|to[ -_]commons|move[ -_]to[ -_]wikimedia[ -_]commons|copy[ -_]to[ -_]commons|move-to-commons)[\s\t\n\r]*\}\}/ig,''); txt.value = '{' + '{' + 'subst:ncd}}\n\n' + txt.value; document.getElementById('wpSummary').value += ' tagging image as on already on commons ({'+'{NowCommons}})'; document.getElementById('wpSave').click(); } 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 += 'Tagging image to be [[WP:MITTC|Moved to the Wikimedia Commons]] ({'+'{Copy to Wikimedia Commons}})'; document.getElementById('wpSave').click(); } if(queryString('autormtc')) addOnloadHook(function() { doRmtc(); }) function doRmtc() { var txt = document.getElementById('wpTextbox1'); if(!txt) return; txt.value = txt.value.replace(/\{\{[\s\t\n\r]*(mtc|ctwc|cwc|copy[ -_]to[ -_]wikimedia[ -_]commons|needs[ -_]commons[ -_]category|tocommons|movetocommons|move[ -_]to[ -_]commons|to[ -_]commons|move[ -_]to[ -_]wikimedia[ -_]commons|copy[ -_]to[ -_]commons|move-to-commons)[\s\t\n\r]*\}\}/ig,''); txt.value = '<' + '!--' + 'Image has been moved to commons by [[User:Legoktm|Legoktm]]-->\n\n' + txt.value; document.getElementById('wpSummary').value += ' removing unnecessary {'+'{mtc}} tag'; 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; }