MediaWiki:Common.js

From The Radical Buddhism Project
Revision as of 12:34, 21 July 2026 by Lajos (talk | contribs) (Created page with "Any JavaScript here will be loaded for all users on every page load.: ===================================================================== RADICAL BUDDHIST PROJECT - AUTOMATED DESKTOP CATEGORY GENERATOR =====================================================================: $(document).ready(function() { // Locate MediaWiki's hidden internal category tracking metadata links var catLinks = $('.mw-normal-catlinks a, .catlinks a'); if (catLinks....")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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.
/* Any JavaScript here will be loaded for all users on every page load. */

/* =====================================================================
   RADICAL BUDDHIST PROJECT - AUTOMATED DESKTOP CATEGORY GENERATOR
   ===================================================================== */
$(document).ready(function() {
    // Locate MediaWiki's hidden internal category tracking metadata links
    var catLinks = $('.mw-normal-catlinks a, .catlinks a');
    if (catLinks.length > 0 && $('#custom-cat-tray').length === 0) {
        var trayHtml = '<div id="custom-cat-tray" style="margin: 40px 0 20px 0; padding: 15px 20px; background-color: #f0f2f4; border: 1px solid #d0d4d8; font-family: sans-serif; font-size: 0.85em; color: #222222;"><strong>Categories:</strong> ';
        
        catLinks.each(function(index) {
            var text = $(this).text();
            var href = $(this).attr('href');
            // Skip the generic "Categories" heading link itself
            if (text !== 'Categories' && text !== 'カテゴリ') {
                if (index > 1) trayHtml += ' <span style="color: #d0d4d8; margin: 0 8px;">|</span> ';
                trayHtml += '<a href="' + href + '" style="color: #222222; text-decoration: none;">' + text + '</a>';
            }
        });
        
        trayHtml += '</div>';
        // Surgically append our custom tray right inside the active article reading block
        $('.mw-body-content, #bodyContent').append(trayHtml);
    }
});