MediaWiki:Common.js: Difference between revisions
OMNIVERSE
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
console.log('Common.js is loading!'); | |||
// Make image links open the full resolution image directly (no jQuery) | // Make image links open the full resolution image directly (no jQuery) | ||
document.addEventListener('DOMContentLoaded', function() { | document.addEventListener('DOMContentLoaded', function() { | ||
console.log('DOMContentLoaded fired!'); | |||
var imageLinks = document.querySelectorAll('.mw-parser-output a.image'); | var imageLinks = document.querySelectorAll('.mw-parser-output a.image'); | ||
console.log('Found ' + imageLinks.length + ' image links'); | |||
imageLinks.forEach(function(link) { | imageLinks.forEach(function(link) { | ||
| Line 8: | Line 13: | ||
if (img) { | if (img) { | ||
var src = img.getAttribute('src'); | var src = img.getAttribute('src'); | ||
var fullSrc = src.replace(/\/thumb(\/[^\/]+\/[^\/]+\/)(\d+px-)?(.+)$/, '$1$3'); | var fullSrc = src.replace(/\/thumb(\/[^\/]+\/[^\/]+\/)(\d+px-)?(.+)$/, '$1$3'); | ||
link.setAttribute('href', fullSrc); | link.setAttribute('href', fullSrc); | ||
console.log('Changed link to:', fullSrc); | |||
console.log('Changed link | |||
} | } | ||
}); | }); | ||
}); | }); | ||
Revision as of 03:07, 25 January 2026
console.log('Common.js is loading!');
// Make image links open the full resolution image directly (no jQuery)
document.addEventListener('DOMContentLoaded', function() {
console.log('DOMContentLoaded fired!');
var imageLinks = document.querySelectorAll('.mw-parser-output a.image');
console.log('Found ' + imageLinks.length + ' image links');
imageLinks.forEach(function(link) {
var img = link.querySelector('img');
if (img) {
var src = img.getAttribute('src');
var fullSrc = src.replace(/\/thumb(\/[^\/]+\/[^\/]+\/)(\d+px-)?(.+)$/, '$1$3');
link.setAttribute('href', fullSrc);
console.log('Changed link to:', fullSrc);
}
});
});
