User:Pi Delport/monobook.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | The accompanying .css page for this skin is at User:Pi Delport/monobook.css. |
// Helpful: [[Wikipedia:WikiProject User scripts/Guide]]
// Helpers
function contains(xs, x) {
return 0 <= xs.indexOf(x);
}
function notnull(x) {
if (x == null) throw TypeError(x);
return x;
}
// Personal navigation
$(function() {
function pagehref (page) {
return mw.config.get('wgArticlePath').replace('$1', page.replace(/ /g, '_'));
}
function addLink(page, label, id) {
// mw.util.addPortletLink(portlet, href, text, id,
// tooltip, accesskey, nextnode)
mw.util.addPortletLink('p-personal', pagehref(page), label, id,
page, '', document.getElementById('pt-userpage'));
}
addLink('User:Piet Delport/Task list', 'task list', 'pt-tasklist');
addLink('User:Piet Delport/Edit summary snippets', 'edit snippets', 'pt-editsnippets');
});
// Avoid wrapping edit summaries (it makes lists of them hard to read)
if (contains(['Recentchanges', 'Recentchangeslinked', 'Watchlist'], mw.config.get('wgCanonicalSpecialPageName')) || mw.config.get('wgAction') == 'history') {
addOnloadHook(function() {
notnull(document.getElementById('bodyContent')).style.whiteSpace = 'nowrap';
});
}
// Editing toolbar
if (mw.config.get('wgAction') == 'edit' || mw.config.get('wgAction') == 'submit') {
addOnloadHook(function() {
// Drop dubious buttons.
mwEditButtons = mwEditButtons.filter(function (button) {
return !contains([
'mw-editbutton-extlink',
'mw-editbutton-image',
'mw-editbutton-media',
'mw-editbutton-math',
'mw-editbutton-nowiki',
], button.imageId);
});
// Em dashed signature.
mwEditButtons = mwEditButtons.map(function (button) {
if (button.tagOpen == '--~~'+'~~') {
button.tagOpen = '~'+'~~';
}
return button;
});
});
// See [[MediaWiki:Common.js]]; i don't want those.
mwCustomEditButtons = [{
"imageFile": "/media/wikipedia/commons/1/1b/Button_miss_signature.png",
"speedTip": "Unsigned post",
"tagOpen": "{"+"{unsigned|",
"tagClose": "|}"+"}",
"sampleText": "Name",
}];
importScript('User:Js/ajaxPreview.js');
}
// Other extensions
importScript('MediaWiki:Gadget-edittop.js');
importScript('User:Lupin/popups.js');
popupHideDelay = 0;
importScript('User:Dschwen/highlightredirects.js');