Created
April 10, 2021 10:37
-
-
Save Xatenev/aa919c93fc3e284c266648c15bba6b0f to your computer and use it in GitHub Desktop.
Lichess study enhancement user script
This file contains 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 Lichess study enhancement | |
// @author Xatenev | |
// @match https://*.lichess.org/* | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
console.log("Lichess study userscript loaded"); | |
document.addEventListener('keydown', onKeyDown); | |
function onKeyDown(e) { | |
const activeElement = document.querySelector('.study__chapters .active'); | |
if(activeElement) { | |
if(e.keyCode === 78) { // press n | |
const next = activeElement.nextSibling; | |
if(next) { | |
next.click(); | |
} | |
} | |
if(e.keyCode === 80) { // press p | |
const previous = activeElement.previousSibling; | |
if(previous) { | |
previous.click(); | |
} | |
} | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@blacklegend1000 Sorry, I don‘t know about Safari/MacBook.