Jump to content

MediaWiki:Common.js: Difference between revisions

From Artemis Archive
No edit summary
No edit summary
Line 1: Line 1:
$(function () {
$(function () {
     // Wait until the header tools are available
     console.log('[ReportAbuseLink] Running...');
     const checkInterval = setInterval(function () {
      
        const headerTools = document.querySelector('.vector-header-end');
    var menuList = document.querySelector('#p-personal ul.vector-menu-content-list');
        if (headerTools) {
    if (!menuList) {
            clearInterval(checkInterval);
        console.log('[ReportAbuseLink] Personal tools menu not found.');
        return;
    }


            // Avoid adding the link multiple times
    // Create new list item
            if (document.querySelector('#report-abuse-link')) return;
    var li = document.createElement('li');
    li.id = 'pt-reportabuse';


            // Create the link element
    var a = document.createElement('a');
            const reportLink = document.createElement('a');
    a.href = mw.util.getUrl('Report_Animal_Abuse');
            reportLink.id = 'report-abuse-link';
    a.textContent = '🐾 Report Abuse';
            reportLink.href = mw.util.getUrl('Report_Animal_Abuse'); // Update with your actual page
    a.style.color = 'red';
            reportLink.textContent = '🐾 Report Abuse';
    a.style.fontWeight = 'bold';
            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
    li.appendChild(a);
            const loginLink = headerTools.querySelector('a[href*="Special:UserLogin"]');
    menuList.appendChild(li);
            if (loginLink) {
                headerTools.insertBefore(reportLink, loginLink);
            } else {
                headerTools.appendChild(reportLink);
            }


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

Revision as of 05:27, 21 April 2025

$(function () {
    console.log('[ReportAbuseLink] Running...');
    
    var menuList = document.querySelector('#p-personal ul.vector-menu-content-list');
    if (!menuList) {
        console.log('[ReportAbuseLink] Personal tools menu not found.');
        return;
    }

    // Create new list item
    var li = document.createElement('li');
    li.id = 'pt-reportabuse';

    var a = document.createElement('a');
    a.href = mw.util.getUrl('Report_Animal_Abuse');
    a.textContent = '🐾 Report Abuse';
    a.style.color = 'red';
    a.style.fontWeight = 'bold';

    li.appendChild(a);
    menuList.appendChild(li);

    console.log('[ReportAbuseLink] Link inserted.');
});