User:Vastmine1029/global.js

// Show all announcements except those from the following [city_id] wikis window.announcementsIgnore = { option: 'opt-in-all', exceptWikiIds: [ 2502419, /* the-avocados */ 2009968, /* blox-fruits */ 2170197, /* bgs-community-content */ 1435365 /* sing */ ] };

importArticles({   type: 'script',    articles: [    	'u:dev:MediaWiki:AjaxBatchDelete.js',    	'u:dev:MediaWiki:AnnouncementsIgnore.js',    	//'u:dev:MediaWiki:BlockSummary.js',    	'u:dev:MediaWiki:DisableCode/code2.js',    	'u:dev:MediaWiki:Discussions Delete All/code.js',        'u:dev:MediaWiki:DisplayTimer/code.js',		'u:dev:MediaWiki:LastEdited/code.js',		'u:dev:MediaWiki:MassBlock/code.js',		'u:dev:MediaWiki:MassEdit/code.js',		'u:dev:MediaWiki:MarkBlocked.js',		'u:dev:MediaWiki:PortableCSSPad/code.js',		/*'u:dev:MediaWiki:QuickBarPageTools.js',*/		'u:dev:MediaWiki:QuickDiff/code.js',		'u:dev:MediaWiki:Rollback/code.js',		'u:dev:MediaWiki:ShowUserGroups.js',		'u:dev:MediaWiki:Status/code.js',		'u:dev:MediaWiki:SyntaxHighlight.js',		'u:dev:MediaWiki:ThemeToggler.js',		'u:dev:MediaWiki:UserAccountAge/code2.js',		/*'u:dev:MediaWiki:UserAndIPTools.js', - Not compatible*/		'u:dev:MediaWiki:WHAM/code.2.js', "User:Vastmine1029/common.js" ] });

/* Credits to joritochip :) */ mw.hook("wikipage.content").add(function($content) { var links = $('#mw-content-text a.new'); links.each(function(index, element){       if (!$(element).attr('href')) {            var title = $(element).attr('title');            if (title.startsWith('User:') && title.endsWith('(page does not exist)')) {                title = title.slice(0, -22);                var decodedURL = mw.util.getUrl(title);                $(element).removeAttr('data-uncrawlable-url');                $(element).attr('href', decodedURL);            }        }    }); }); mw.loader.using('mediawiki.api', function { 'use strict'; var user = mw.config.get('wgRelevantUserName'); if (		window.DiscussionPLReady ||		!user	) return; window.DiscussionPLReady = true; var api = new mw.Api, data, id; api.get({		action: 'query',		list: 'users',		ususers: user	}).then(function(d) {		data = d.query.users;		if (!data.length) return;		id = data[0].userid;		var interval = setInterval(function { if ($('#userProfileApp .user-profile-navigation').length) { clearInterval(interval); var identity = $('.user-identity-stats a[href^="/wiki/Special:UserProfileActivity/'+user+'"]'); if (identity.length) { identity.each(function {						$(this).attr('href', '/f/u/'+id);					}); }			}		}, 1000);	}); });

/* https://adoptme.fandom.com/api.php?action=query&list=users&ususers=Shaki123Ss&usprop=blockinfo|groups|editcount|registration|emailable|gender*/ /*api.php?action=query&list=blocks&bkusers=USERNAME

/*mw.loader.using('mediawiki.api', function {	'use strict'; });*/

$(function {	if ($(".wds-banner-notification__text").html.includes("trivia")) {		$(".wds-banner-notification").remove;	}		else {		return;	} });

/************* Title       :   BlockSummary Description :   Displaying a summary of user's block on the blocked user's "User" Namespace pages Author      :   Vastmine1029 Version     :   1.0

/* https://adoptme.fandom.com/api.php?action=query&list=users&ususers=USERNAME&usprop=blockinfo|groups|editcount|registration|emailable|gender

mw.loader.using('mediawiki.api', function {	var user = mw.config.get('wgRelevantUserName'); // grabbing username of user blocked	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 variables for formatting text	var sitename, domain, rootdomain, subdomain;

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		blocktime = data[0].timestamp; // fetching block start time		expire = data[0].expiry; // fetching block expiration		api.get({ action: 'query', meta: 'siteinfo' }).then(function(d) { data = d.query.general; sitename = data["sitename"]; domain = data["server"] + data["scriptpath"]; rootdomain = data["servername"]; var rootDomainBreakdown = rootdomain.split("."); subdomain = rootDomainBreakdown[0]; });		// Checking MediaWiki Version		var ucp = mw.config.get('wgVersion') !== '1.19.24';		var selector = ucp ? $('.page-header__separator') : $('#contentSub > a:last-child');		if (window.BlockReport || !user)			return;		window.BlockReport = true;		//--- | Main Function for Block Report | ---//		function main(user, blockreason, blockID, blockperformer, 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 // 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 " + "" + sitename + "  . " + "" + "Block Information " + "Username: " + user + " Block ID: " + blockID + " Block Performer: " + blockperformer + "" + " Block Start: " + blockStartDateTime + " Block Expiry: " + blockEndDateTime + " Block Reason: " + parsedBlockReason + " "; //console.log("Parse Output (main): " + 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')) {						clearInterval(interval);						$(".ns-2 #content").eq(0).before(Box); // prepending Box to ".ns-2 #content"					}				}, 1000); });		}		main(user, blockr, blockID, blockperformer, blocktime, expire); // executing function	}); });