Edenya-Script

Addon Edenya

目前為 2017-03-11 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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);
        }
    }
})();