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