On Sat, 13 Sep 2014 21:28:05 +0200, Federico Leva (Nemo) nemowiki@gmail.com wrote:
Is there a JavaScript snippet I can add to my [[m:Special:MyPage/global.js]] to enable this beta feature globally without visiting Special:Preferences everywhere? Would be worth mentioning in the page.
I just composed one.
// Intentionally using non-strict comparison with ==, not ===, because of bug 52542 if ( mw.user.options.get( 'wikibase-otherprojects' ) == 0 ) { mw.loader.using( 'mediawiki.api', function () { var api = new mw.Api(); api.postWithToken( 'options', { action: 'options', optionname: 'wikibase-otherprojects', optionvalue: 1 } ); } ); }
This can naturally be reused for other global preferences you might want to set. Note that it will "take effect" the second time you visit a page on a given wiki: the first page load will set the preference, and the new value will be available after you refresh.
(If you ever want to extend it to set multiple options, the API must be called differently – see the documentation for the 'change' parameter on https://www.mediawiki.org/wiki/API:Options#Parameters – unfortunately it's rather clunky. I've been meaning to write a helper function for this for some time now.)