// ==UserScript== // @name Dreadcast Chat Enhancer // @namespace https://greasyfork.org/scripts/21359-dreadcast-chat-enhancer/ // @version 2.2.2.2 // @description Améliore le chat de Dreadcast. // @author MockingJay, Odul, Ladoria, Isilin // @match https://www.dreadcast.eu/Main // @match https://www.dreadcast.net/Main // @grant GM_setValue // @grant GM_getValue // @grant GM_deleteValue // @grant GM_listValues // @license http://creativecommons.org/licenses/by-nc-nd/4.0/ // @downloadURL none // ==/UserScript== //Lit les variables dans GM à la demande. A utiliser pour chaque déclaration de variable qui est copiée en mémoire. //initValue: Valeur par défaut de la variable, qu'on lui donne à la déclaration et qu'elle garde si pas d'équivalent en mémoire. localVarName: Valeur GM locale. function initLocalMemory(defaultValue, localVarName) { if (GM_getValue(localVarName) === undefined) { GM_setValue(localVarName, defaultValue); return defaultValue; } else { return GM_getValue(localVarName); } } function rgb2hex(orig){ var rgb = orig.replace(/\s/g,'').match(/^rgba?\((\d+),(\d+),(\d+)/i); return (rgb && rgb.length === 4) ? "#" + ("0" + parseInt(rgb[1],10).toString(16)).slice(-2) + ("0" + parseInt(rgb[2],10).toString(16)).slice(-2) + ("0" + parseInt(rgb[3],10).toString(16)).slice(-2) : orig; } $(document).ready(function() { //********************************************** // DECLARATION DES VARIABLES //********************************************** //CONSTANTES const W_ZONE_CHAT = 317; //Largeur de base des différents éléments du chat. const W_MSG = 290; const W_CHATCONTENT = 308; //Valeur pas d'origine, mais nécessaire pour le script. const W_CHAT = 328; const W_ONGLETS_CHAT = 254; const W_CHATFORM = 288; const DEFAULT_CHAT_COLOR = rgb2hex($("#zone_chat .zone_infos").css("color")); $('').appendTo("body"); const DEFAULT_CHAT_COLOR5 = ($(".couleur5").css("color") !== undefined) ? rgb2hex($(".couleur5").css("color")) : "#999"; $('').appendTo("body"); const DEFAULT_CHAT_COLOR_RED = ($(".couleur_rouge").css("color") !== undefined) ? rgb2hex($(".couleur_rouge").css("color")) : "#D32929"; const DEFAULT_ZONE_DROITE_BG = $("#zone_droite").css("background"); //Permet de restituer le fond d'origine (ou de skin) de la zone droite lorsque le chat est à sa largeur initiale. const DEFAULT_SCRIPT_ZONE_DROITE_BG = 'http://i.imgur.com/kPzRqS2.png'; const DEFAULT_SCRIPT_ZONE_CHAT_BG = 'http://i.imgur.com/0J3wOK0.png'; const DEFAULT_ALERT_CHAT_AUDIO_URL = 'http://s1download-universal-soundbank.com/mp3/sounds/2041.mp3'; //Initialisation variables de préférences var autoScroll = initLocalMemory(false, "DCCE_autoScroll"); var scrollBar = initLocalMemory(true, "DCCE_scrollBar"); var typePredict = initLocalMemory(true, "DCCE_typePredict"); var chatExtend = initLocalMemory(0, "DCCE_chatExtend"); var scriptZoneDroiteBG = initLocalMemory(DEFAULT_SCRIPT_ZONE_DROITE_BG, "DCCE_scriptZoneDroiteBG"); var scriptZoneChatBG = initLocalMemory(DEFAULT_SCRIPT_ZONE_CHAT_BG, "DCCE_scriptZoneChatBG"); var alertChatAudioURL = initLocalMemory(DEFAULT_ALERT_CHAT_AUDIO_URL, "DCCE_alertChatAudioURL"); var activateAlertChat = initLocalMemory(false, "DCCE_activateAlertChat"); var chatWidthStyle = $('').appendTo("head"); //Règle CSS pour appliquer la couleur du skin aux emotes. Visible uniquement côté client. var chatEmoteStyleWe = $('').appendTo("head"); var chatEmoteStyleYe = $('').appendTo("head"); var chatEmoteStyleSpeech = $('').appendTo("head"); //Redresse les paroles dans des emotes //Un non-utilisateur du script aura la couleur de base bleu clair. //********************************************** // DECLARATION DES FONCTIONS, MISE EN PLACE DU CSS //********************************************** $("#chatContent").css({ "overflow-x": 'hidden', "overflow-y": 'scroll', height: '313px', //width traitée dans setChatCSS }); //Applique la barre de défilement en fonction des préférences, et règle la largeur des lignes dans le chat. function setChatContentScroll() { if(scrollBar) { $("#chatContent").css({"padding-right": '0px'}); chatWidthStyle.text('#zone_chat .zone_infos .msg{width:' + (W_MSG + chatExtend) + 'px}'); $("#zone_chat").css({width: (W_ZONE_CHAT + 5 + chatExtend) + 'px'}); //Assure d'avoir le fond derrière la scrollbar lorsque le chat est étendu. } else { $("#chatContent").css({"padding-right": '15px'}); chatWidthStyle.text('#zone_chat .zone_infos .msg{width:' + (W_MSG + 7 + chatExtend) + 'px}'); $("#zone_chat").css({width: (W_ZONE_CHAT + chatExtend) + 'px'}); } } var $dcce_background = $('
').prependTo($("#zone_page")).css({left: '907px', top: '142px', height: '461px'}); function setZoneChatBackground() { if(chatExtend > 0) { $dcce_background.css({background: 'url("' + scriptZoneChatBG + '")', "background-size": '100% 100%', width: (W_ZONE_CHAT + 13 + chatExtend) + 'px'}); $("#zone_droite").css({background: 'url("' + scriptZoneDroiteBG + '")'}); } else { $dcce_background.css({ background: 'none', width: '0px' }); $("#zone_droite").css({background: DEFAULT_ZONE_DROITE_BG}); } } function setChatCSS() { setChatContentScroll(); //Comprend déjà #ZONE_CHAT et .MSG setZoneChatBackground(); //Fixer les largeurs restantes $("#chatContent").width(W_CHATCONTENT + chatExtend); $("#zone_chat .zone_infos .chat").width(W_CHAT + chatExtend); $("#zone_chat #onglets_chat").width(W_ONGLETS_CHAT + chatExtend); $("#chatForm").width(W_CHATFORM + chatExtend); } setChatCSS(); //Appliquer à l'initialisation. //Initialisation du bouton d'alerte, utilisé quand l'autoScroll est désactivé. var $newMessageAlert = $('
').appendTo($('#zone_chat')); $newMessageAlert.text("⚠ Nouveau message! ⚠"); $newMessageAlert.css({ display: 'none', top: '45px', "text-align": 'center', cursor: 'pointer', background: '#fff', border: '1px solid #fff', color: '#0296bb', "margin-top": '2px', "-webkit-box-shadow": '0 0 4px 2px #329bc2', }); $newMessageAlert.attr('onmouseover', 'this.style.backgroundColor=\"#0b9bcb\";this.style.color=\"#FFFFFF\";'); $newMessageAlert.attr('onmouseout', 'this.style.backgroundColor=\"#FFFFFF\";this.style.color=\"#0296bb\";'); //Initialisation bandeau latéral var $toggleAutoScroll = $('
  • '+'
  • ').prependTo($('#bandeau ul.menus')); if(autoScroll) { $("#toggleAutoScroll").text("AS on"); } else { $("#toggleAutoScroll").text("AS off"); } $("#toggleAutoScroll").css({ cursor: 'pointer', }); //$("#toggleAutoScroll").attr('onmouseover', 'this.style.color=\"#0073d5\";'); //$("#toggleAutoScroll").attr('onmouseout', 'this.style.color=\"#999\";'); $("#toggleAutoScroll").hover( function(){ $(this).css("color", "#0073d5"); }, function(){ var colorAS = autoScroll ? "#999" : "#D00000"; $(this).css("color", colorAS); } ); //Changer l'autoscroll au clic sur le bandeau latéral. $("#toggleAutoScroll").click(function(){ if(autoScroll) { autoScroll = false; $("#toggleAutoScroll").text("AS off"); } else { autoScroll = true; $("#toggleAutoScroll").text("AS on"); } GM_setValue("DCCE_autoScroll", autoScroll); }); //Fait défiler le chat jusqu'en bas. function scrollChat(){ $('#chatContent').stop().animate({ scrollTop: $('#chatContent')[0].scrollHeight }, 800); $newMessageAlert.stop().fadeOut(500); } var colorTagStyle = $('').appendTo("head"); //Forcer la couleur grise sur les messages chuchotés. //********************************************** //INTERFACE DE CONFIGURATION UTILISATEUR //********************************************** var $databox = $('#zone_dataBox'); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //Constructeur de fenêtre de configuration //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ var DCCE_ConfigurationWindow = function () { var window_width = '560px'; var window_height = '450px'; var $config_window = $('
    '); $config_window.draggable(); $config_window.addClass('dataBox focused ui-draggable'); $config_window.css({ width: window_width, "margin-left": '-185px', display: 'block', position: 'absolute', "z-index": '2', }); for (var i = 1; i <= 8; i++) { $('
    ').appendTo($config_window); } var $config_head = $('
    ').appendTo($config_window); $('