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

2022/11/05のページです。最新版はこちら

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
  1. // ==UserScript==
  2. // @name Keymap Overlay for Custom Layouts on monkeytype.com (Updated)
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description Swap keys repeatedly on a base keymap layout till you get your modified version of the layout
  6. // @author full alt
  7. // @match https://monkeytype.com/
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. async function swap(key1, key2){
  15. var s1 = "[data-key='"+key1+"']"
  16. var s2 = "[data-key='"+key2+"']"
  17. var k1 = document.querySelectorAll(s1)[0];
  18. var k2 = document.querySelectorAll(s2)[0];
  19. k1.setAttribute("data-key",key2)
  20. k2.setAttribute("data-key",key1)
  21. var tempk1val = k1.getElementsByTagName("span")[0].innerText
  22. k1.getElementsByTagName("span")[0].innerText = k2.getElementsByTagName("span")[0].innerText
  23. k2.getElementsByTagName("span")[0].innerText = tempk1val
  24. }
  25.  
  26. //just right click anywhere for the changes to be made
  27. //the goal is to have keys swap places with each other on the keymap to suit your layout
  28. window.oncontextmenu = async function (){
  29. //IMPORTANT: For letters use inputs like "hH" or "jJ" since the updated site has 2 characters being used
  30. //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
  31. /*
  32. OLD CODE, IGNORE THIS
  33. swap("O","Semicolon");
  34. swap("F","G");
  35. swap("Z","Quote");
  36. swap("K","Quote");
  37. swap("D","Quote");
  38. swap("C","Quote");
  39. swap("X","Quote");
  40. */
  41. await swap("vV","fF");
  42. await swap("mM","qQ");
  43. await swap("fF","zZ");
  44. await swap("gG","kK");
  45. await swap("pP","cC");
  46. await swap("fF","kK");
  47. await swap("mM","kK");
  48. };
  49. })();