User:Mooeypoo/User script demos/ReplaceArticleImagesWithImageFromArray.js

/** * User script demo: Replace all images in the article with random images from an array */ $( document ).ready( function {	var randomIndex,		imageArray = [			// Array of image src from commons			'https://upload.wikimedia.org/wikipedia/commons/thumb/8/82/P_S_Kr%C3%B8yer_1899_-_Sommeraften_ved_Skagens_strand._Kunstneren_og_hans_hustru.jpg/320px-P_S_Kr%C3%B8yer_1899_-_Sommeraften_ved_Skagens_strand._Kunstneren_og_hans_hustru.jpg',			'https://upload.wikimedia.org/wikipedia/commons/c/cf/Heinrich_Hirschsprung_%28Peder_Severin_Kr%C3%B8yer%29.jpg',			'https://upload.wikimedia.org/wikipedia/commons/e/ee/%22Birdcatcher%22_with_jockey_up.jpg',			'https://upload.wikimedia.org/wikipedia/commons/4/44/%27Amitabha_in_Sukhavati_Paradise%27%2C_Tibetan%2C_circa_1700%2C_San_Antonio_Museum_of_Art.jpg'		],		// Get a random integer between min and max		getRandomInt = function ( min, max ) {			return Math.floor( Math.random * ( max - min + 1 ) + min );		};

// Find all images in the body $( '.mw-body img' ).each( function {			var randomIndex = getRandomInt( 0, imageArray.length - 1 );

// Replace the src property $( this ).prop( 'src', imageArray[ randomIndex ] ); } ); } );