Roll20 Character Switcher

Switches the chatting character to the one who's sheet you clicked on

Versione datata 03/02/2017. Vedi la nuova versione l'ultima versione.

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         Roll20 Character Switcher
// @namespace    de.idrinth
// @homepage     https://github.com/Idrinth/Roll20-Character-Switcher
// @version      1.0.0
// @description  Switches the chatting character to the one who's sheet you clicked on
// @author       Idrinth
// @match        https://app.roll20.net/editor/
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    var a = function() {
        document.getElementsByTagName('body')[0].addEventListener('mousedown', function(event) {
            console.log('US mousedown');
            var e = window.event || event;
            if (e.target.tagName === 'BUTTON' && e.target.hasAttribute('type') && e.target.getAttribute('type') === 'roll') {
                var character = e.target;
                while (!character.hasAttribute('data-characterid')) {
                    character = character.parentNode;
                }
                var id = 'character|' + character.getAttribute('data-characterid');
                var select = document.getElementById('speakingas');
                for (var i = 0; i < select.options.length; i++) {
                    if (select.options[i].value === id) {
                        select.selectedIndex = i;
                        return;
                    }
                }
            }
        });
    };
    eval('(' + a.toString() + '())');
})();