Jump to content

User:CodeMyGame Wiki/common.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
//console.log(window.location.href);
/* jshint esversion: 8 */

function loadJQuery() {
	var script_tag = document.createElement("<script>");
	script_tag.src("https://code.jquery.com/jquery-3.6.1.js");
	document.getElementsByTagName("head")[0].appendChild(script_tag);
	
}

function checkURl() {
	if (document.title.includes("Typo Team")) {
		document.title = "TYPO";
	}
	
	if (window.location.href == "https://en.wikipedia.org/wiki/Wikipedia:Typo_Team") {
		fetch("https://en.wikipedia.org/wiki/Wikipedia:Typo_Team/moss")
			.then(function (response) { return response.text(); })
			.then(function (text) {
				var html = $(text);
				var stuff = html.find("#mw-content-text > div.mw-parser-output > ul:nth-child(50)");
				stuff.children().each(function () {
					$(this).children("b").each(function() {
						if ($(this)) {
							var target_link = $(this).children("a").prop("href");
							if (target_link.startsWith("https://en.wikipedia.org/")) {
								window.location.replace(target_link);	
							}
						}
					})
				});
			});
	}
}

checkURl();