User:Shelkovitsa/common.js

Hello, you have come here looking for the meaning of the word User:Shelkovitsa/common.js. In DICTIOUS you will not only get to know all the dictionary meanings for the word User:Shelkovitsa/common.js, but we will also tell you about its etymology, its characteristics and you will know how to say User:Shelkovitsa/common.js in singular and plural. Everything you need to know about the word User:Shelkovitsa/common.js you have here. The definition of the word User:Shelkovitsa/common.js will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofUser:Shelkovitsa/common.js, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.
mw.loader.load('https://en.wikipedia.orghttps://en.wiktionary.org/w/index.php?action=raw&ctype=text/javascript&title=User:MusikAnimal/customWatchlists.js');
importScript("User:Shelkovitsa/fullwidthSlash.js");

// Removes pesky <br>s from my horizontal ".Mong" text.
var elements = document.querySelectorAll('.citation-whole, .h-usage-example, .h-quotation, .e-quotation, figcaption, .NavFrame, .nyms');

elements.forEach(function (element) {
	var mongElements = element.getElementsByClassName('Mong');
	
	for (var j = 0; j < mongElements.length; j++) {
		var content = mongElements.innerHTML;
		var updatedContent = content.replace(/<br>/g, ' ');
		mongElements.innerHTML = updatedContent;
	}
});

// Makes my mobile viewing experience of certain language headwords just a little bit better.
var paragraphs = document.getElementsByTagName('p');

for (var i = 0; i < paragraphs.length; i++) {
	var paragraph = paragraphs;

	var hasHeadwordLineChild = paragraph.querySelector('span.headword-line');

	if (hasHeadwordLineChild) {
		var htmlContent = paragraph.innerHTML;
		var updatedContent = htmlContent.replace(/&nbsp;/g, ' ');
		updatedContent = updatedContent.replace(/ (?=<sup>)/g, '');
		paragraph.innerHTML = updatedContent;
	}
}

// Make every ".wikitable.floatright" have ".kanji-table" added to it.
// Now, when "Alternative spelling" comes after "Kanji in this tab", they will have the same styling!
// How neat.
var sourceTables = document.querySelectorAll('.wikitable.floatright, .kanji-forms');

sourceTables.forEach(function (sourceTable) {
	if (hasJpanClass(sourceTable)) {
		sourceTable.classList.add('kanji-table');
	}
});

function hasJpanClass(element) {
	var descendants = element.querySelectorAll('.Jpan');
	return descendants.length > 0;
}

// Create hanzi-tables. They're like kanji-tables, but hanzi!
var tables = document.querySelectorAll('table');

tables.forEach(function(table) {
	if (
		table.getAttribute('style') === 'clear: right;margin: 1em 0 1em 1em;border-collapse: collapse;text-align: center'
	) {
		table.classList.add('wikitable', 'hanzi-table');
	}
});

// Remove the trailing "&nbsp;" from the class "vsToggleElement" because it messes with my hanzi-tables on mobile.
var elements = document.querySelectorAll('span.vsToggleElement');
for (var i = 0; i < elements.length; i++) {
	elements.innerHTML = elements.innerHTML.replace(/&nbsp;/g, '<br>');
}