MediaWiki:Common.js

/* Any JavaScript here will be loaded for all users on every page load. */

/* yell at Crec0 */ function toggleTheme(state, twitter) { var mode = "light"; if (state) { mode = "dark"; }   twitter.contentWindow.document.querySelector("head > link").href = "https://platform.twitter.com/css/timeline.2fcb295ab98c2ce26f4cca0d2b2d0f48." + mode + ".ltr.css"; }

function registerEventListeners { var interval = setInterval(function {       var twitter = document.getElementById("twitter-widget-0");        if (twitter && twitter.contentWindow.document.readyState !== "loading") {            clearInterval(interval);

var themeButton = document.querySelector("#pt-darkmode-toggle > a"); toggleTheme(themeButton.innerHTML == "Default mode", twitter);

themeButton.addEventListener("click", function (e) {               toggleTheme(e.target.innerHTML == "Default mode", twitter);            }); }   }, 500);    setTimeout(function { clearInterval(interval); }, 120*1000); }

if (document.readyState !== "loading") { registerEventListeners; } else { window.addEventListener("DOMContentLoaded", registerEventListeners); }

/* Fires when DOM is ready */ $( function {

/** * Element animator * * Cycles through a set of elements (or "frames") on a 2 second timer per frame * Add the "animated" class to the frame containing the elements to animate. * Optionally, add the "animated-active" class to the frame to display first. * Optionally, add the "animated-subframe" class to a frame, and the * "animated-active" class to a subframe within, in order to designate a set of * subframes which will only be cycled every time the parent frame is displayed. * Animations with the "animated-paused" class will be skipped each interval. * * Requires some styling from MediaWiki:Gadget-site-styles.css. */ ( function {	var $content = $( '#mw-content-text' );	var advanceFrame = function( parentElem, parentSelector ) {		var curFrame = parentElem.querySelector( parentSelector + ' > .animated-active' );		$( curFrame ).removeClass( 'animated-active' );		var $nextFrame = $( curFrame && curFrame.nextElementSibling || parentElem.firstElementChild );		return $nextFrame.addClass( 'animated-active' );	};	// Set the name of the hidden property	var hidden; 	if ( typeof document.hidden !== 'undefined' ) {		hidden = 'hidden';	} else if ( typeof document.msHidden !== 'undefined' ) {		hidden = 'msHidden';	} else if ( typeof document.webkitHidden !== 'undefined' ) {		hidden = 'webkitHidden';	}	setInterval( function { if ( hidden && document[hidden] ) { return; }		$content.find( '.animated' ).each( function {			if ( $( this ).hasClass( 'animated-paused' ) ) {				return;			}			var $nextFrame = advanceFrame( this, '.animated' );			if ( $nextFrame.hasClass( 'animated-subframe' ) ) {				advanceFrame( $nextFrame[0], '.animated-subframe' );			}		} ); }, 2000 ); } );

} ); /* End DOM ready */ const DARKLINK = "https://syndication.twitter.com/srv/timeline-profile/screen-name/StardustlabsMC?dnt=false&embedId=twitter-widget-0&frame=false&lang=en&maxHeight=500&origin=https%3A%2F%2Fstardustlabs.miraheze.org%2Fwiki%2FMain_page&sessionId=96b5c621a91384774ebc0cef5f3f13a9fecdc27e&showHeader=true&showReplies=false&theme=dark&widgetsVersion=31f0cdc1eaa0f%3A1660602114609"           const LIGHTLINK = "https://syndication.twitter.com/srv/timeline-profile/screen-name/StardustlabsMC?dnt=false&embedId=twitter-widget-0&frame=false&lang=en&maxHeight=500&origin=https%3A%2F%2Fstardustlabs.miraheze.org%2Fwiki%2FMain_page&sessionId=96b5c621a91384774ebc0cef5f3f13a9fecdc27e&showHeader=true&showReplies=false&theme=light&widgetsVersion=31f0cdc1eaa0f%3A1660602114609"            $(".ext-darkmode-link").click(function{ if($(".client-darkmode").length>0){ $("#twitter-widget-0").attr("src",LIGHTLINK) }else{ $("#twitter-widget-0").attr("src",DARKLINK) }           })