Jump to content

MediaWiki:Common.js

From Artemis Archive
Revision as of 05:13, 21 April 2025 by Bxuwd (talk | contribs)

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 () {
    // Wait until the header tools are available
    const checkInterval = setInterval(function () {
        const headerTools = document.querySelector('.vector-header-end');
        if (headerTools) {
            clearInterval(checkInterval);

            // Avoid adding the link multiple times
            if (document.querySelector('#report-abuse-link')) return;

            // Create the link element
            const reportLink = document.createElement('a');
            reportLink.id = 'report-abuse-link';
            reportLink.href = mw.util.getUrl('Report_Animal_Abuse'); // Update with your actual page
            reportLink.textContent = '🐾 Report Abuse';
            reportLink.style.marginLeft = '1em';
            reportLink.style.fontWeight = 'bold';
            reportLink.style.color = '#d33'; // Red color for visibility

            // Insert the link before the login link if it exists
            const loginLink = headerTools.querySelector('a[href*="Special:UserLogin"]');
            if (loginLink) {
                headerTools.insertBefore(reportLink, loginLink);
            } else {
                headerTools.appendChild(reportLink);
            }

            console.log('[ReportAbuseLink] Inserted into header');
        }
    }, 100);
});