Skip to content

Instantly share code, notes, and snippets.

@monoblaine
Last active April 21, 2022 22:48
Show Gist options
  • Save monoblaine/c7938e7725ffa7e87ae62f49d5065e91 to your computer and use it in GitHub Desktop.
Save monoblaine/c7938e7725ffa7e87ae62f49d5065e91 to your computer and use it in GitHub Desktop.
Tüm siteler için erişilebilirlik iyileştirmeleri
// ==UserScript==
// @name Tüm siteler için erişilebilirlik iyileştirmeleri
// @description tabindex ile ilgili saçmalıkları ve href'i olmayan anchor element'ları düzeltir.
// @namespace yarak
// @match *://*/*
// @exclude *.local/*
// @version 3.0.3
// @grant none
// ==/UserScript==
// Tüm linkleri gezilebilir duruma getir
const tlgdg = window.tlgdg = () => document.querySelectorAll('a:not([href])').forEach(anchor => anchor.setAttribute('href', 'javascript:void(0)'));
// tabindex="-1" olan anchor'lardan ve button'larda tabindex attribute'unu kaldırır.
function removeTabIndexMinusOnes () {
document
.querySelectorAll('a[tabindex="-1"], button[tabindex="-1"]')
.forEach(el => { el.tabIndex = 0; });
}
document.addEventListener('keydown', function (e) {
const keyName = e.key;
if (keyName === 'Control' || !e.ctrlKey) {
return;
}
switch (keyName) {
case '.':
tlgdg();
break;
case 'ç':
removeTabIndexMinusOnes();
break;
default:
return;
}
e.preventDefault();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment