mic_none

User:Anomie/hide-images.js Source: en.wikipedia.org/wiki/User:Anomie/hide-images.js

( 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 $( '<span>', {
            'class': 'hide-images-wrapper',
            'click': clickHandler
        } );
    };

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