Snippets/Special:WhatLinksHere action links

From MediaWiki.org
Jump to navigation Jump to search
How to use Snippets
List of Snippets
Crystal Clear action run.png
Special:WhatLinksHere action links
Language(s): JavaScript
Compatible with: MediaWiki 1.17+ (Monobook; Vector)

Description[edit]

Adds a "hist" link to Special:WhatLinksHere.

Code[edit]

/**
 * Special:WhatLinksHere edit, history and delete links
 *
 * Adds "edit", "hist" and "delete" link to [[Special:WhatLinksHere]]
 *
 * @source: https://www.mediawiki.org/wiki/Snippets/Special:WhatLinksHere_history_link
 * @rev: 2
 */
$( '#mw-whatlinkshere-list li' ).each( function() {
	var url = mw.config.get( 'wgScript' ) + '?title=' + encodeURIComponent( $( 'a:first', this ).text() ) + '&action=';
	$( '.mw-whatlinkshere-tools a:last', this )
		.after( $( '<a>' ).attr( 'href', url + 'delete' ).text( 'delete' ) ).after( ' | ' )
		.after( $( '<a>' ).attr( 'href', url + 'history' ).text( 'hist' ) ).after( ' | ' )
		.after( $( '<a>' ).attr( 'href', url + 'edit' ).text( 'edit' ) ).after( ' | ' );
});