/** As with common.js, any code here should be kept to a minimum. */
'use strict';
// ] <nowiki>
/*jshint shadow:true, undef:true, latedef:true, unused:true, es3:true */
/*global window, jQuery, mw, importScript, importStylesheet, $ */
/********************* Copied from Common.js as of ] 17:14, 19 August 2024 ***********************/
/** ] v2.0 **/
try {
(function() {
var prefs;
try {
prefs = window.localStorage.getItem('AGprefs');
} catch (e) {
prefs = jQuery.cookie('AGprefs');
}
prefs = prefs && JSON.parse(prefs);
if (mw.config.get('wgUserGroups').indexOf('autoconfirmed') !== -1)
return;
if (mw.config.get('wgUserGroups').indexOf('user') === -1) {
// XXX: ] is just a temporary page
mw.loader.using(, function() {
mw.util.addPortletLink('p-personal', mw.util.getUrl('Wiktionary:Preferences for users without an account'),
'Preferences', 'pt-agprefs', 'Personalise Wiktionary (settings are kept per-browser).', '',
document.getElementById('pt-createaccount'));
});
if ((mw.config.get('wgAction') === 'view') && (mw.config.get('wgPageName') === 'Wiktionary:Preferences_for_users_without_an_account')) {
mw.loader.load('ext.gadget.AGprefs'); // ]
}
}
if (!prefs)
return;
mw.loader.state('wiktionary_this_gadget_has_been_disabled_by_the_user', 'missing');
for (var key in prefs.modules) {
if (prefs.modules) {
mw.loader.load();
} else {
// unavoidable race condition. to prevent it, every enabled-by-default gadget should have "site" as a dependency
if (mw.loader.getState(key) !== 'ready') {
mw.loader.moduleRegistry.dependencies.push('wiktionary_this_gadget_has_been_disabled_by_the_user');
mw.loader.state(key, 'missing');
} else {
// XXX
mw.log.warn(key + " could not be disabled; make sure it has 'site' declared as a dependency");
}
}
}
for (var key in prefs.sheets) {
importStylesheet('MediaWiki:Gadget-' + key);
}
for (var key in prefs.scripts) {
importScript('MediaWiki:Gadget-' + key);
}
if (mw.config.get('wgUserGroups').indexOf('user') !== -1)
mw.loader.using(, function() {
var changes = ;
for (var key in prefs.gadgets)
changes.push('gadget-' + key + '=' + (prefs.gadgets ? '1' : '0'));
new mw.Api().postWithToken('options', {
action: 'options',
change: changes.join('|')
}).then(function() {
jQuery.cookie('AGprefs', null);
try {
window.localStorage.removeItem('AGprefs');
} catch (e) { /* */ }
mw.notify(
jQuery('<b>Your <a href="https://dictious.com/en/Wiktionary:Preferences/V2">per-browser preferences</a> have been migrated</b><br/><br/>' +
'From now on, you should use your <a href="https://dictious.com/en/Special:Preferences">user preferences page</a>. ' +
'Preferences will no longer apply after you log out.')
);
});
});
})();
} catch (e) {
mw.log.warn(e);
}
/* ==Page specific extensions== */
/* ===]=== */
mw.loader.using("mediawiki.util", function(){
if (mw.config.get('wgIsMainPage')) {
// Workaround for ].
document.querySelector(".mw-searchInput").autocapitalize = "off";
}
});
/********************* End copied from Common.js ***********************/
// Make "edit all" the default by stopping `section=0` from getting added to the link.
var editButton = document.querySelector("#page-actions-edit > a");
if (editButton) {
var m = new MutationObserver(function() {
if (editButton.href.slice(-10) === "§ion=0") {
editButton.href = editButton.href.slice(0, -10);
}
});
m.observe(editButton, {attributes: true});
}
// </nowiki>