MediaWiki:Common.js
OMNIVERSE
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.
console.log('Common.js is loading!');
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', changeImageLinks);
} else {
changeImageLinks();
}
function changeImageLinks() {
console.log('changeImageLinks function called!');
var imageLinks = document.querySelectorAll('a[href*="/File:"]');
console.log('Found ' + imageLinks.length + ' File: links');
imageLinks.forEach(function(link) {
var img = link.querySelector('img');
if (img) {
var src = img.getAttribute('src');
console.log('Original src:', src);
// Remove /thumb/ and the size specification
var fullSrc = src.replace(/\/thumb\/(.+?)\/\d+px-.+$/, '/$1');
console.log('Changed to:', fullSrc);
link.setAttribute('href', fullSrc);
}
});
}
