- Blind mode tutorial
lichess.org
Donate

Script that adds a Next Chapter/Previous Chapter shortcut key when you are in a study.

Thanks and credit goes out to Xatenev for giving me this script when I asked in https://lichess.org/forum/general-chess-discussion/anyone-know-javascript-that-could-make-a-very-short-but-extremely-useful-user-script-for-lichess
Here is his answer in full.

#2
@PizzaChess61

I made one for you. It can be found in the following link with syntax highlighting, or just as plain text below:

gist.github.com/Xatenev/aa919c93fc3e284c266648c15bba6b0f

Press 'p' to go to the previous chapter.
Press 'n' to go to the next chapter.

PS: If you prefer different keys, you can visit keycode.info/ and press the respective key. It will display their "keycode". Replace the numbers 78 and 80 with the keys you want to use. For example, an alternative usage of <left arrow> and <right arrow> would have the keys 37 and 39, so you would replace 80 with 37 and 78 with 39.


// ==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();
}
}
}
}
})();

Thanks and credit goes out to Xatenev for giving me this script when I asked in https://lichess.org/forum/general-chess-discussion/anyone-know-javascript-that-could-make-a-very-short-but-extremely-useful-user-script-for-lichess Here is his answer in full. #2 @PizzaChess61 I made one for you. It can be found in the following link with syntax highlighting, or just as plain text below: gist.github.com/Xatenev/aa919c93fc3e284c266648c15bba6b0f Press 'p' to go to the previous chapter. Press 'n' to go to the next chapter. PS: If you prefer different keys, you can visit keycode.info/ and press the respective key. It will display their "keycode". Replace the numbers 78 and 80 with the keys you want to use. For example, an alternative usage of <left arrow> and <right arrow> would have the keys 37 and 39, so you would replace 80 with 37 and 78 with 39. ------------------- // ==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(); } } } } })();

That was nice of him!

Can you explain how a random non-coding user can implement this script ?

Cheers!

That was nice of him! Can you explain how a random non-coding user can implement this script ? Cheers!

This topic has been archived and can no longer be replied to.