Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
mw.loader.using( ['mediawiki.api', 'mediawiki.user'],
	function () {
		function isAutoconfirmed() {
			return mw.config.get('wgUserGroups').indexOf('autoconfirmed') > -1;
		}
		if ( !isAutoconfirmed() ) {
			// If the user is not autoconfirmed, disable it
			mw.user.options.set('visualeditor-enable', 0);
			// If the user is logged in, lets also save this preference
			if ( mw.config.get( 'wgUserName' ) != null
				&& mw.user.options.get('visualeditor-betatempdisable') !== 1 ) {
				var api = new mw.Api();
				api.get({
					action: 'tokens',
					type: 'options'
				}).done(function (json) {
						api.post({
							action: 'options',
							change: 'visualeditor-betatempdisable=1',
							token: json.tokens.optionstoken
						});
					});
			}

		}
	}
);