Use shortcut to open your github

Use shortcut open your github

Από την 20/04/2023. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         Use shortcut to open your github
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Use shortcut open your github
// @author       You
// @include     https://github.com/
// @match       https://github.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=github.com
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    let commaCount = 0; // We can move the counter outside of the event listener
    let timer = null
    document.addEventListener('keydown', function(event) {
        const href = `https://github1s.com${location.pathname}`;
        if (timer) clearTimeout(timer)
        // We can check if the key pressed is the comma key (key code 188)
        if (event.code === 'Comma') {
            // We can increment the counter each time the comma key is pressed
            commaCount++;
            // If the comma key has been pressed twice, we can open a link
            if (commaCount === 2) {
                window.open(href);
                // We can reset the counter after the link is opened
                commaCount = 0;
            }
        } else {
            // We can reset the counter if any other key is pressed
            commaCount = 0;
        }

        timer = setTimeout(() => { commaCount = 0 }, 1e3)
    });
})();