MediaWiki:Common.js

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

/* 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 */

/* Funy Twitter dark mode or default mode thingy made by Daik */

const DARKLINK = "https://syndication.twitter.com/srv/timeline-profile/screen-name/StardustLabs?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/StardustLabs?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)                }            })

/* End of funy Twitter dark mode or default mode thingy made by Daik */

// select all elements with the class 'image-link' var imageLinks = document.querySelectorAll('.image-link');

// loop through each element imageLinks.forEach(function(imageLink) {   // select the image element within the link element    var image = imageLink.querySelector('img');

// get the href attribute of the link var href = imageLink.getAttribute('href');

// check if the link has been visited if (localStorage.getItem(href)) { // if visited, set image color to purple image.style.filter = 'hue-rotate(45deg)'; }

// when the link is clicked imageLink.addEventListener('click', function {       // set the href as visited        localStorage.setItem(href, true);    }); });