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

Verze ze dne 05. 11. 2022. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

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