More actions
Created page with "→Any JavaScript here will be loaded for all users on every page load.: $(function() { var lastModified = new Date(document.lastModified); $('#sidebar').append('<div>Last Modified: ' + lastModified.toLocaleDateString() + '</div>'); });" |
No edit summary |
||
| Line 1: | Line 1: | ||
/ | $(document).ready(function() { | ||
$( | // Wait for the document to be fully loaded before making changes | ||
setTimeout(function() { | |||
// Assuming the last modified text is inside an element with class 'lastmodified' | |||
var lastModifiedElement = $('.lastmodified'); | |||
if (lastModifiedElement.length > 0) { // Check if the element exists | |||
// Get the current date and format it nicely | |||
var lastModified = new Date(document.lastModified); | |||
var formattedDate = lastModified.toLocaleDateString() + " " + lastModified.toLocaleTimeString(); | |||
// Update the text content | |||
lastModifiedElement.text("Last Modified: " + formattedDate); | |||
// Apply styles for better readability | |||
lastModifiedElement.css({ | |||
'background-color': '#f0f0f0', // Light grey background | |||
'color': '#333', // Dark grey text for contrast | |||
'padding': '5px', | |||
'border-radius': '3px', | |||
'font-family': 'Arial, sans-serif', | |||
'font-size': '12px' | |||
}); | |||
} else { | |||
// If no specific element found, maybe append to sidebar or create one | |||
var sidebar = $('#mw-panel'); | |||
if (sidebar.length > 0) { | |||
var newElement = $('<div class="lastmodified">Last Modified: ' + formattedDate + '</div>'); | |||
newElement.css({ | |||
'background-color': '#f0f0f0', | |||
'color': '#333', | |||
'padding': '5px', | |||
'margin': '5px 0', | |||
'border-radius': '3px', | |||
'font-family': 'Arial, sans-serif', | |||
'font-size': '12px' | |||
}); | |||
sidebar.prepend(newElement); | |||
} | |||
} | |||
}, 500); // Small delay to ensure sidebar is fully loaded | |||
}); | }); | ||
Latest revision as of 13:48, 20 December 2024
$(document).ready(function() {
// Wait for the document to be fully loaded before making changes
setTimeout(function() {
// Assuming the last modified text is inside an element with class 'lastmodified'
var lastModifiedElement = $('.lastmodified');
if (lastModifiedElement.length > 0) { // Check if the element exists
// Get the current date and format it nicely
var lastModified = new Date(document.lastModified);
var formattedDate = lastModified.toLocaleDateString() + " " + lastModified.toLocaleTimeString();
// Update the text content
lastModifiedElement.text("Last Modified: " + formattedDate);
// Apply styles for better readability
lastModifiedElement.css({
'background-color': '#f0f0f0', // Light grey background
'color': '#333', // Dark grey text for contrast
'padding': '5px',
'border-radius': '3px',
'font-family': 'Arial, sans-serif',
'font-size': '12px'
});
} else {
// If no specific element found, maybe append to sidebar or create one
var sidebar = $('#mw-panel');
if (sidebar.length > 0) {
var newElement = $('<div class="lastmodified">Last Modified: ' + formattedDate + '</div>');
newElement.css({
'background-color': '#f0f0f0',
'color': '#333',
'padding': '5px',
'margin': '5px 0',
'border-radius': '3px',
'font-family': 'Arial, sans-serif',
'font-size': '12px'
});
sidebar.prepend(newElement);
}
}
}, 500); // Small delay to ensure sidebar is fully loaded
});