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.
loadScript('/MediaWiki:Scripting.js?action=raw&ctype=text/javascript');
function makeVisible(el) {
el.style.display = 'inline';
}
// show edit items when a user is logged in
if (window.mw.config.values.wgUserId) {
Array.from(document.getElementsByClassName('controls-loggedin')).forEach(makeVisible);
}
// make sunwater logo area clickable
document.querySelector('#p-tb').addEventListener('click', function (e) {
function isInPath(p) {
return p.parentNode.nodeName === 'A';
}
const isMenuItem = isInPath(e.path[0]);
if (!isMenuItem) {
document.location = 'https://sunwater.org';
return false;
}
});
function parse(data) {
const text = data.text();
return text; // Promise
}
function evals(script) {
try {
eval(script);
} catch (e) {
console.log('failed', e);
}
}
function loadScript(url) {
fetch(url)
.then(parse)
.then(evals);
}