MediaWiki:Common.js

From PRS
Revision as of 08:18, 22 April 2026 by Prs (talk | contribs)
Jump to navigation Jump to search

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. */

/* ── DIAGNOSTIC: Watch what TMH does to the video element ── */
$(function () {
    if ($('.training-video-wrap').length === 0) return;

    function startWatching() {
        var video = document.querySelector('.mw-file-element');
        if (!video) {
            setTimeout(startWatching, 100);
            return;
        }

        console.log('=== TMH DIAGNOSTIC STARTED ===');
        console.log('Initial video attributes:');
        for (var i = 0; i < video.attributes.length; i++) {
            console.log('  ' + video.attributes[i].name + '="' + video.attributes[i].value + '"');
        }

        /* Watch for any attribute changes on the video element */
        var observer = new MutationObserver(function (mutations) {
            mutations.forEach(function (mutation) {
                if (mutation.type === 'attributes') {
                    console.log('ATTR CHANGED: ' + mutation.attributeName + ' = "' + mutation.target.getAttribute(mutation.attributeName) + '" (was: "' + mutation.oldValue + '")');
                }
                if (mutation.type === 'childList') {
                    console.log('CHILD ADDED/REMOVED on: ' + mutation.target.className);
                }
            });
        });

        observer.observe(video, {
            attributes: true,
            attributeOldValue: true,
            childList: true,
            subtree: true
        });

        /* Also watch the parent container */
        var parent = document.querySelector('.mw-tmh-player');
        if (parent) {
            observer.observe(parent, {
                attributes: true,
                attributeOldValue: true,
                childList: true,
                subtree: false
            });
        }

        console.log('=== NOW WATCHING FOR CHANGES ===');
    }

    startWatching();
});