Skip to content

Instantly share code, notes, and snippets.

@Xatenev
Created April 10, 2021 10:37
Show Gist options
  • Save Xatenev/aa919c93fc3e284c266648c15bba6b0f to your computer and use it in GitHub Desktop.
Save Xatenev/aa919c93fc3e284c266648c15bba6b0f to your computer and use it in GitHub Desktop.
Lichess study enhancement user script
// ==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();
}
}
}
}
})();
@blacklegend1000
Copy link

Excuse me this might sound dumb but what do I do with this? Like where do I insert this ty.

@Xatenev
Copy link
Author

Xatenev commented Aug 31, 2023

Excuse me this might sound dumb but what do I do with this? Like where do I insert this ty.

@blacklegend1000 You need a browser addon that allows you to insert and run userscripts. The addons might have a different name depending on the browser you are using.

Google „Userscript Browser Javascript“ for example to find tutorials on how to use them.

https://www.tampermonkey.net/

This is one possible addon.

@blacklegend1000
Copy link

Sorry to bother you once again but I use safari on my MacBook and tampermonkey costs money as well on app store do you know a free addon or do I buy this

@Xatenev
Copy link
Author

Xatenev commented Aug 31, 2023

Sorry to bother you once again but I use safari on my MacBook and tampermonkey costs money as well on app store do you know a free addon or do I buy this

@blacklegend1000 Sorry, I don‘t know about Safari/MacBook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment