liChess.org Colorize Arrows

lichessarrows

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name          liChess.org Colorize Arrows
// @namespace     http://userstyles.org
// @description	  lichessarrows
// @author        ceberous
// @homepage      https://creatitees.info
// @include       https://lichess.org/*
// @require		  http://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js
// @run-at        document-start
// @version       0.5
// ==/UserScript==

( function() {

var colorPreferences = {};
colorPreferences.colors = {
    green: "#009933",
    yellow: "#ccff33",
    purple: "#cc00cc",
    orange: "#ff3300",
    red: "#ff0000",
    blue: "#0066cc",
};
colorPreferences.arrows = {
    large: { color: colorPreferences.colors.green , opacity: "1.0" },
    medium: { color: colorPreferences.colors.yellow , opacity: "0.8" },
    small: { color: colorPreferences.colors.blue , opacity: "0.8" },
    xs: { color: colorPreferences.colors.purple , opacity: "0.6" },
    xxs: { color: colorPreferences.colors.red , opacity: "0.5" },
};

var clickWatchInterval = null;
function startInterval() {

    clickWatchInterval = setInterval( overDrawArrows , 250 );
}


function clearInterval() {
    clearInterval(clickWatchInterval);
}

function overDrawArrows() {

    $("[marker-end]").each( function( i , ielem ) {

        var wSW = parseInt( $( ielem ).attr( "stroke-width" ) );
        switch( wSW ) {
            case 15:
                $( ielem ).attr( "stroke" , colorPreferences.arrows.large.color );
                $( ielem ).attr( "opacity" , colorPreferences.arrows.large.opacity );
                break;
            case 12:
                $( ielem ).attr( "stroke" , colorPreferences.arrows.medium.color );
                $( ielem ).attr( "opacity" , colorPreferences.arrows.medium.opacity );
                break;
            case 11:
                $( ielem ).attr( "stroke" , colorPreferences.arrows.small.color );
                $( ielem ).attr( "opacity" , colorPreferences.arrows.small.opacity );
                break;
            case 10:
                $( ielem ).attr( "stroke" , colorPreferences.arrows.small.color );
                $( ielem ).attr( "opacity" , colorPreferences.arrows.small.opacity );
                break;
            case 8:
                $( ielem ).attr( "stroke" , colorPreferences.arrows.xs.color );
                $( ielem ).attr( "opacity" , colorPreferences.arrows.xs.opacity );
                break;
            /*     
            case 6:
                $( ielem ).attr( "stroke" , colorPreferences.arrows.xs.color );
                $( ielem ).attr( "opacity" , colorPreferences.arrows.xs.opacity );
                break;                 
            case 2:
                $( ielem ).attr( "stroke" , colorPreferences.arrows.xs.color );
                $( ielem ).attr( "opacity" , colorPreferences.arrows.xs.opacity );
                break;
            */
            default:
                $( ielem ).attr( "stroke" , colorPreferences.arrows.xxs.color );
                $( ielem ).attr( "opacity" , colorPreferences.arrows.xxs.opacity );
                break;
        }

    });
}


$(document).ready(function(){

    startInterval();
    /*
    $(document).click(function(e) {
        //alert("left click");
        //if ( clickWatchInterval === null ) { startInterval(); }
        overDrawArrows();
    });

    $(document).bind("contextmenu",function(e){
        e.preventDefault();
        //alert("right click");
        //if ( clickWatchInterval === null ) { startInterval(); }
        overDrawArrows();
    });
    */

});

})();