User:Kww-newbie2/common.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
The accompanying .css page for this skin can be added at User:Kww-newbie2/common.css. |
// Disabling VE for anonymous and new users, per community consensus.
// For anons and first edits of by an account, the CSS elements to invoke VE are hidden
// When an account has made no edits, it checks to see if VE is enabled.
// If it is, it is disabled via the API.
// An account cannot enable VE until it makes an edit of some kind: there's no way around this unless WMF
// agrees to make the change.
mw.loader.using( ['mediawiki.user','mediawiki.api'],
function ()
{
var userName=mw.config.get( 'wgUserName' );
if (( userName == null ) || (mw.config.get( 'wgUserEditCount' ) < 1 ))
{
mw.user.options.set('visualeditor-enable',0);
appendCSS('li#ca-ve-edit, \
.mw-editsection .mw-editsection-divider, \
.mw-editsection .mw-editsection-visualeditor \
{ display: none; }');
if (( userName != 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
});
});
}
}
}
);
mw.loader.load( 'ext.visualEditor.viewPageTarget.init' );