script.js
document.addEventListener('keydown', (event) => {
if (event.ctrlKey && event.code === 'KeyO') {
event.preventDefault()
const cursor = document.getElementsByClassName('cursor')[0]
if (cursor.style.display === 'none') {
return document.getElementById('text-input').focus()
}
if (cursor) {
const {x, y} = cursor.getBoundingClientRect()
let diff = 1
let el
while(true) {
if(x - diff < 0) {
break
}
el = document.elementFromPoint(x - diff, y)
if (el.tagName === 'SPAN') {
break
}
el = document.elementFromPoint(x + diff, y)
if (el.tagname === 'SPAN') {
break
}
diff += 1
}
const {parentElement} = el
if (parentElement.getAttribute('type') === 'link') {
parentElement.click()
}
} else {
document.getElementById('text-input').focus()
}
}
})