Last active
August 9, 2018 09:48
-
-
Save monoblaine/ff2eff01da39180722e7ad975b21cb0a to your computer and use it in GitHub Desktop.
Ekşi sözlük için erişilebilirlik iyileştirmeleri
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Ekşi sözlük için erişilebilirlik iyileştirmeleri | |
// @namespace https://eksisozluk.com/ | |
// @include https://eksisozluk.com/* | |
// @version 1.1.1 | |
// @grant none | |
// ==/UserScript== | |
(function () { | |
setTimeout(() => window.wrappedJSObject.jQuery($ => $(document).off('keypress')), 1); | |
document.addEventListener('keydown', function (e) { | |
const keyName = e.key; | |
if (keyName === 'Control' || !e.ctrlKey) { | |
return; | |
} | |
let elToFocusSelector; | |
switch (keyName) { | |
case 'i': | |
elToFocusSelector = '#content-body a[href]:not([href="#"]):not([href="javascript:void(0)"])'; | |
break; | |
case 'ğ': | |
elToFocusSelector = '#sub-navigation a'; | |
break; | |
case ',': | |
elToFocusSelector = '.pager > select, .load-more-entries'; | |
break; | |
case 'ş': | |
tlgdg(); | |
elToFocusSelector = '#index-section a'; | |
break; | |
default: | |
elToFocusSelector = null; | |
break; | |
} | |
if (elToFocusSelector === null) { | |
return; | |
} | |
e.preventDefault(); | |
const elToFocus = document.querySelector(elToFocusSelector); | |
if (elToFocus !== null) { | |
elToFocus.focus(); | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment