ad bind

Bind AD to <- ->

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         ad bind
// @namespace    http://rainsims.com/
// @version      0.3
// @description  Bind AD to <- ->
// @author       Rain Sims
// @match        http*://*/*
// @exclude      http*://*pr0gramm.com/*
// @exclude      http*://mail.google.com/*
// ==/UserScript==

(function() {
    'use strict';

    var keyMap = {
        65: {
            "keyCode" : 37,
            "which" : 37,
            "charCode" : 0
            },
        68: {
            "keyCode" : 39,
            "which" : 39,
            "charCode" : 0
            }
    };

    function getMapping(key){
        return (key in keyMap) ? keyMap[key] : undefined;
    }

    function addMapping(eventObj, mapping){
        eventObj.keyCode = mapping.keyCode;
        eventObj.which = mapping.which;
        eventObj.charCode = mapping.charCode;
    }

    function fireEvent(evt) {
        var mapping = getMapping(evt.keyCode);

        if(mapping){
            var eventObj;

            if(document.createEventObject) {
                eventObj = document.createEventObject();
                addMapping(eventObj, mapping);
                document.body.fireEvent("on" + evt.type, eventObj);
            } else if(document.createEvent) {
                eventObj = document.createEvent("Events");
                eventObj.initEvent(evt.type, true, true);
                addMapping(eventObj, mapping);
                document.body.dispatchEvent(eventObj);
            }
        }

    }

    function addEvent(element, eventName, callback) {
        if (element.addEventListener) {
            element.addEventListener(eventName, callback, false);
        } else if (element.attachEvent) {
            element.attachEvent("on" + eventName, callback);
        }
    }

    addEvent(document, "keydown", fireEvent);
    addEvent(document, "keyup", fireEvent);
    addEvent(document, "keypress", fireEvent);
})();