Untitled

 avatar
unknown
javascript
2 years ago
1.7 kB
5
No Index
// ==UserScript==
// @name         KG_Main_Page_Navigation
// @namespace    klavogonki
// @version      2024-05-13
// @description  Fast main page navigation
// @author       Patcher
// @match        *://klavogonki.ru/g*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=klavogonki.ru
// @grant        none
// ==/UserScript==

(function() {

    // Define the URL of the main page
    const kgMainPage = 'https://klavogonki.ru';

    // Define the duration threshold for a long press in milliseconds
    const longPressDuration = 300;

    // Variable to store the time when the right mouse button is pressed down
    let mouseDownTime;

    // Add event listener for mouse down event
    document.addEventListener('mousedown', e => {
        // Check if the right mouse button is pressed
        if (e.button === 2) {
            // Record the current time when the right mouse button is pressed down
            mouseDownTime = Date.now();
        }
    });

    // Add event listener for mouse up event
    document.addEventListener('mouseup', e => {
        // Check if the right mouse button is released
        if (e.button === 2) {
            // Calculate the duration of the press by subtracting the mouse down time from the current time
            const pressDuration = Date.now() - mouseDownTime;
            // Check if the press duration exceeds the long press duration threshold
            if (pressDuration >= longPressDuration) {
                // If the press duration is longer than or equal to the threshold, navigate to the main page URL
                window.location.href = kgMainPage;
            }
        }
    });

})();
Editor is loading...
Leave a Comment