Jump to content

User:Clumsystiggy/common.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Clumsystiggy (talk | contribs) at 21:04, 21 August 2023. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
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.
importScript('User:BrandonXLF/RedirectNotification.js'); // [[User:BrandonXLF/RedirectNotification.js]]
importScript('User:BrandonXLF/TodoList.js'); // [[User:BrandonXLF/TodoList.js]]
importScript('User:BrandonXLF/ToTopButton.js'); // [[User:BrandonXLF/ToTopButton.js]]
importScript( 'User:Ravid ziv/highlightSearch.js' ); // Backlink: [[User:Ravid ziv/highlightSearch.js]]
importScript('User:BrandonXLF/FindSources.js'); // [[User:BrandonXLF/FindSources.js]]
importScript( 'User:Mxn/CommentsInLocalTime.js' ); // Backlink: [[User:Mxn/CommentsInLocalTime.js]]


mw.config.get('wgNamespaceNumber') === 0 &&
mw.config.get('wgAction') === 'view' &&
mw.loader.using('mediawiki.api').then(() => (
	new mw.Api().get({
		action: 'query',
		titles: 'Talk:' + mw.config.get('wgTitle'),
		prop: 'categories',
		clcategories: 'Category:Wikipedia level-1 vital articles|Category:Wikipedia level-2 vital articles|Category:Wikipedia level-3 vital articles|Category:Wikipedia level-4 vital articles|Category:Wikipedia level-5 vital articles|Category:Wikipedia level-unknown vital articles',
		formatversion: 2,
		maxage: 86400,
		smaxage: 86400
	})
)).then(response => {
	let cat = (((((response || {}).query || {}).pages || [])[0] || {}).categories || [])[0];
	if (!cat) return;
	let level = cat.title.match(/^Category:Wikipedia level-(.+) vital articles$/)[1];
	let $icon = $('<div>').attr({
		id: 'mw-indicator-vital-article',
		class: 'mw-indicator'
	}).append(
		$('<a>').attr({
			href: `/wiki/Wikipedia:Vital_articles${['3', 'unknown'].includes(level) ? '' : '/Level/' + level}`,
			title: `This is a level-${level} vital article.`
		}).append(
			$('<img>').attr({
				alt: 'Vital article',
				src: '/media/wikipedia/commons/1/13/C%C3%ADrculos_Conc%C3%A9ntricos.svg',
				width: 20,
				height: 20
			})
		)
	);
	mw.hook('wikipage.indicators').fire($icon);
	$(() => {
		$('.mw-indicators').prepend($icon, '\n');
	});
});