Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

MediaWiki:Gadget-quickLinkCardClick.js

MediaWiki interface page

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
(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;
        }
      });
    });
  });
})();