User:Tpbradbury/monobook.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | The accompanying .css page for this skin is at User:Tpbradbury/monobook.css. |
// Monobook.js is loading
console.log('Monobook.js is loading');
// HighlightUnreferencedPassages.js is loading
console.log('HighlightUnreferencedPassages.js is loading');
// Document ready
document.addEventListener('DOMContentLoaded', function () {
console.log('Document ready');
// Stylesheet added
console.log('Stylesheet added');
// highlightUnreferencedPassages function is executed
console.log('highlightUnreferencedPassages function is executed');
// Find the mw-content-text element
var contentText = document.getElementById('mw-content-text');
if (contentText) {
console.log('mw-content-text element found');
// Get all elements to be highlighted
var elementsToHighlight = contentText.querySelectorAll('.highlight-unreferenced');
console.log('Total elements found:', elementsToHighlight.length);
// Find the references section
var referencesSection = contentText.querySelector('#References, .references');
var stopHighlighting = false;
// Iterate through elements to be highlighted
elementsToHighlight.forEach(function (element) {
// Stop if the references section is reached
if (referencesSection && referencesSection.compareDocumentPosition(element) & Node.DOCUMENT_POSITION_FOLLOWING) {
stopHighlighting = true;
}
if (!stopHighlighting) {
// Highlight unreferenced element
element.classList.add('highlighted');
console.log('Highlighted unreferenced element:', element);
}
});
}
console.log('Highlighting completed');
});