User:Inductiveload/common.js

// { //  var tmp_load = mw.loader.load;

//  mw.loader.load = function ( modules, type ) { //    console.log( "Load", modules ); //    return tmp_load( modules, type ); //  };

//  var tmp_using = mw.loader.using;

//  mw.loader.using = function ( dep, ready, error ) { //    console.log( "using", dep ); //    return tmp_using( dep, ready, error ); //  } // }

var load = true;

function setUpEnableToggle { const enabled = mw.storage.get( 'userjs.commonjs.enable' ) === '1';

const toggleLink = mw.util.addPortletLink(		'p-tb',		'#',		( enabled ? 'Disable' : 'Enable' ) + ' common.js',		'n-enableCommonJs',		'Enable/disable user common.js'	);

toggleLink.onclick = function { mw.storage.set( 'userjs.commonjs.enable', enabled ? '0' : '1' ); location.reload; };	return enabled; }

mw.loader.using( 'mediawiki.storage', function {	const enabled = setUpEnableToggle;	if ( load && enabled ) {		// Load local dev script if available, or fall back to an on-wiki version		mw.loader.getScript('https://localhost:5555/wsjs/common.js')		    .then(function  { console.log("Local Common.js script loaded"); }, function (e) { // Script failed. X is not available mw.log.error("Local Common.js script failed to load - falling back to on-wiki version"); var _cNS = mw.config.get("wgCanonicalNamespace"); var _isEdit = mw.config.get("wgAction") === "edit" || mw.config.get("wgAction") === "submit"; const mobile = mw.config.get( 'skin' ) === 'minerva'; mw.loader.load('//en.wikisource.org/w/index.php?title=User:Inductiveload/common-fallback.js&action=raw&ctype=text/javascript'); // Load gadgets and things here to avoid having to wait for the fallback script // Load if gadget disabled if (!mw.user.options.get("gadget-PageNumbers")) { mw.loader.load(['ext.gadget.PageNumbers']); }		       // Reimagined popups {		           mw.loader.load("/w/index.php?title=User:Inductiveload/popups_reloaded.js&action=raw&ctype=text/javascript"); mw.loader.load("/w/index.php?title=User:Inductiveload/popups_reloaded.css&action=raw&ctype=text/css", 'text/css'); }		   	// OCR cleanup mw.loader.load("/w/index.php?title=User:Inductiveload/cleanup.js&action=raw&ctype=text/javascript");

// Load gadgets that are otherwise served locally mw.loader.load("//en.wikisource.org/w/index.php?title=User:Inductiveload/index preview.js&action=raw&ctype=text/javascript"); mw.loader.load("//en.wikisource.org/w/index.php?title=User:Inductiveload/quick access.js&action=raw&ctype=text/javascript"); mw.loader.load("//en.wikisource.org/w/index.php?title=User:Inductiveload/IaUploadPopup.js&action=raw&ctype=text/javascript"); mw.loader.load("/w/index.php?title=User:Inductiveload/jump_to_file/load.js&action=raw&ctype=text/javascript");

mw.loader.load('/w/index.php?title=User:Xover/ocrtoy.js&action=raw&ctype=text/javascript'); if ((_cNS === "Index") && _isEdit) { mw.loader.load(['ext.gadget.ImportPagelist', 'ext.gadget.Fill_Index']); }		       // maintain script has no purpose on edit or special if ((_cNS !== "Special") && !_isEdit) { mw.loader.using(['ext.gadget.utils-difference', 'mediawiki.util', 'mediawiki.api',		               'oojs-ui-core', 'oojs-ui-windows', 'oojs-ui-widgets']).done(function {		              mw.loader.load("/w/index.php?title=User:Inductiveload/maintain.js&action=raw&ctype=text/javascript");		              mw.loader.load("/w/index.php?title=User:Inductiveload/maintain-ws-tools.js&action=raw&ctype=text/javascript");		            }); }		       if ( mobile ) { // Load the wikitext editor fixer mw.loader.load("/w/index.php?title=User:Inductiveload/Gadget-MobileFrontendFixer.js&action=raw&ctype=text/javascript"); }		   } );	} } );