MediaWiki:Common.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
// Force college page edits to open Page Forms instead of raw wikitext
(function () {
function pageTitle() {
return mw.config.get('wgPageName');
}
function formEditUrl(title) {
return mw.util.getUrl('Special:FormEdit/CollegePage/' + title);
}
function redirectIfRawCollegeEdit() {
var action = mw.config.get('wgAction');
var title = pageTitle();
if (action === 'edit') {
var textarea = document.querySelector('#wpTextbox1');
if (textarea && textarea.value.indexOf('{{CollegePage') !== -1) {
window.location.href = formEditUrl(title);
}
}
}
function rewriteEditTab() {
var title = pageTitle();
var formButton = document.querySelector('a[href*="Special:FormEdit/CollegePage"]');
var editTab = document.querySelector('#ca-edit a');
if (formButton && editTab) {
editTab.href = formEditUrl(title);
editTab.textContent = 'Edit';
}
}
$(function () {
redirectIfRawCollegeEdit();
rewriteEditTab();
});
})();