Edenya-Script

Addon Edenya

11.03.2017 itibariyledir. En son verisyonu görün.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği yüklemek için Tampermonkey gibi bir uzantı yüklemeniz gerekir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

Bu stili yüklemek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için Stylus gibi bir uzantı kurmanız gerekir.

Bu stili yükleyebilmek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı kurmanız gerekir.

Bu stili yükleyebilmek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         Edenya-Script
// @namespace    http://tampermonkey.net/
// @version      0.100010
// @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) {
        var items = {};
        items.cadre2 = '#dda0dd';
        items.ligneA = '#000000';
        items.dialogue = '#ffffff';
        items.narration = '#ffd700';
        items.cri = '#9acd32';
        items.hj = '#FFDAB9';
        items.BlackDate = '#B09070';
        localStorage.setItem('EdenyaColor', JSON.stringify(items));
        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);
        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;");
            divScript.appendChild(inputColor);
        }
    }
})();