MediaWiki:Common.js
From Emmy The Robot Fandom Wiki
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)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
if ( mw.config.get( 'wgPageName' ) === 'Main_Page' ) {
document.getElementsByTagName('br')[0].remove();
}
if ( mw.config.get( 'wgPageName' ) === 'Main_Page' ) {
document.getElementsByTagName('h1')[0].remove();
}
// Function to initialize the text parsing and filtering functionality
function initializeTextParser() {
// Create a search input field
var searchInput = document.createElement('input');
searchInput.setAttribute('type', 'text');
searchInput.setAttribute('id', 'mediawiki-text-parser-input');
searchInput.setAttribute('placeholder', 'Type to search1');
document.getElementById('mw-content-text').insertBefore(searchInput, document.getElementById('mw-content-text').firstChild);
// Attach an event listener to the search input field
searchInput.addEventListener('input', function() {
var searchText = this.value.toLowerCase();
// Get all paragraphs in the content area
var paragraphs = document.querySelectorAll ('html.client-js.ve-not-available body.mediawiki.ltr.sitedir-ltr.mw-hide-empty-elt.ns-0.ns-subject.mw-editable.page-List_of_fan_Nandroids.rootpage-List_of_fan_Nandroids.skin-timeless.action-view.skin--responsive div#mw-wrapper.extension-icons div#mw-content-container.ts-container div#mw-content-block.ts-inner div#mw-content-wrapper div#mw-content div#content.mw-body.ve-init-mw-desktopArticleTarget-targetContainer div#bodyContentOuter div#bodyContent div#mw-content-text.mw-body-content.mw-content-ltr div.mw-parser-output div.content-table-wrapper div.content-table table.wikitable.sortable.mw-datatable.jquery-tablesorter p');
// Loop through each paragraph
for (var i = 0; i < paragraphs.length; i++) {
var paragraph = paragraphs[i];
var paragraphText = paragraph.textContent.toLowerCase();
// Check if the paragraph contains the search text
if (paragraphText.includes(searchText)) {
paragraph.style.display = 'block'; // Show the paragraph
} else {
paragraph.style.display = 'none'; // Hide the paragraph
}
}
});
}
// Call the initializeTextParser function when the DOM is ready
function initializeTextParserOnLoad() {
if (document.readyState === "complete" || (document.readyState !== "loading" && !document.documentElement.doScroll)) {
// The DOM has already loaded, so call initializeTextParser immediately
initializeTextParser();
} else {
// Wait for the DOMContentLoaded event to call initializeTextParser
document.addEventListener('DOMContentLoaded', initializeTextParser);
}
}
// Call the initializeTextParserOnLoad function when the entire page is loaded
window.onload = initializeTextParserOnLoad;