MediaWiki:Common.js
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)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */ // Function to hide 'Edit' for anonymous users document.addEventListener("DOMContentLoaded", function() { // Get the user groups from MediaWiki config var userGroups = mw.config.get('wgUserGroups'); // Check if the user is logged in ('user') or an admin ('sysop') if (userGroups.includes('sysop')) { var editLink = document.getElementById('ca-edit'); if (editLink) { editLink.style.display = 'inline'; // Show 'Edit' for logged-in users/admins } } else { // Hide 'Edit' link for anonymous users var editLink = document.getElementById('ca-edit'); if (editLink) { editLink.style.display = 'none'; // Hide 'Edit' for anonymous users } } }); // Google Translate Widget function googleTranslateElementInit() { new google.translate.TranslateElement({ pageLanguage: 'en', layout: google.translate.TranslateElement.InlineLayout.SIMPLE }, 'google_translate_element'); } // Add a div for Google Translate document.addEventListener('DOMContentLoaded', function() { var translateDiv = document.createElement('div'); translateDiv.id = 'google_translate_element'; document.body.insertBefore(translateDiv, document.body.firstChild); // Insert at the top of the body });