Jump to content

User:Kww-newbie2/common.js

From Wikipedia, the free encyclopedia
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.
// 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' );