MediaWiki:Common.js
Appearance
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 () { mw.loader.using('mediawiki.util').then(function () { console.log('[ReportAbuseLink] Running...'); const reportPage = 'Report_Animal_Abuse'; // page title const linkText = '🚨 Report Abuse'; const insertLink = function () { const personalList = document.querySelector('#p-personal ul.vector-menu-content-list'); const langButton = document.querySelector('#p-lang-btn, #vector-lang-button'); // language button const loginItem = document.querySelector('#pt-login-2, #pt-login'); if (!personalList) { console.log('[ReportAbuseLink] personal tools list not found.'); return false; } // Create the list item const li = document.createElement('li'); li.id = 'pt-reportabuse'; const link = document.createElement('a'); link.href = mw.util.getUrl(reportPage); link.textContent = linkText; link.style.color = '#b10000'; link.style.fontWeight = 'bold'; li.appendChild(link); if (langButton && langButton.closest('li')?.parentNode === personalList) { personalList.insertBefore(li, langButton.closest('li')); console.log('[ReportAbuseLink] Inserted before language button.'); } else if (loginItem && loginItem.closest('li')?.parentNode === personalList) { personalList.insertBefore(li, loginItem.closest('li')); console.log('[ReportAbuseLink] Inserted before login.'); } else { personalList.appendChild(li); console.log('[ReportAbuseLink] Appended to the end.'); } return true; }; // Try inserting with retry logic let attempts = 0; const maxAttempts = 30; const retryInterval = setInterval(() => { if (insertLink() || ++attempts >= maxAttempts) { clearInterval(retryInterval); console.log('[ReportAbuseLink] Done.'); } }, 200); }); });