diff --git a/src/utils/config.js b/src/utils/config.js index 25c448e..0ab3954 100644 --- a/src/utils/config.js +++ b/src/utils/config.js @@ -14,6 +14,31 @@ export const bindConfig = () => { }); }); }); + + document.querySelectorAll('dialog.config').forEach((dialog) => { + dialog.querySelectorAll('input[name=mode]').forEach((input) => { + + if (input.value === 'none' && localStorage.af_enabled === '0') { + input.checked = true; + } else if (input.value === 'dyslexia' && (localStorage.af_enabled === '1' && localStorage.af_mode === 'df')) { + input.checked = true; + } + + input.addEventListener('change', (evt) => { + if (evt.target.value === 'dyslexia') { + document.documentElement.classList.remove('dark'); + document.documentElement.classList.add('df'); + // Set accessibility features. + localStorage.af_enabled = 1; + localStorage.af_mode = 'df'; + } else if (evt.target.value === 'none') { + document.documentElement.classList.remove('df'); + document.documentElement.classList.remove('hc'); + localStorage.af_enabled = 0; + } + }); + }); + }); }; export const bindMenu = () => {