User:UnauthorizedPerson/common.js

/* Any JavaScript here will be loaded for all users on every page load. */ window.DiscussionTemplates = { templates: { 'item-1': { name: 'Template:Staff', title: 'Staff' }   },    allowedGroups: ['bureaucrat','sysop', 'content-moderator', 'threadmoderator', 'rollback'] }; window.UserTagsJS = { modules: {}, tags: { // group: { associated tag data } wikimanager: {u:'Wiki Manager', order: -1/0}, forummanager: {u:'Forums Manager', order: -1/0}, creator: {u:'The CSS Guy', order: -1e76}, montheditor: { u:'Editor of the Month', order: -1e75}, cool: { u:'Certified Cool Kid', order: -1e70}, former: {u:'Former Staff', order: -1e50}, formerowner: {u:'Former Owner', order: -1e69}, god: {u:'God of the Wiki', order: -1e100}, nothing: {u: '⠀⠀⠀', order: -1e100}, bureaureal: {u: 'BUREAUREAL', order: -1e110}, } }; UserTagsJS.modules.custom = { 'YataDev': ['cool', 'formerowner'], 'Sanjay2133': ['wikimanager', 'creator', 'cool'], 'Oh Noez! Oh Noez!': ['forumsmanager'], 'SodafizzIGuess': ['former'], 'AlsoOmori': ['former'], 'IdklolXDXDXD': ['former'], 'TheOquas': ['former'], 'Bruhshard1': ['former'], 'YourNuglyguy': ['formerowner', 'god'], 'Ferdinandloveslegos': ['formerowner'], 'The Difficulty Enthusiast': ['formerowner'], 'OrbentuneAlt': ['nothing'], 'Jtohisgoodimo': ['bureaureal'], 'Touchgrass210779': ['montheditor'], 'MapleIsNotAMapleLeaf': ['montheditor'] }; window.quizName = "The Hard Quiz"; window.quizLang = "en"; window.resultsTextArray = [ "You suck so much, that's REALLY sad.", "mid", "You're clearly the biggest Babassian fan ever" ]; window.questions = [ ["sin 120°", "√3/2",   "√2/2",    "1/2",    "-√2/2",    "-√3/2",    "-1/2"],

["sin 30°", "1/2",   "√2/2",    "√3/2",    "-√2/2",    "-√3/2",    "-1/2"],

["sin 45°", "√2/2",   "√3/2",    "1/2",    "-√2/2",    "-√3/2",    "-1/2"], ]; window.lockOldComments = (window.lockOldComments || {}); window.lockOldComments.limit = 180; window.AutoCreateUserPagesConfig = { content: { 2: '',       3: false, 1202: false },   summary: 'Creating user page', notify: 'Here is a link to your userpage, $1!' }; mw.loader.using('mediawiki.api', function {	var config = mw.config.get([ 'wgNamespaceNumber', 'wgRelevantUserName', 'wgServer', // Wiki URL 'wgSiteName', // Wiki Name 'wgContentLanguage' // Wiki Language Code ]);	if (config.wgNamespaceNumber !== 2) {		console.error("The page is not a \"User\" namespace page. BlockSummary.js aborted!")		return; // Only run in "User" namespace.	}	if (config.wgRelevantUserName === null) {		console.error("No relevant username attributed to the current viewed page. BlockSummary.js aborted!")		return; // Only run in "User" namespace.	}	var wiki_name = config.wgSiteName;	var wiki_url = config.wgServer;	var wiki_lang = config.wgContentLanguage;	var wiki_lang_for_url = "";	if (wiki_lang !== "en") {		wiki_lang_for_url = "/" + wiki_lang;	}	wiki_url = wiki_url + wiki_lang_for_url;	// If the wiki is not English, add language code next to the site name.	if (wiki_lang !== "en") {		lang_for_wiki_name = " (" + wiki_lang + ")";	}	else {		lang_for_wiki_name = "";	}	var user = config.wgRelevantUserName; // grabbing username of user blocked	var url_user = user.replace(/ /g, "_"); var api = new mw.Api, data; var blockr, blockID, blockperformer, blocktime, expire; // declaring variables for api.get var parsedBlockReason; // parsed reason stored from parse API output var startDate, startTime, startHour, startMinute, startSecond, start_am_pm, blockStartDateTime, blockStartDateTimeHHMMSS; // start time variables var endDate, endTime, endHour, endMinute, endSecond, blockEndDateTime, blockEndDateTimeHHMMSS; // end time variables var temp; // declaring variable for formatting text var lang_for_wiki_name;

api.get({		action: 'query',		list: 'blocks',		bkusers: user,	}).then(function(d) {		data = d.query.blocks;		// if the user is not blocked, terminate program		if (data === undefined || data.length < 1) { 			return;		}		blockr = data[0].reason; // fetching block reason		blockID = data[0].id; // fetching block ID		blockperformer = data[0].by; // fetching block performer		blockperformer_url = blockperformer.replace(/ /g, "_");		blocktime = data[0].timestamp; // fetching block start time		expire = data[0].expiry; // fetching block expiration		if (window.BlockSummary || !user)			return;		window.BlockSummary = true;		//--- | Main Function for Block Report | ---//		function main(user, blockreason, blockID, blockperformer, blockperformer_url, blocktime, blockexpire) {						// Passing wikitext for parsing			console.log("%c[RUNNING] Parsing block reason wikitext...", "background: #F9F983; color: black"); api.parse(blockreason).done(function(textOutput) {				console.log("%c[PASSED] Parsing block reason wikitext.", "background: limegreen; color: black");				parsedBlockReason = textOutput;				// console.log("[INFO] parsedBlockReason: " + parsedBlockReason);				//--- | Block Start Time | ---//				console.log("%c[RUNNING] Block (Start) Timestamp Process...", "background: #F9F983; color: black");				temp = blocktime.split("T"); 				startDate = temp[0];				temp = temp[1].split("Z");				startTime = temp[0];				blockStartDateTimeHHMMSS = startTime.split(":"); // Splitting time into hours, minutes, seconds as array (blockEndDateTimeHHMMSS = {HH, MM, SS})				startMinute = blockStartDateTimeHHMMSS[1]; // MM				startSecond = blockStartDateTimeHHMMSS[2]; // SS				if (parseInt(blockStartDateTimeHHMMSS[0]) == 0) {					startHour = "12";					start_am_pm = "AM";					// console.log("blockEndDateTimeHHMMSS parseInt: " + blockEndDateTimeHHMMSS); }				else if (parseInt(blockStartDateTimeHHMMSS[0]) == 12) { startHour = "12"; start_am_pm = "PM"; }				else if (parseInt(blockStartDateTimeHHMMSS[0]) > 12) { startHour = parseInt(blockStartDateTimeHHMMSS[0])-12; startHour = startHour.toString; start_am_pm = "PM"; }				else { startHour = blockStartDateTimeHHMMSS[0]; startHour = startHour.toString; start_am_pm = "AM"; }				// Formatting Start Time startTime = startHour + ":" + startMinute + ":" + startSecond + " " + start_am_pm; blockStartDateTime = startDate + ", " + startTime + " (UTC)"; console.log("%c[PASSED] Block (Start) Timestamp Process", "background: limegreen; color: black"); // console.log("[INFO] blockStartDateTime: " + blockStartDateTime); //--- | Time Formatting for Block End Time | ---// console.log("%c[RUNNING] Block (End) Timestamp Process...", "background: #F9F983; color: black"); if (blockexpire == "infinity") { blockEndDateTime = "infinity"; }				else { temp = blockexpire.split("T"); endDate = temp[0]; temp = temp[1].split("Z"); endTime = temp[0]; blockEndDateTime = endDate + ", " + endTime + " UTC"; blockEndDateTimeHHMMSS = endTime.split(":"); // Splitting time into hours, minutes, seconds as array (blockEndDateTimeHHMMSS = {HH, MM, SS}) endMinute = blockStartDateTimeHHMMSS[1]; endSecond = blockStartDateTimeHHMMSS[2]; // console.log("blockEndDateTimeHHMMSS[0]: " + blockEndDateTimeHHMMSS[0]); temp = parseInt(blockEndDateTimeHHMMSS[0])-12; // console.log("End Hour: " + temp.toString); if (parseInt(blockEndDateTimeHHMMSS[0]) == 0) { endHour = "12"; end_am_pm = "AM"; // console.log("blockEndDateTimeHHMMSS parseInt: " + blockEndDateTimeHHMMSS); }					else if (parseInt(blockEndDateTimeHHMMSS[0]) == 12) { endHour = "12"; end_am_pm = "PM"; }					else if (parseInt(blockEndDateTimeHHMMSS[0]) > 12) { endHour = parseInt(blockEndDateTimeHHMMSS[0])-12; endHour = endHour.toString; end_am_pm = "PM"; }					else { endHour = blockEndDateTimeHHMMSS[0]; endHour = endHour.toString; end_am_pm = "AM"; }					// Formatting End Time endTime = endHour + ":" + endMinute + ":" + endSecond + " " + end_am_pm; blockEndDateTime = endDate + ", " + endTime + " (UTC)"; }				console.log("%c[PASSED] Block (End) Timestamp Process", "background: limegreen; color: black"); // console.log("[INFO] blockEndDateTime: " + blockEndDateTime); //--- | HTML Display of Block Report | ---// console.log("%c[RUNNING] Creating HTML Display of Block Report...", "background: #F9F983; color: black"); var Box = document.createElement("div"); // Box Box.style.marginTop = "1em"; // setting top-margin for Box Box.style.marginBottom = "1em"; // setting bottom-margin for Box Box.style.paddingTop = "1em"; // setting padding-top for Box Box.style.paddingLeft = "1em"; // setting padding-left for Box Box.style.paddingRight = "1em"; // setting padding-right for Box Box.style.paddingBottom = "1em"; // setting padding-bottom for Box // adding classes for Box -- these classes are made by Fandom Box.classList.add("warningbox"); Box.classList.add("mw-warning-with-logexcerpt"); Box.classList.add("mw-content-ltr"); var textParagraph = document.createElement("p"); // create a text paragraph textParagraph.innerHTML = " " + "" + user + " is currently blocked on " + "" + wiki_name + "" + lang_for_wiki_name + " . " + " " + wiki_url + "/wiki/User:" + url_user + " " + "" + "Block Log " + "Block Information " + "Username: " + user + " Block ID: " + blockID + " Block Performer: " + blockperformer + "</a>" + " Block Start: " + blockStartDateTime + " Block Expiry: " + blockEndDateTime + " Block Reason: <blockquote style=\"border-left: 5px solid rgba(var(--theme-alert-color--rgb), 0.5); padding-left: 0.5em;\">" + parsedBlockReason + " "; Box.appendChild(textParagraph); // apply all text configurations into Box console.log("%c[DONE] HTML Display of Block Report", "background: limegreen; color: black"); //--- | Using setInterval to ensure prepending of Box to content page | ---// var interval = setInterval(function {					if ($('.ns-2 #content').length) {						clearInterval(interval);						$(".ns-2 #content").eq(0).before(Box); // prepending Box to ".ns-2 #content"					}				}, 1000); });		}		main(user, blockr, blockID, blockperformer, blockperformer_url, blocktime, expire); // executing function	}); });