Snippets/Parser information

From MediaWiki.org
Jump to: navigation, search
How to use Snippets
List of Snippets
Crystal Clear action run.png
Parser information
Language(s): javascript
Compatible with:

MediaWiki 1.11++ (Monobook; Vector)

Description [edit]

Make "NewPP parser report" and "Saved in parser cache with key" HTML comments visible at the bottom of the page.

JavaScript [edit]

/**
 * Parser information: Uncomment the parser reports and parser cache informations
 *
 * @source: http://www.mediawiki.org/wiki/Snippets/Parser_information
 * @rev: 2
 */

$( '#bodyContent' ).contents().filter( function() {
        if ( this.nodeType == 8 )  {
                return ( this.data.indexOf( 'Saved' ) > 0 ||
                        this.data.indexOf( 'NewPP' ) > 0 );
        } else {
                return false;
        }
}).replaceWith( function() {
  return $( '<pre></pre>' ).text( this.data );
});

URL option [edit]

MediaWiki version: 1.17
/**
 * Parser information: Uncomment the parser reports and parser cache informations
 *
 * @source: http://www.mediawiki.org/wiki/Snippets/Parser_information
 * @rev: 2
 */

function ShowParseInfo(){
        $( '#bodyContent' ).contents().filter( function() {
                if ( this.nodeType == 8 )  {
                        return ( this.data.indexOf( 'Saved' ) > 0 ||
                                this.data.indexOf( 'NewPP' ) > 0 );
                } else {
                        return false;
                }
        }).replaceWith( function() {
                return $( '<pre></pre>' ).text( this.data );
        });
}
if ( mw.util.getParamValue('debug') == 'true' ) {
        $(document).ready( ShowParseInfo );
}