MediaWiki:Vector.js: Difference between revisions

From Galaxypedia
imported>Smallketchup82
(instead of using settimeout for 100 miliseconds to enable darkreader and setinterval to wait until the DarkReader variable exists, use jquery promises to wait for each script to load and do things based off of that asynchronously)
(stop loading from vector.js, load from a module instead so that it is activated before page is loaded/rendered)
 
(28 intermediate revisions by 2 users not shown)
Line 1: Line 1:
/* All JavaScript here will be loaded for users of the Vector skin */
/* All JavaScript here will be loaded for users of the Vector skin */


// Load Scripts
/*mw.loader.getScript( '/index.php?title=MediaWiki:Dark.css&action=raw&ctype=text/css', 'text/css' ).then( // -> Load custom dark css styling first
mw.loader.getScript( '/index.php?title=MediaWiki:Dark.css&action=raw&ctype=text/css', 'text/css' ).then( // -> Load custom dark css styling first
function () {
function () {
mw.loader.getScript( '/index.php?title=MediaWiki:DarkReader.js&action=raw&ctype=text/javascript' ).then( // -> Now load DarkReader to refine our custom dark css styling
console.log("Custom CSS Styling loaded!")
mw.loader.load( '/index.php?title=MediaWiki:DarkReader.js&action=raw&ctype=text/javascript' ) // -> Now load DarkReader to refine our custom dark css styling
// Comment above and uncomment below to use JSDelivr for loading DarkReader, slightly (50ms diff) more loading time than using Comet
/* mw.loader.getScript('https://cdn.jsdelivr.net/npm/darkreader@4/darkreader.min.js').then(
function () {
function () {
DarkReader.setFetchMethod(window.fetch);
DarkReader.setFetchMethod(window.fetch);
DarkReader.enable();
DarkReader.enable({
console.log("Darkreader Enabled!");
}, {
},
ignoreInlineStyle: ['.mediaContainer', '.mediaContainer *', '.TemplateRevision', '.TemplateRevision *', '#homeButtonNav', '#homeButtonNav *', '.mw-wiki-logo', 'img', '#siteNotice *', '.sitenoticestyling'],
function ( e ) {
css: ".sitenoticestyling { border-color: rgb(48, 52, 54) !important; border: 2px solid rgb(48, 52, 54) !important; }",
mw.log.error( e.message ); // => "Failed to load script"
ignoreImageAnalysis: [".mw-wiki-logo", "img"],
invert: []
});
console.log("Darkreader Enabled Using JSDelivr!");
}, function( e ) {
mw.log.error( e.message );
console.error( e.message );
}
}
);
) *
     },
     },
     function ( e ) {
     function ( e ) {
         mw.log.error( e.message ); // => "Failed to load script"
         mw.log.error( e.message );
     }
     }
)
)
*/

Latest revision as of 17:05, 24 November 2023

/* All JavaScript here will be loaded for users of the Vector skin */

/*mw.loader.getScript( '/index.php?title=MediaWiki:Dark.css&action=raw&ctype=text/css', 'text/css' ).then( // -> Load custom dark css styling first
	function () {
		console.log("Custom CSS Styling loaded!")
		mw.loader.load( '/index.php?title=MediaWiki:DarkReader.js&action=raw&ctype=text/javascript' ) // -> Now load DarkReader to refine our custom dark css styling
		
		// Comment above and uncomment below to use JSDelivr for loading DarkReader, slightly (50ms diff) more loading time than using Comet
		/* mw.loader.getScript('https://cdn.jsdelivr.net/npm/darkreader@4/darkreader.min.js').then(
			function () {
				DarkReader.setFetchMethod(window.fetch);
				DarkReader.enable({
				}, {
					ignoreInlineStyle: ['.mediaContainer', '.mediaContainer *', '.TemplateRevision', '.TemplateRevision *', '#homeButtonNav', '#homeButtonNav *', '.mw-wiki-logo', 'img', '#siteNotice *', '.sitenoticestyling'],
					css: ".sitenoticestyling { border-color: rgb(48, 52, 54) !important; border: 2px solid rgb(48, 52, 54) !important; }",
					ignoreImageAnalysis: [".mw-wiki-logo", "img"],
					invert: []
				});
				console.log("Darkreader Enabled Using JSDelivr!");
			}, function( e ) {
				mw.log.error( e.message );
				console.error( e.message );
			}
		) *
    },
    function ( e ) {
        mw.log.error( e.message );
    }
)
*/