Yet another attempt to get better at chess
Tags: chess, devtools
Published: 2024-07-15 03:50:33

Do you recall that golden period when your chess rating skyrocketed? When you were effortlessly conquering opponents who seemed invincible? It felt like you could defeat anyone with just a little extra focus on the next game. Perhaps you even believed that your rating would continue to soar indefinitely. You may have even thought you were one of those rare few who effortlessly transitioned from beginner to expert.

Sadly, this is almost never the case. That phase I described usually marks the transition from amateur to club player. It is at this stage that you come to realize that improvement requires effort and dedication. You understand the importance of tactical training, endgame theory, and preparation for different openings, as well as the need for strategic thinking. Not only must you invest countless hours in honing these skills, but you must also develop the intuition to blend them harmoniously. In fact, becoming better at chess requires consistent study.

Every now and then, I tend to overlook this truth and delude myself into thinking there must be an easier path. It was during one of these moments of self-deception that I ended up creating the first version of [this](https://github.com/mrdimosthenis/BlindfoldChessTraining) mobile app.

After a decade, I've made the decision to make better use of my limited time for chess. To achieve this, I've enabled the Zen mode in [lichess](https://lichess.org) and hidden all ratings. This allowed me to focus on enjoying the game rather than worrying about improvement.

![lichess display options](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/842pcgaedm1qob4gelcx.png)

But once again, instead of studying chess, I started playing partially-blindfold games. Lichess allows players to use disguised pieces, where their color is visible but their specific figures are not shown.

![disguised pieces](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tbc10l2jfr26jm6q5baz.png)

Without the visual cues of the chess pieces, I had to rely on memorizing each position. Although it took some time to adjust, I found that I now make fewer mistakes.
It took me a couple of weeks to be able to play with disguised pieces, and I imagine most club players would find it equally manageable.

However, I was still starving for a new challenge. Using JavaScript code in the browser's console, I changed all the pieces to white.

![no black piece](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m4jisogidgcktllteqd3.png)

Concealing the color of the pieces encourages the mind to imagine the chessboard in more detail. We can aid this process by revealing the last move in the target square. The code below detects the most recent move and presents it in the center of the appropriate square. To ensure visibility, let's lessen the transparency of the pieces.

```javascript
document.querySelectorAll("cg-board piece").forEach(piece => {
    piece.style.opacity = '0.5';
});

const kwdbElements = document.querySelectorAll("kwdb");
const kwdbContent = kwdbElements[kwdbElements.length - 1].innerHTML;
const lastMoveSquare = document.querySelector("cg-board square.last-move");

let textSpan = document.createElement('span');
textSpan.innerText = kwdbContent;
textSpan.style.color = 'black';
textSpan.style.fontWeight = 'bold';
textSpan.style.fontSize = `${lastMoveSquare.offsetWidth * 0.2}px`;

lastMoveSquare.style.display = 'flex';
lastMoveSquare.style.alignItems = 'center';
lastMoveSquare.style.justifyContent = 'center';

lastMoveSquare.appendChild(textSpan);
```

The result looks like this:

![last move notation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wm1tgdt66egreacw2ef9.png)

During a chess game, it is necessary to execute the code multiple times. To enable this, we can modify the code, install the [tampermonkey](https://www.tampermonkey.net) browser extension, and configure it for the lichess web pages. Below is the complete tampermonkey script:

```javascript
// ==UserScript==
// @name         Update Lichess Piece Classes and Display kwdb Content
// @namespace    http://tampermonkey.net/
// @version      0.9
// @description  Change piece classes to 'white' and display last kwdb content in last-move square
// @author       You
// @match        *://lichess.org/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let lastKwdbContent = '';

    function main() {
        document.querySelectorAll("cg-board piece").forEach(piece => {
            let classNames = piece.className.split(' ');

            if (classNames.length > 0) {
                classNames[0] = 'white';
                piece.className = classNames.join(' ');
                piece.style.opacity = '0.5';
            }
        });

        const kwdbElements = document.querySelectorAll("kwdb");
        if (kwdbElements.length > 0) {
            const kwdbContent = kwdbElements[kwdbElements.length - 1].innerHTML;

            if (kwdbContent !== lastKwdbContent) {
                lastKwdbContent = kwdbContent;

                document.querySelectorAll("cg-board square").forEach(square => {
                    square.innerHTML = '';
                });

                const lastMoveSquare = document.querySelector("cg-board square.last-move");
                if (lastMoveSquare) {
                    let textSpan = document.createElement('span');
                    textSpan.innerText = kwdbContent;
                    textSpan.style.color = 'black';
                    textSpan.style.fontWeight = 'bold';
                    textSpan.style.fontSize = `${lastMoveSquare.offsetWidth * 0.2}px`;

                    lastMoveSquare.style.display = 'flex';
                    lastMoveSquare.style.alignItems = 'center';
                    lastMoveSquare.style.justifyContent = 'center';

                    lastMoveSquare.appendChild(textSpan);
                }
            }
        }
    }

    window.addEventListener('load', main);

    const observer = new MutationObserver(main);
    observer.observe(document.body, { childList: true, subtree: true });
})();

```

It works on my computer's Chrome and on my android's Firefox browser.

![it works on my machine](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8wlohpjz9xwd5fhymdj5.png)

After playing thousands of games, I may finally be able to play fully-blindfold chess. Also, by paying attention to the displayed last move, especially on the square names, I may develop the skill to read chess books without needing a chessboard.

In the next decade, I should see significant improvement in my chess skills. By the time I reach my 50s, I should become a highly respected player in the chess community.

On the other hand, there is always a chance for me to participate physically in a chess tournament, where I will undoubtedly be defeated by players of all skill levels and get forced to face the truth one more time: there is no shortcut, becoming better at chess requires consistent study.