/*
This script adds "Source-added" and "Template-added" links under "Tools" in the sidebar on category pages.
"Source-added" searches category members which were added with category code in the source.
"Template-added" shows all category members not found by "Source-added".
To use the script, add the following line to Special:MyPage/common.js:
importScript('User:PrimeHunter/Category source.js'); // Linkback: [[User:PrimeHunter/Category source.js]]
*/
mw.loader.using(['mediawiki.util'], function () {
if ( mw.config.get( 'wgNamespaceNumber' ) === 14 ) {
var name = mw.config.get( 'wgTitle' );
var url;
try {
url = mw.util.getUrl( 'Special:Search' ) + '?profile=advanced&search='
+ encodeURIComponent('incategory:"'
+ name
+ '" ' + '-insource:/\\[\\[Category:'
+ name.replace(/[-[\]{}()*+!<=:?.\/\\^$|#\s,]/g, '\\$&')
+ '[\\|\\]]/i'
)
+ '&ns0=1&ns1=1&ns2=1&ns3=1&ns4=1&ns5=1&ns6=1&ns7=1&ns8=1&ns9=1&ns10=1&ns11=1&ns12=1&ns13=1'
+ '&ns14=1&ns15=1&ns100=1&ns101=1&ns108=1&ns109=1&ns118=1&ns119=1&ns446=1&ns447=1'
+ '&ns710=1&ns711=1&ns828=1&ns829=1&ns2300=1&ns2301=1&ns2302=1&ns2303=1';
} catch(e) {
url = '#error';
}
mw.util.addPortletLink(
'p-tb',
url,
'Template-added',
'pt-templateadded',
'Category members which were NOT added with category code in the source',
null,
'#t-info'
);
mw.util.addPortletLink(
'p-tb',
url.replace('-insource', 'insource'),
'Source-added',
'pt-sourceadded',
'Category members which were added with category code in the source',
null,
'#pt-templateadded'
);
}
});