User:Samwilson/Searchnotincat.js

'use strict';

$( function() {
	if ( mw.config.get('wgCanonicalNamespace') === 'Category' ) {
		var title = mw.config.get( 'wgTitle' );
		var url = mw.config.get('wgScript') + "?title=Special:Search&search=" +
			"%22" + encodeURIComponent( title ) + "%22%20-deepcat:%22" +
			encodeURIComponent( title.replaceAll( ' ', '_' ) ) + "%22";
	    mw.util.addPortletLink(
	    	'p-cactions', 
			url,
			'Search out of category',
			'ca-searchnotincat', 
			"Find related files that are not yet in this category",
			null
		);
	}
} );