MediaWiki:Common.js: Difference between revisions

OMNIVERSE
No edit summary
Blanked the page
Tag: Blanking
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
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);
        }
    });
}

Latest revision as of 03:21, 25 January 2026