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.
// document.addEventListener("DOMContentLoaded", function() { // // Get the current page title from MediaWiki config // var pageTitle = mw.config.get('wgPageName'); // console.log("P TITLE" : pageTitle) // // Construct the URL using the current origin and encode the page title // var fetchUrl = window.location.origin + '/w/index.php?title=' + encodeURIComponent(pageTitle) + '&action=info'; // fetch(fetchUrl) // .then(response => response.text()) // .then(data => { // // Parse the returned HTML // const parser = new DOMParser(); // const doc = parser.parseFromString(data, 'text/html'); // // Select the creation date and page views elements. // // Note: Adjust these selectors if the structure on Wikivoyage differs. // const creationDateElement = doc.querySelector('#mw-pageinfo-firsttime td:nth-child(2) a'); // const pageViewsElement = doc.querySelector('#mw-pvi-month'); // // Create a new div to display the info // const infoDiv = document.createElement('div'); // infoDiv.style.position = 'absolute'; // infoDiv.style.top = '2.15cm'; // infoDiv.style.right = '5%'; // infoDiv.style.fontSize = 'small'; // infoDiv.style.color = 'red'; // infoDiv.style.backgroundColor = 'rgba(255, 255, 102, 0.24)'; // // Build the text content if the elements exist // let infoText = ""; // if (creationDateElement) { // infoText += "Page created: " + creationDateElement.textContent.trim(); // } // infoText += "\n"; // if (pageViewsElement) { // infoText += "Page views: " + pageViewsElement.textContent.trim(); // } // infoDiv.textContent = infoText; // // Append the div to the body of the page // document.body.appendChild(infoDiv); // }) // .catch(error => { // console.error('Error fetching page info:', error); // }); // });