Jump to content

MediaWiki:Common.js

From Artemis Archive
Revision as of 07:52, 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 () {
    // identify mobile device
    const isMobile = /Mobi|Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
    if (isMobile) {
        console.log('[ReportAbuseLink] Mobile device detected – button disabled.');
        return;
    }

    // desktop load button
    console.log('[ReportAbuseLink] Running...');

    const linkURL = '/index.php/Report_Animal_Abuse'; // target page
    const linkText = 'Report Abuse';

    const button = document.createElement('a');
    button.href = linkURL;
    button.textContent = linkText;
    button.style.position = 'absolute';
    button.style.top = '0.5rem';
    button.style.right = '1rem';
    button.style.padding = '10px 16px';
    button.style.backgroundColor = '#ff4444';
    button.style.color = 'white';
    button.style.fontWeight = 'bold';
    button.style.borderRadius = '6px';
    button.style.textDecoration = 'none';
    button.style.zIndex = '9999';
    button.style.fontSize = '16px';
    button.style.transition = 'background-color 0.3s ease';

    // Hover effect
    button.addEventListener('mouseover', function () {
        button.style.backgroundColor = '#cc0000';
    });
    button.addEventListener('mouseout', function () {
        button.style.backgroundColor = '#ff4444';
    });

    document.body.appendChild(button);
    console.log('[ReportAbuseLink] Button inserted.');
});