FastReader for Hindi and English

Enhance fast reading by highlighting specific syllables in Hindi script and letters in English script for Hindi and English web pages respectively. Works on all websites. Press Alt + R to toggle FastReader.

当前为 2024-03-07 提交的版本,查看 最新版本

// ==UserScript==
// @name         FastReader for Hindi and English
// @version      1.8
// @description  Enhance fast reading by highlighting specific syllables in Hindi script and letters in English script for Hindi and English web pages respectively. Works on all websites. Press Alt + R to toggle FastReader.
// @license      MIT
// @match        *://*/*
// @grant        none
// @author       iamnobody
// @namespace http://tampermonkey.net/
// ==/UserScript==

(function() {
    'use strict';

    // Check if the current element is part of the main website
    if (window.self === window.top) {
        // Create and style the toggle button
        var toggleButton = document.createElement('button');
        toggleButton.id = 'fast-reader-toggle-button';
        toggleButton.style.position = 'fixed';
        toggleButton.style.bottom = '20px';
        toggleButton.style.left = '20px';
        toggleButton.style.width = '50px';
        toggleButton.style.height = '50px';
        toggleButton.style.borderRadius = '50%';
        toggleButton.style.backgroundColor = 'red';
        toggleButton.style.color = 'white';
        toggleButton.style.fontSize = '24px';
        toggleButton.style.border = 'none';
        toggleButton.innerText = 'R';
        toggleButton.setAttribute('aria-label', 'Toggle Fast Reading (Alt + R)');
        document.body.appendChild(toggleButton);

        // Set default state of fast reading feature
        var isFastReadingOn = false;

        // Add event listener to toggle button
        toggleButton.addEventListener('click', toggleFastReading);

        // Add event listener for Alt + R keyboard shortcut
        document.addEventListener('keydown', function(event) {
            if (event.altKey && event.key === 'r') {
                toggleFastReading();
            }
        });

        // Function to toggle fast reading feature
        function toggleFastReading() {
            // Toggle fast reading feature and button color
            isFastReadingOn = !isFastReadingOn;
            toggleButton.style.backgroundColor = isFastReadingOn ? 'green' : 'red';

            // Activate/deactivate fast reading feature based on button state
            if (isFastReadingOn) {
                activateFastReading();
            } else {
                deactivateFastReading();
            }
        }

        // Add other functions (activateFastReading, deactivateFastReading, highlightWord, isHindiWord, isSpecialHindiCharacter) here...
    }

    // Add the rest of your existing code here...
})();