Edenya-Script

Addon Edenya

当前为 2017-03-11 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

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