dxdchess

good stuff

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         dxdchess
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  good stuff
// @author       aidanch1
// @license      MIT
// @match        https://lichess.org/*
// @icon         https://cdn.myanimelist.net/images/anime/1331/111940l.jpg
// @grant        GM_addStyle
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
    function waitForElm(selector) {
    return new Promise(resolve => {
        if (document.querySelector(selector)) {
            return resolve(document.querySelector(selector));
        }

        const observer = new MutationObserver(mutations => {
            if (document.querySelector(selector)) {
                observer.disconnect();
                resolve(document.querySelector(selector));
            }
        });

        // If you get "parameter 1 is not of type 'Node'" error, see https://stackoverflow.com/a/77855838/492336
        observer.observe(document.body, {
            childList: true,
            subtree: true
        });
    });
}
    function applyStyle(color) {
        GM_addStyle(`
.is2d {
    .king.${color} {
        background-image: url('https://cdn.myanimelist.net/images/characters/5/150011.jpg');
    }
    .queen.${color} {
        background-image: url('https://cdn.myanimelist.net/images/characters/3/150013.jpg');
    }
    .bishop.${color} {
        background-image: url('https://cdn.myanimelist.net/images/characters/16/155349.jpg');
    }
    .knight.${color} {
        background-image: url('https://cdn.myanimelist.net/images/characters/13/150035.jpg');
    }
    .rook.${color} {
        background-image: url('https://cdn.myanimelist.net/images/characters/2/216619.jpg');
    }
    .pawn.${color} {
        background-image: url('https://cdn.myanimelist.net/images/characters/4/211641.jpg');
    }
}
    `);
    }
    if (document.querySelector('.puzzle')) {
        waitForElm('.no-square').then(elm => {
            const color = elm.firstChild.classList.contains('white') ? 'white' : 'black';
            applyStyle(color);
        });
    } else {
        const user = document.body.getAttribute('data-user');
        const meta = document.querySelector('.game__meta__players');
        const color = meta.children[0].innerText.toLowerCase().includes(user) ? 'white' : 'black';
        applyStyle(color);
    }
})();