User:Stefan04/global.js

if (wgUserLanguage != wgPageContentLanguage) {

mw.loader.using('mediawiki.api', function {    var api = new mw.Api;    api.get({ action: 'query', meta: 'tokens', type: 'csrf' }).done(function (json) { api.post({       action: 'options',        optionname: 'language',        optionvalue: wgPageContentLanguage,        token: json.tokens.csrftoken      }); }); });

if (location.href.indexOf('\?') == -1 && location.href.indexOf('action=submit') == -1 && location.href.indexOf('#') == -1) location.href=location.href+'?uselang=' + wgPageContentLanguage; else if (location.href.indexOf('action=submit') == -1 && location.href.indexOf('#') == -1) location.href=location.href+'&uselang=' + wgPageContentLanguage;

}