Custom Layout for monkeytype.com (that works)

custom layout for monkeytype mini keyboard

Ajankohdalta 30.1.2022. Katso uusin versio.

// ==UserScript==
// @name         Custom Layout for monkeytype.com (that works)
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  custom layout for monkeytype mini keyboard
// @author       Sasha231
// @match        https://monkeytype.com/
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function ide(key){
        document.getElementById("Key"+key).id = "TEMP_"+key;
    }
    function swap(key1, key2){
        document.getElementById("TEMP_"+key1).innerHTML = "<span class='letter' style='text-transform: capitalize;'>"+key2+"</span>";
        document.getElementById("TEMP_"+key1).id = "Key"+key2;
    }
    function name(title){
        document.getElementById("KeySpace").innerHTML = '<span class="letter">'+title+'</span>';
    }

        //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 = function (){
        window.onload = function (){

            ///ID-ING
            const keys = ["Q","W","E","R","T","Y","U","I","O","P",
                          "A","S","D","F","G","H","J","K","L","Semicolon",
                          "Z","X","C","V","B","N","M","Comma","Period","Slash"]
            for (let k in keys) {
            ide(keys[k]);
            };
            //set name of layout that you will see on spacebar
            name("Esperanta Dvoraka")
            //use capital letters for keys, swap("a","b"); will not work, you will have to use swap("A","B");
            //for symbols like ";" type them like "Semicolon", if you have doubts on the word then just inspect element the key and see what the 'id' of the element is
            swap("Q","Ŝ");
            swap("W",",");
            swap("E",".");
            swap("R","J");
            swap("T","P");
            swap("Y","F");
            swap("U","G");
            swap("I","M");
            swap("O","R");
            swap("P","L");
            swap("A","A");
            swap("S","O");
            swap("D","E");
            swap("F","U");
            swap("G","I");
            swap("H","D");
            swap("J","K");
            swap("K","T");
            swap("L","N");
            swap("Semicolon","S");
            swap("Z","Z");
            swap("X","Ĉ");
            swap("C","Ŭ");
            swap("V","Ĵ");
            swap("B","Ĥ");
            swap("N","B");
            swap("M","C");
            swap("Comma","Ĝ");
            swap("Period","V");
            swap("Slash","H");

        };
    })();