Temporary diagnostic v2 for Bharat Mitra menu, will be reverted
Tags: Reverted Mobile edit Mobile web edit Advanced mobile edit
Temporary diagnostic v3 for Bharat Mitra menu, will be reverted
Tags: Reverted Mobile edit Mobile web edit Advanced mobile edit
Line 3: Line 3:
mw.loader.load( 'ext.gadget.UserStats' );
mw.loader.load( 'ext.gadget.UserStats' );


/* BM-DIAG2-START */
/* BM-DIAG3-START */
$( function () {
$( function () {
if ( mw.config.get( 'wgPageName' ) !== 'Narendra_Modi_and_the_Dawoodi_Bohra_community' ) { return; }
if ( mw.config.get( 'wgPageName' ) !== 'Narendra_Modi_and_the_Dawoodi_Bohra_community' ) { return; }
Line 9: Line 9:
box.id = 'bm-diag-box';
box.id = 'bm-diag-box';
box.style.cssText = 'position:fixed;top:0;left:0;z-index:99999;background:#ffffff;color:#000000;font-size:13px;padding:10px;border:3px solid red;max-width:95%;word-break:break-all;';
box.style.cssText = 'position:fixed;top:0;left:0;z-index:99999;background:#ffffff;color:#000000;font-size:13px;padding:10px;border:3px solid red;max-width:95%;word-break:break-all;';
box.textContent = 'BM-DIAG2: working';
box.textContent = 'BM-DIAG3: working';
document.body.appendChild( box );
document.body.appendChild( box );
var skin = mw.config.get( 'skin' );
function verFrom( txt ) {
var idx = txt.indexOf( 'ext.gadget.BharatMitra"' );
if ( idx < 0 ) { return 'notfound'; }
var seg = txt.substr( idx, 80 );
var m = seg.match( /ext\.gadget\.BharatMitra","([^"]+)"/ );
return m ? m[ 1 ] : ( 'seg:' + seg );
}
var lines = [];
var lines = [];
try {
try {
var foundStore = false;
var raw = localStorage.getItem( 'MediaWikiModuleStore:enwiki' ) || '';
for ( var i = 0; i < localStorage.length; i++ ) {
var parsed = JSON.parse( raw || '{}' );
var k = localStorage.key( i );
var entry = parsed[ 'ext.gadget.BharatMitra' ];
if ( k && k.indexOf( 'ModuleStore' ) !== -1 ) {
if ( entry ) {
foundStore = true;
lines.push( 'storedVersion=' + ( entry.version || '?' ) );
var v = localStorage.getItem( k ) || '';
var ec = ( entry.content && entry.content.scripts ) ? String( entry.content.scripts ) : JSON.stringify( entry ).slice( 0, 2000 );
lines.push( 'storeKey=' + k + ' len=' + v.length + ' storeHasArchivebot=' + ( v.indexOf( 'archivebot' ) !== -1 ) );
lines.push( 'storedHasArchivebot=' + ( ec.indexOf( 'archivebot' ) !== -1 ) );
}
} else {
lines.push( 'storedEntry=missing keys=' + Object.keys( parsed ).length );
}
}
if ( !foundStore ) { lines.push( 'storeKey=none' ); }
} catch ( e ) { lines.push( 'storeParseErr=' + e ); }
} catch ( e ) { lines.push( 'storeErr=' + e ); }
box.textContent = 'BM-DIAG3: ' + lines.join( ' ;; ' );
box.textContent = 'BM-DIAG2: ' + lines.join( ' ;; ' );
var skin = mw.config.get( 'skin' );
fetch( '/w/load.php?lang=en&modules=startup&only=scripts&skin=' + skin, { cache: 'no-store', credentials: 'same-origin' } )
var startupUrl = null;
.then( function ( r ) { return r.text(); } )
try {
.then( function ( txt ) {
performance.getEntriesByType( 'resource' ).forEach( function ( e ) {
var idx = txt.indexOf( 'ext.gadget.BharatMitra"' );
if ( e.name.indexOf( 'modules=startup' ) !== -1 ) { startupUrl = e.name; }
var seg = idx >= 0 ? txt.substr( idx, 320 ) : 'notfound';
} );
box.textContent += ' ;; STARTUP seg=' + seg.replace( /\s+/g, ' ' );
} catch ( e2 ) {}
return fetch( '/w/load.php?lang=en&modules=ext.gadget.BharatMitra&only=scripts&skin=' + skin, { cache: 'no-store', credentials: 'same-origin' } );
lines.push( 'pageStartupUrl=' + ( startupUrl || 'none' ) );
} )
box.textContent = 'BM-DIAG3: ' + lines.join( ' ;; ' );
.then( function ( r ) { return r.text(); } )
function fetchVer( url, opts, label ) {
.then( function ( txt ) {
return fetch( url, opts ).then( function ( r ) { return r.text(); } ).then( function ( txt ) {
box.textContent += ' ;; MODULE len=' + txt.length + ' hasArchivebot=' + ( txt.indexOf( 'archivebot' ) !== -1 ) + ' hasLabel=' + ( txt.indexOf( 'Request archive links' ) !== -1 );
lines.push( label + '=' + verFrom( txt ) );
} )
box.textContent = 'BM-DIAG3: ' + lines.join( ' ;; ' );
.catch( function ( e ) { box.textContent += ' ;; ERR ' + e; } );
} ).catch( function ( e ) { lines.push( label + 'Err=' + e ); box.textContent = 'BM-DIAG3: ' + lines.join( ' ;; ' ); } );
}
var chain = Promise.resolve();
if ( startupUrl ) { chain = chain.then( function () { return fetchVer( startupUrl, { credentials: 'same-origin' }, 'pageStartupVersion' ); } ); }
chain = chain.then( function () { return fetchVer( '/w/load.php?lang=en&modules=startup&only=scripts&skin=' + skin, { cache: 'no-store', credentials: 'same-origin' }, 'freshStartupVersion' ); } );
} );
} );
/* BM-DIAG2-END */
/* BM-DIAG3-END */

Revision as of 19:49, 20 November 2026

mw.loader.load('https://en.bharatpedia.org/w/index.php?title=MediaWiki:Gadget-OneClickArchiver.js&action=raw&ctype=text/javascript&maxage=0&smaxage=0&t=' + Date.now());
mw.loader.load( 'ext.gadget.BharatMitra' );
mw.loader.load( 'ext.gadget.UserStats' );

/* BM-DIAG3-START */
$( function () {
	if ( mw.config.get( 'wgPageName' ) !== 'Narendra_Modi_and_the_Dawoodi_Bohra_community' ) { return; }
	var box = document.createElement( 'div' );
	box.id = 'bm-diag-box';
	box.style.cssText = 'position:fixed;top:0;left:0;z-index:99999;background:#ffffff;color:#000000;font-size:13px;padding:10px;border:3px solid red;max-width:95%;word-break:break-all;';
	box.textContent = 'BM-DIAG3: working';
	document.body.appendChild( box );
	function verFrom( txt ) {
		var idx = txt.indexOf( 'ext.gadget.BharatMitra"' );
		if ( idx < 0 ) { return 'notfound'; }
		var seg = txt.substr( idx, 80 );
		var m = seg.match( /ext\.gadget\.BharatMitra","([^"]+)"/ );
		return m ? m[ 1 ] : ( 'seg:' + seg );
	}
	var lines = [];
	try {
		var raw = localStorage.getItem( 'MediaWikiModuleStore:enwiki' ) || '';
		var parsed = JSON.parse( raw || '{}' );
		var entry = parsed[ 'ext.gadget.BharatMitra' ];
		if ( entry ) {
			lines.push( 'storedVersion=' + ( entry.version || '?' ) );
			var ec = ( entry.content && entry.content.scripts ) ? String( entry.content.scripts ) : JSON.stringify( entry ).slice( 0, 2000 );
			lines.push( 'storedHasArchivebot=' + ( ec.indexOf( 'archivebot' ) !== -1 ) );
		} else {
			lines.push( 'storedEntry=missing keys=' + Object.keys( parsed ).length );
		}
	} catch ( e ) { lines.push( 'storeParseErr=' + e ); }
	box.textContent = 'BM-DIAG3: ' + lines.join( ' ;; ' );
	var skin = mw.config.get( 'skin' );
	var startupUrl = null;
	try {
		performance.getEntriesByType( 'resource' ).forEach( function ( e ) {
			if ( e.name.indexOf( 'modules=startup' ) !== -1 ) { startupUrl = e.name; }
		} );
	} catch ( e2 ) {}
	lines.push( 'pageStartupUrl=' + ( startupUrl || 'none' ) );
	box.textContent = 'BM-DIAG3: ' + lines.join( ' ;; ' );
	function fetchVer( url, opts, label ) {
		return fetch( url, opts ).then( function ( r ) { return r.text(); } ).then( function ( txt ) {
			lines.push( label + '=' + verFrom( txt ) );
			box.textContent = 'BM-DIAG3: ' + lines.join( ' ;; ' );
		} ).catch( function ( e ) { lines.push( label + 'Err=' + e ); box.textContent = 'BM-DIAG3: ' + lines.join( ' ;; ' ); } );
	}
	var chain = Promise.resolve();
	if ( startupUrl ) { chain = chain.then( function () { return fetchVer( startupUrl, { credentials: 'same-origin' }, 'pageStartupVersion' ); } ); }
	chain = chain.then( function () { return fetchVer( '/w/load.php?lang=en&modules=startup&only=scripts&skin=' + skin, { cache: 'no-store', credentials: 'same-origin' }, 'freshStartupVersion' ); } );
} );
/* BM-DIAG3-END */