Edenya-Script

Addon Edenya

Verze ze dne 13. 03. 2017. Zobrazit nejnovější verzi.

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         Edenya-Script
// @namespace    http://tampermonkey.net/
// @version      0.100011
// @description  Addon Edenya
// @author       Valkazaar
// @match        http://www.edenya.net/_vahal/*
// @grant        none
// @include        http://www.edenya.net/_vahal/*
// @include        https://www.edenya.net/_vahal/*
// ==/UserScript==

(function () {
    'use strict';
    // Vérification de la présence de la variable localStorage EdenyaColor
    // et instanciation de base si nécessaire
    var localColor = localStorage.getItem('EdenyaColor');
    if (localColor === null) {
        localColor = {};
        localColor.cadre2 = '#dda0dd';
        localColor.ligneA = '#000000';
        localColor.dialogue = '#ffffff';
        localColor.narration = '#ffd700';
        localColor.cri = '#9acd32';
        localColor.hj = '#FFDAB9';
        localColor.BlackDate = '#B09070';
        localStorage.setItem('EdenyaColor', JSON.stringify(localColor));
        localColor = localStorage.getItem('EdenyaColor');
    }

    var localColorParsed = JSON.parse(localColor);
    if (localColorParsed.BlackDate === undefined) {
        localColorParsed.BlackDate = '#B09070';
        localStorage.setItem('EdenyaColor', JSON.stringify(localColorParsed));
    }

    // Remplacement des dates écrites en noir dans les forums.
    var x = document.getElementsByTagName("font");
    for (var i = 0; i < x.length; i++) {
        if (x[i].getAttribute('color') !== null) {
            x[i].setAttribute('color', (x[i].getAttribute('color')).replace('#000000', localColorParsed.BlackDate));
            x[i].setAttribute('color', (x[i].getAttribute('color')).replace('\\"', ''));
            x[i].setAttribute('color', (x[i].getAttribute('color')).replace('\\"', ''));
        }
    }

    // Colorisation des éléments
    for (var item in localColorParsed) {
        x = document.getElementsByClassName(item);
        for (var j = 0; j < x.length; j++) {
            x[j].style.color = localColorParsed[item];
        }
    }

    // Positionnement sur la colone de gauche pour y ajouter les éléments (raccourcis et gestion des couleurs)
    x = document.querySelector(".menu");
    if (x !== null) {
        var divScript = document.createElement("div");
        var localShortcut = localStorage.getItem('EdenyaShortcut');
        if (localShortcut === null) {
            var shortcut = { 'accueil': 'https://www.edenya.net/_vahal/' };
            localStorage.setItem('EdenyaShortcut', JSON.stringify(shortcut));
            localShortcut = localStorage.getItem('EdenyaShortcut');
        }
        var localShortcutParsed = JSON.parse(localShortcut);

        var titre = document.createElement("p");
        var linkToAdd = document.createElement("span");

        linkToAdd.innerHTML = "<a href='#'> Ajouter </a>";
        linkToAdd.setAttribute("onclick", "var nom=prompt('Nom du shortcut ?');if (nom!==null){var z = localStorage.getItem('EdenyaShortcut');z = JSON.parse(z);z[nom]=document.URL;localStorage.setItem('EdenyaShortcut',JSON.stringify(z));location.href = location.href;}");
        titre.innerText = "Raccourcis : ";
        titre.appendChild(linkToAdd);
        divScript.appendChild(titre);
        for (item in localShortcutParsed) {
            var linkToDelete = document.createElement("img");
            linkToDelete.setAttribute('src', '../images/bad.gif');
            linkToDelete.setAttribute('onclick', 'var z = localStorage.getItem("EdenyaShortcut");z = JSON.parse(z);delete z["' + item + '"];localStorage.setItem("EdenyaShortcut",JSON.stringify(z));location.href = location.href;');
            var ligneShortcut = document.createElement("span");
            ligneShortcut.setAttribute('style', 'display:block;');
            var linkShortcut = document.createElement("a");
            linkShortcut.setAttribute('href', localShortcutParsed[item]);
            linkShortcut.innerText = item + " ";
            ligneShortcut.appendChild(linkShortcut);
            ligneShortcut.appendChild(linkToDelete);
            divScript.appendChild(ligneShortcut);
        }
        divScript.className = "cadre";
        divScript.style = "width:200";
        x.appendChild(divScript);
        titre = document.createElement("p");
        titre.innerText = "Couleurs utilisées :";
        divScript.appendChild(titre);

        var localTips = localStorage.getItem('EdenyaTips');
        if (localTips === null) {
            localTips = {};
            localTips.cadre2 = "Couleur générale titre, panneau PJ,...";
            localTips.ligneA = "Couleur texte hors balises RP";
            localTips.dialogue = "Texte d'un dialogue";
            localTips.narration = "Texte de narration";
            localTips.cri = "Texte crié";
            localTips.hj = "descriptions HJ";
            localTips.BlackDate = "couleur des dates dans les forums";
            localStorage.setItem('EdenyaTips', JSON.stringify(localTips));
            localTips = localStorage.getItem('EdenyaTips');
        }
        var localTipsParsed = JSON.parse(localTips);

        for (item in localColorParsed) {
            var inputColor = document.createElement("input");
            inputColor.setAttribute("id", item);
            inputColor.setAttribute("type", "color");
            inputColor.setAttribute("class", "bouton");
            inputColor.setAttribute("value", localColorParsed[item]);
            inputColor.setAttribute("style", "width:25;padding:0");
            inputColor.setAttribute("onChange", "var z = localStorage.getItem('EdenyaColor');z = JSON.parse(z);z['" + inputColor.getAttribute("id") + "'] = document.getElementById('" + inputColor.getAttribute("id") + "').value; localStorage.setItem('EdenyaColor',JSON.stringify(z));location.href = location.href;");
            inputColor.title = localTipsParsed[item];
            divScript.appendChild(inputColor);
        }
    }
})();