Toggle menu
611
279
1.4K
7.7K
InfraWiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

MediaWiki:Common.js

MediaWiki interface page

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */

/* Google Analytics 4 (G-TMXZHRYBNT) */
( function () {
	var gaId = 'G-TMXZHRYBNT';
	var s = document.createElement( 'script' );
	s.async = true;
	s.src = 'https://www.googletagmanager.com/gtag/js?id=' + gaId;
	document.head.appendChild( s );
	window.dataLayer = window.dataLayer || [];
	window.gtag = function () {
		window.dataLayer.push( arguments );
	};
	window.gtag( 'js', new Date() );
	window.gtag( 'config', gaId );
}() );

/* Ko-fi floating donate button (bottom right) */
/*
 * Ko-fi's floating-chat widget has no position option; its stylesheet
 * (storage.ko-fi.com/cdn/scripts/floating-chat-wrapper.css) pins the button
 * wrappers and the popup to left: 16px. Override to the right side.
 * Below 1120px Citizen puts its header bar at the bottom and a fixed
 * .page-actions toolbar at bottom-right above it, so lift the button above both.
 */
mw.loader.using( 'mediawiki.util' ).then( function () {
	mw.util.addCSS(
		'.floatingchat-container-wrap, .floatingchat-container-wrap-mobi {' +
			' left: auto !important; right: 16px !important;' +
			' width: 195px !important; max-width: 195px !important; }' +
		'.floating-chat-kofi-popup-iframe, .floating-chat-kofi-popup-iframe-mobi {' +
			' left: auto !important; right: 16px !important;' +
			' max-width: calc(100vw - 32px) !important; }' +
		'@media screen and (max-width: 1119.98px) {' +
			' .floatingchat-container-wrap, .floatingchat-container-wrap-mobi {' +
				' bottom: calc(var(--header-size-block-end, 3.5rem) + var(--toolbar-size, 2.5rem) + 2rem + env(safe-area-inset-bottom, 0px)) !important; }' +
			' .floating-chat-kofi-popup-iframe, .floating-chat-kofi-popup-iframe-mobi {' +
				' bottom: calc(var(--header-size-block-end, 3.5rem) + var(--toolbar-size, 2.5rem) + 2rem + 59px + env(safe-area-inset-bottom, 0px)) !important; }' +
		' }'
	);
	return mw.loader.getScript( 'https://storage.ko-fi.com/cdn/scripts/overlay-widget.js' );
} ).then( function () {
	if ( window.kofiWidgetOverlay ) {
		window.kofiWidgetOverlay.draw( 'infrawiki', {
			'type': 'floating-chat',
			'floating-chat.donateButton.text': 'Support us',
			'floating-chat.donateButton.background-color': '#d9534f',
			'floating-chat.donateButton.text-color': '#fff'
		} );
	}
} );