More actions
No edit summary |
mNo edit summary |
||
Line 3: | Line 3: | ||
mw.hook('wikipage.content').add(function (content) { | mw.hook('wikipage.content').add(function (content) { | ||
const cards = content.querySelectorAll('.vh-quick-link-card'); | const cards = content[0].querySelectorAll('.vh-quick-link-card'); | ||
cards.forEach(card => { | cards.forEach(card => { | ||
const link = card.querySelector('a'); | const link = card.querySelector('a'); |
Latest revision as of 04:45, 23 July 2025
(function () {
if (mw.config.get('wgIsMainPage') !== true) return;
mw.hook('wikipage.content').add(function (content) {
const cards = content[0].querySelectorAll('.vh-quick-link-card');
cards.forEach(card => {
const link = card.querySelector('a');
if (!link) return;
card.addEventListener('click', function (e) {
if (e.target.closest('a')) return;
window.location.href = link.href;
});
card.setAttribute('role', 'link');
card.setAttribute('tabindex', '0');
card.addEventListener('keydown', function (e) {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
window.location.href = link.href;
}
});
});
});
})();