User:DarkMatterMan4500/global.js

// Global TW mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Xiplus/TwinkleGlobal.js&action=raw&ctype=text/javascript');

// Tools/Navigation popups mw.loader.load('https://en.wikipedia.org/w/load.php?modules=ext.gadget.Navigation_popups'); if ( (mw.config.get("wgDBname") !== "wikidatawiki") && (mw.config.get("wgDBname") !== "testwikidatawiki") ) { // Don't work in Wikidata // Fork of Twinkle intended to work on as many wikis as possible mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:DarkMatterMan4500/TwinkleGlobal.js&action=raw&ctype=text/javascript'); }

// mw.loader.load("//en.wikipedia.org/w/index.php?title=User:Zhaofeng_Li/Reflinks.js&action=raw&ctype=text/javascript"); mw.loader.load("//en.wikipedia.org/w/index.php?title=User:DannyS712/PermaLinkSection.js&action=raw&ctype=text/javascript"); // Backlink: User:DannyS712/PermaLinkSection.js mw.loader.load("//en.wikipedia.org/w/index.php?title=User:DannyS712/Easy-link.js&action=raw&ctype=text/javascript"); // Backlink: User:DannyS712/Easy-link.js mw.loader.load("//en.wikipedia.org/w/index.php?title=User:Writ_Keeper/Scripts/markBlocked.js&action=raw&ctype=text/javascript"); // Backlink: User:Writ Keeper/Scripts/markBlocked.js mw.loader.load("//en.wikipedia.org/w/index.php?title=User:Enterprisey/diff-permalink.js&action=raw&ctype=text/javascript"); // Backlink: User:Enterprisey/diff-permalink.js mw.loader.load('https://en.wikipedia.org/w/load.php?modules=ext.gadget.Navigation_popups'); // Backlink: Tools/Navigation popups mw.loader.load("//en.wikipedia.org/wiki/User:Kbh3rd/whackamole.js"); // Backlink: User:Kbh3rd/whackamole.js mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:BrandonXLF/Restorer.js&action=raw&ctype=text/javascript'); // Backlink: User:BrandonXLF/Restorer // mw.loader.load('//en.wikipedia.org/w/index.php?action=raw&ctype=text/javascript&title=User:Writ_Keeper/Scripts/massRevdel.js'); mw.loader.load('//meta.miraheze.org/w/index.php?title=MediaWiki:Gadget-CentralAuthInterlinkFixer.js&action=raw&ctype=text/javascript'); mw.loader.load('/en.wikipedia.org/wiki/User:Path_slopu/scripts/RBK-assist.js'); mw.loader.load('//commons.wikimedia.org/wiki/User:Mdaniels5757/cuStaleness.js'); mw.loader.load('//meta.miraheze.org/wiki/User:DarkMatterMan4500/easyblock-modern.js'); mw.loader.load('//meta.miraheze.org/wiki/User:DarkMatterMan4500/mark-locked.js'); mw.loader.load('//en.wikipedia.org/w/index.php?action=raw&ctype=text/javascript&title=User:Writ_Keeper/Scripts/massRollback.js'); // Global preferences mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:BrandonXLF/GlobalPrefs.js&action=raw&ctype=text/javascript'); // SubpageMover mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:BrandonXLF/SubpageMover.js&action=raw&ctype=text/javascript');

// ParameterSpacing mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:BrandonXLF/ParameterSpacing.js&action=raw&ctype=text/javascript');

// Based on alaa's script mw.loader.using( [ 'mediawiki.util', 'oojs-ui-windows', 'mediawiki.ForeignApi' ], function {	mw.util.addPortletLink ( 'p-tb', "#", "Shorten URL", 'pt-shortenURL', "Make short URL" );	$("#pt-shortenURL").click (function { //Fetch Short URL from Meta tool var api = new mw.ForeignApi( 'https://meta.wikimedia.org/w/api.php' ); api.post({				action: 'shortenurl',				format: 'json',				url: window.location.href			}).then( function( response ) {				window.prompt("Copy your link", response.shortenurl.shorturl);			}); }); });

// Wiki-Labels mw.loader.load( '//labels.wmflabs.org/gadget/loader.js' );

mw.loader.load('//de.wikipedia.org/w/index.php?title=Benutzer:TMg/autoFormatter.js&action=raw&ctype=text/javascript'); var autoFormatReplacements = [ [/ +<ref\b/g, '<ref'] ];

// Tools/Navigation popups // mw.loader.load('https://en.wikipedia.org/w/index.php?title=MediaWiki:Gadget-popups.js&action=raw&ctype=text/javascript'); // mw.loader.load('https://en.wikipedia.org/w/index.php?title=MediaWiki:Gadget-navpop.css&action=raw&ctype=text/css', 'text/css');

// Linkback: MoreMenu mw.loader.load('https://meta.wikimedia.org/w/index.php?action=raw&ctype=text/javascript&title=MediaWiki:MoreMenu.import.js');

// EditWarChecker Evad37/EditWarChecker // mw.loader.load('https://en.wikipedia.org/wiki/User:Evad37/EditWarChecker.js');

// SRGL mw.loader.load('https://meta.wikimedia.org/wiki/User:Awesome_Aasim/SRGL.js');

// Chunked uploads // mw.loader.load( 'https://commons.wikimedia.org/w/index.php?title=User:Rillke/bigChunkedUpload.js&action=raw&ctype=text/javascript' );

// User:YMS/ORC // mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:YMS/orc.js&action=raw&ctype=text/javascript', 'text/javascript');

// userinfo.js mw.loader.load('//en.wikipedia.org/w/index.php?title=User:PleaseStand/userinfo.js&action=raw&ctype=text/javascript');

// WordCount.js mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Caorongjin/wordcount.js&action=raw&ctype=text/javascript');

// Short description // mw.loader.getScript( '//en.wikipedia.org/w/index.php?title=MediaWiki:Gadget-libSettings.js&action=raw&ctype=text/javascript' ).then ( // function { //	mw.loader.load( '//en.wikipedia.org/w/index.php?title=MediaWiki:Gadget-Shortdesc-helper.css&action=raw&ctype=text/css', 'text/css'); //	mw.loader.load( '//en.wikipedia.org/w/index.php?title=MediaWiki:Gadget-Shortdesc-helper.js&action=raw&ctype=text/javascript' ); // }); // @ts-check // Companion to markblocked - asynchronously marks locked users // Chunks borrowed from User:Krinkle/Scripts/CVNSimpleOverlay_wiki.js, // User:GeneralNotability/ip-ext-info.js, and MediaWiki:Gadget-markblocked.js

/** * Get all userlinks on the page * * @param {JQuery} $content page contents * @return {Map} list of unique users on the page and their corresponding links */ function lockedUsers_getUsers($content) { const userLinks = new Map;

// Get all aliases for user: & user_talk: (taken from markblocked) const userNS = []; for ( const ns in mw.config.get( 'wgNamespaceIds' ) ) { if ( mw.config.get( 'wgNamespaceIds' )[ns] === 2 || mw.config.get( 'wgNamespaceIds' )[ns] === 3 ) { userNS.push( mw.util.escapeRegExp(ns.replace( /_/g, ' ' )) + ':' ); }	}

// RegExp for all titles that are User:| User_talk: | Special:Contributions/ (for userscripts) const userTitleRX = new RegExp( '^(' + userNS.join( '|' ) + '|' + 'Special:Contributions' + '\\/)+([^\\/#]+)$', 'i' ); const articleRX = new RegExp( mw.config.get( 'wgArticlePath' ).replace('$1', '') + '([^#]+)' ); $('a', $content).each(function {		if (!$(this).attr('href')) {			// Ignore if the  doesn't have a href			return;		}		const articleTitleReMatch = articleRX.exec($(this).attr('href').toString);		if (!articleTitleReMatch) {			return;		}		const pgTitle = decodeURIComponent( articleTitleReMatch[1] ).replace( /_/g, ' ' );		const userTitleReMatch = userTitleRX.exec(pgTitle);		if (!userTitleReMatch) {			return;		}		const username = userTitleReMatch[2];		if (!mw.util.isIPAddress(username, true)) {			if (!userLinks.get(username)) {				userLinks.set(username, []);			}			userLinks.get(username).push($(this));		}	}); return userLinks; }

/** * Check whether a user is locked * * @param {string} user Username to check * * @return {Promise } Whether the user in question is locked */ async function lockedUsers_isLocked(user) { const api = new mw.Api; try { const response = await api.get({			action: 'query',			list: 'globalallusers',			agulimit: '1',			agufrom: user,			aguto: user,			aguprop: 'lockinfo'		}); if (response.query.globalallusers.length === 0) { // If the length is 0, then we couldn't find the global user return false; }		// If the 'locked' field is present, then the user is locked return 'locked' in response.query.globalallusers[0]; } catch (error) { return false; } }

// On window load, get all the users on the page and check if they're blocked $.when( $.ready, mw.loader.using( 'mediawiki.util' ) ).then( function {	mw.hook('wikipage.content').add(function ($content) { const usersOnPage = lockedUsers_getUsers($content); usersOnPage.forEach(async (val, key, _) => {			const userLocked = await lockedUsers_isLocked(key);			if (userLocked) {				val.forEach(($link) => { $link.css({ opacity: 0.4, 'border-bottom-size': 'thick', 'border-bottom-style': 'dashed', 'border-bottom-color': 'red' }); });			}		});	}); });