MediaWiki:Common.js: Difference between revisions
OMNIVERSE
No edit summary |
No edit summary |
||
| Line 10: | Line 10: | ||
console.log('changeImageLinks function called!'); | console.log('changeImageLinks function called!'); | ||
var imageLinks = document.querySelectorAll('a[href*="/File:"]'); | var imageLinks = document.querySelectorAll('a[href*="/File:"]'); | ||
console.log('Found ' + imageLinks.length + ' File: links'); | console.log('Found ' + imageLinks.length + ' File: links'); | ||
| Line 19: | Line 18: | ||
if (img) { | if (img) { | ||
var src = img.getAttribute('src'); | var src = img.getAttribute('src'); | ||
console.log('Link ' + index + ' - Image src:', src); | console.log('Link ' + index + ' - Image src:', src); | ||
// | // Simply remove /thumb/ and the size prefix (e.g., /300px-filename.png) | ||
var fullSrc = src.replace(/\/thumb\//, '/').replace(/\/\d+px-([^/]+)$/, '/$1'); | |||
var fullSrc = src.replace(/\/thumb(\/ | |||
console.log('Link ' + index + ' - Changed to:', fullSrc); | console.log('Link ' + index + ' - Changed to:', fullSrc); | ||
Revision as of 03:15, 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, index) {
var img = link.querySelector('img');
if (img) {
var src = img.getAttribute('src');
console.log('Link ' + index + ' - Image src:', src);
// Simply remove /thumb/ and the size prefix (e.g., /300px-filename.png)
var fullSrc = src.replace(/\/thumb\//, '/').replace(/\/\d+px-([^/]+)$/, '/$1');
console.log('Link ' + index + ' - Changed to:', fullSrc);
link.href = fullSrc;
}
});
}
