User:XXN/withscript.js

From mediawiki.org

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
mw.loader.using( ['mediawiki.util'], function () {
	var extraCSS = mw.util.getParamValue( 'withCSS' ),
		extraJS = mw.util.getParamValue( 'withscript' );

	if ( extraCSS ) {
		// DONT REMOVE THIS IF (unless you are OK with CSRF attacks)
		if ( /^(User|MediaWiki):[^&<>=%#]*\.css$/.test( extraCSS ) ) {
			mw.loader.load( '/w/index.php?title=' + encodeURIComponent( extraCSS ) + '&action=raw&ctype=text/css', 'text/css' );
		} else {
			mw.notify( '!!!!!!!!!!!!!', { title: 'Invalid withCSS value' } );
		}
	}

	if ( extraJS ) {
		// DONT REMOVE THIS IF (unless you are OK with XSS and CSRF attacks)
		if ( /^(User|MediaWiki):[^&<>=%#]*\.js$/.test( extraJS ) ) {
			mw.loader.load( '/w/index.php?title=' + encodeURIComponent( extraJS ) + '&action=raw&ctype=text/javascript' );
		} else {
			mw.notify( '!!!!!!!!!!!!!', { title: 'Invalid withscript value' } );
		}
	}

});