Greasy Fork is available in English.

ad bind

Bind AD to <- ->

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==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);
})();