MediaWiki:Common.js
An Avatar.Global Resource
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.
/* Any JavaScript here will be loaded for all users on every page load. */
$(document).ready(function() {
// Get the last visited page from localStorage
var lastPage = localStorage.getItem('lastVisitedPage');
// Get the current page title
var currentPage = mw.config.get('wgPageName').replace(/_/g, ' ');
// Store the current page in localStorage for the next visit
if (currentPage !== "Main_Page") { // Avoid setting breadcrumbs for the main page
localStorage.setItem('lastVisitedPage', currentPage);
}
// Display the breadcrumb if a last visited page exists
if (lastPage && lastPage !== currentPage) {
var breadcrumbHtml = `<div class="breadcrumb" style="margin-bottom:10px;">
<a href="/wiki/${encodeURIComponent(lastPage)}">← Back to ${lastPage}</a>
</div>`;
// Insert breadcrumb at the top of the page content
$('#content').prepend(breadcrumbHtml);
}
});
