|
|
| (3 intermediate revisions by the same user not shown) |
| Line 1: |
Line 1: |
| /* Any JavaScript here will be loaded for all users on every page load. */ | | /* 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);
| |
| }
| |
| });
| |