User:Majr/getOrphanTalkPages.js

Promise.resolve( mw.loader.using( 'mediawiki.api' ) ).then( async => {	'use strict';	let api = new mw.Api;	let namespaceData = await api.get( { action: 'query', meta: 'siteinfo', siprop: 'namespaces', formatversion: 2, } );	// Filter out user talk, negative and even namespaces	let namespaceNumbers = Object.keys( namespaceData.query.namespaces )		.filter( num => num != 3 && num >= 0 && num & 1 );	let baseParams = {		action: 'query',		generator: 'allpages',		gaplimit: 'max',		gapfilterredir: 'all',		prop: 'info',		inprop: 'subjectid',		formatversion: 2,	};	let orphans = [];	for ( let num of namespaceNumbers ) {		let params = Object.assign( { gapnamespace: num }, baseParams );		let cont;		while ( true ) {			Object.assign( params, cont );			let data = await api.get( params );			if ( !data.query ) {				break;			}			let nOrphans = [];			data.query.pages.forEach( page => { if ( !page.subjectid && page.title.search( /\/Archive/ ) < 0 ) { nOrphans.push( page.title ); }			} );			nOrphans.sort;			orphans.push( nOrphans );			cont = data.continue;			if ( !cont ) {				break;			}		}	}	console.log( [].concat( ...orphans ).join( '\n' ) ); } );