MediaWiki:Common.js: Difference between revisions
Appearance
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
$(function () { | $(function () { | ||
// Only run once everything is loaded | |||
const checkInterval = setInterval(function () { | |||
const headerTools = document.querySelector('.vector-header-end'); | |||
if (headerTools) { | |||
clearInterval(checkInterval); | |||
// Don't insert the link twice | |||
if (document.querySelector('#report-abuse-link')) return; | |||
// Create link | |||
const reportLink = document.createElement('a'); | |||
reportLink.id = 'report-abuse-link'; | |||
reportLink.href = mw.util.getUrl('Report_Animal_Abuse'); // Change to your actual target page | |||
reportLink.textContent = '🐾 Report Abuse'; | |||
reportLink.style.marginLeft = '1em'; | |||
reportLink.style.fontWeight = 'bold'; | |||
reportLink.style.color = '#d33'; // red color for attention | |||
// Insert before login link if present | |||
const | const loginLink = headerTools.querySelector('a[href*="Special:UserLogin"]'); | ||
if (loginLink) { | |||
if ( | headerTools.insertBefore(reportLink, loginLink); | ||
} else { | |||
headerTools.appendChild(reportLink); | |||
} | |||
} | } | ||
console.log('[ReportAbuseLink] Inserted into header'); | |||
} | |||
}, 100); | |||
}); | }); |
Revision as of 05:06, 21 April 2025
$(function () { // Only run once everything is loaded const checkInterval = setInterval(function () { const headerTools = document.querySelector('.vector-header-end'); if (headerTools) { clearInterval(checkInterval); // Don't insert the link twice if (document.querySelector('#report-abuse-link')) return; // Create link const reportLink = document.createElement('a'); reportLink.id = 'report-abuse-link'; reportLink.href = mw.util.getUrl('Report_Animal_Abuse'); // Change to your actual target page reportLink.textContent = '🐾 Report Abuse'; reportLink.style.marginLeft = '1em'; reportLink.style.fontWeight = 'bold'; reportLink.style.color = '#d33'; // red color for attention // Insert before login link if present 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); });