User:12twelve/common.js

// Hide images until clicked: const hide = [ 'hide-images-wrapper', 'hide-images-wrapper2', 'hide-images-wrapper3', 'hide-images-wrapper4' ]; ( function ( mw, $ ){   var hide_regex = /^(?:https?:)?\/\/upload.wikimedia.org\/wikipedia\/(?:en|commons)\//;

function clickHandler ( e ) { e.stopPropagation; e.preventDefault; $( this.firstChild ).unwrap; };

function makeWrapper { return $( ' ', {           'class': hide[(Math.floor(Math.random * 3))],            'click': clickHandler        } ); };

$( 'img' ).each( function {        if ( hide_regex.test( this.src ) ) {            $( this ).wrap( makeWrapper );        }        $( this ).addClass( 'hide-images-handled' );    } ); $( 'video' ).each( function {        if ( hide_regex.test( this.poster ) ) {            $( this ).wrap( makeWrapper );        }        $( this ).addClass( 'hide-images-handled' );    } ); }( mediaWiki, jQuery ) );