Keymap Overlay for Custom Layouts on monkeytype.com (Updated)

Swap keys repeatedly on a base keymap layout till you get your modified version of the layout

Versione datata 05/11/2022. Vedi la nuova versione l'ultima versione.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         Keymap Overlay for Custom Layouts on monkeytype.com (Updated)
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Swap keys repeatedly on a base keymap layout till you get your modified version of the layout
// @author       full alt
// @match        https://monkeytype.com/
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    async function swap(key1, key2){
        var s1 = "[data-key='"+key1+"']"
        var s2 = "[data-key='"+key2+"']"
        var k1 = document.querySelectorAll(s1)[0];
        var k2 = document.querySelectorAll(s2)[0];
        k1.setAttribute("data-key",key2)
        k2.setAttribute("data-key",key1)
        var tempk1val = k1.getElementsByTagName("span")[0].innerText
        k1.getElementsByTagName("span")[0].innerText = k2.getElementsByTagName("span")[0].innerText
        k2.getElementsByTagName("span")[0].innerText = tempk1val
    }

    //just right click anywhere for the changes to be made
    //the goal is to have keys swap places with each other on the keymap to suit your layout
    window.oncontextmenu = async function (){
        //IMPORTANT: For letters use inputs like "hH" or "jJ" since the updated site has 2 characters being used
        //for symbols, if you don't know the what the key is then just inspect element the key and see what the 'id' of the element is
        /*
        OLD CODE, IGNORE THIS
        swap("O","Semicolon");
        swap("F","G");
        swap("Z","Quote");
        swap("K","Quote");
        swap("D","Quote");
        swap("C","Quote");
        swap("X","Quote");
        */
        await swap("vV","fF");
        await swap("mM","qQ");
        await swap("fF","zZ");
        await swap("gG","kK");
        await swap("pP","cC");
        await swap("fF","kK");
        await swap("mM","kK");
    };
})();