typing-practice

15.07.2021, 22:09:13

17.07.2021 itibariyledir. En son verisyonu görün.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name        typing-practice
// @namespace   Violentmonkey Scripts
// @match       *://*/*
// @grant       GM_registerMenuCommand
// @grant       GM_openInTab
// @version     1.0
// @author      -
// @description 15.07.2021, 22:09:13
// ==/UserScript==

(function () {
    'use strict';

    let gText;
    function openTypingPractice(text) {
        const baseUrl = "https://10fastfingers.com/widget/typingtest";
        const params = new URLSearchParams({
            dur: "60000",
            rand: "0",
            words: text,
        });
        const url = `${baseUrl}?${params.toString()}`.replace(/\+/g, "%20"); // 10fastfingers doesn't consider "+" as space
        GM_openInTab(url);
    }
    // Alt-T
    function detectHotKey(e) {
        // Use "KeyboardEvent.code" to support the same key position regardless of keyboard layout
        return e.altKey && e.code === "KeyT";
    }
    function onKeyDown(e) {
        if (gText && detectHotKey(e)) {
            const cleanText = gText.toLowerCase().split(/\s/).join(" ");
            openTypingPractice(cleanText);
        }
    }
    function onSelectionChange() {
        // Enable hotkey only when there's a selection
        document.removeEventListener("keydown", onKeyDown);
        const selection = document.getSelection();
        gText = selection === null || selection === void 0 ? void 0 : selection.toString().trim();
        if (!gText) {
            return;
        }
        document.addEventListener("keydown", onKeyDown);
    }
    function register() {
        document.addEventListener("selectionchange", onSelectionChange);
    }
    function main() {
        register();
    }
    main();

}());