User:Innotata/common.js
Jump to navigation
Jump to search
Note: After saving, changes may not occur immediately. Click here to learn how to bypass your browser's cache.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Cmd-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (Cmd-Shift-R on a Mac)
- Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Clear the cache in Tools → Preferences
For details and instructions about other browsers, see Wikipedia:Bypass your cache.
Code that you insert on this page could contain malicious content capable of compromising your account. If you are unsure whether code you are adding to this page is safe, you can ask at the central discussion page, Scriptorium. The code will be executed when previewing this page under some skins, including Monobook. You can in the interim if you wish to refresh the content sooner under another skin. |
The accompanying .css page for this skin can be added at User:Innotata/common.css. |
if(mw.config.get('wgNamespaceNumber') == 6) {
if(wgAction == 'edit' || wgAction == 'submit') {
addOnloadHook(function () {
mw.util.addPortletLink('p-cactions','javascript:doNcd()','ncd','ca-ncd');
mw.util.addPortletLink('p-cactions','javascript:doMtc()','mtc','ca-mtc');
mw.util.addPortletLink('p-cactions','javascript:doCH()','ch','ca-ch');
});
} else {
addOnloadHook(function () {
var url = mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=' + encodeURIComponent(mw.config.get('wgPageName')) + '&action=edit';
mw.util.addPortletLink('p-cactions',url + '&autoncd=true','ncd','ca-ncd');
mw.util.addPortletLink('p-cactions',url + '&automtc=true','mtc','ca-mtc');
var url = 'https://tools.wmflabs.org/commonshelper/?interface=en&image=' + encodeURIComponent(wgTitle) + '&lang=en&project=wikisource';
mw.util.addPortletLink('p-cactions',url + '','ch','ca-ch');
});
}
}
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|commons[ -_]ok)[\s\t\n\r]*\}\}/ig,'');
txt.value = '{' + '{' + 'subst:ncd}}\n\n' + txt.value;
document.getElementById('wpSummary').value += ' this file has been moved to Wikimedia Commons: tagging for deletion';
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 += ' this file should be moved to Wikimedia Commons: tagging with {'+'{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;
}