Dreadcast Chat Enhancer

Améliore le chat de Dreadcast.

当前为 2020-11-10 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Dreadcast Chat Enhancer
  3. // @namespace https://greasyfork.org/scripts/21359-dreadcast-chat-enhancer/
  4. // @version 2.3.16
  5. // @description Améliore le chat de Dreadcast.
  6. // @author MockingJay, Odul, Ladoria, Isilin
  7. // @match https://www.dreadcast.eu/Main
  8. // @match https://www.dreadcast.net/Main
  9. // @grant GM_setValue
  10. // @grant GM_getValue
  11. // @grant GM_deleteValue
  12. // @grant GM_listValues
  13. // @license http://creativecommons.org/licenses/by-nc-nd/4.0/
  14. // ==/UserScript==
  15.  
  16. //Lit les variables dans GM à la demande. A utiliser pour chaque déclaration de variable qui est copiée en mémoire.
  17. //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.
  18. function initLocalMemory(defaultValue, localVarName) {
  19. if (GM_getValue(localVarName) === undefined) {
  20. GM_setValue(localVarName, defaultValue);
  21. return defaultValue;
  22. } else {
  23. return GM_getValue(localVarName);
  24. }
  25. }
  26.  
  27. function rgb2hex(orig){
  28. var rgb = orig.replace(/\s/g,'').match(/^rgba?\((\d+),(\d+),(\d+)/i);
  29. return (rgb && rgb.length === 4) ? "#" +
  30. ("0" + parseInt(rgb[1],10).toString(16)).slice(-2) +
  31. ("0" + parseInt(rgb[2],10).toString(16)).slice(-2) +
  32. ("0" + parseInt(rgb[3],10).toString(16)).slice(-2) : orig;
  33. }
  34.  
  35. $(document).ready(function() {
  36.  
  37. //**********************************************
  38. // DECLARATION DES VARIABLES
  39. //**********************************************
  40.  
  41. //CONSTANTES
  42. const W_ZONE_CHAT = 317; //Largeur de base des différents éléments du chat.
  43. const W_MSG = 290;
  44. const W_CHATCONTENT = 308; //Valeur pas d'origine, mais nécessaire pour le script.
  45. const W_CHAT = 328;
  46. const W_ONGLETS_CHAT = 254;
  47. const W_CHATFORM = 288;
  48.  
  49. const DEFAULT_CHAT_COLOR = rgb2hex($("#zone_chat .zone_infos").css("color"));
  50. $('<div class="couleur5" style="display:none;"></div>').appendTo("body");
  51. const DEFAULT_CHAT_COLOR5 = ($(".couleur5").css("color") !== undefined) ? rgb2hex($(".couleur5").css("color")) : "#999";
  52. $('<div class="couleur_rouge" style="display:none;"></div>').appendTo("body");
  53. const DEFAULT_CHAT_COLOR_RED = ($(".couleur_rouge").css("color") !== undefined) ? rgb2hex($(".couleur_rouge").css("color")) : "#D32929";
  54.  
  55. 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.
  56. const DEFAULT_SCRIPT_ZONE_DROITE_BG = 'https://i.imgur.com/kPzRqS2.png';
  57. const DEFAULT_SCRIPT_ZONE_CHAT_BG = 'https://i.imgur.com/0J3wOK0.png';
  58.  
  59. const DEFAULT_ALERT_CHAT_AUDIO_URL = 'https://www.dreadcast.net/sons/dcce.mp3';
  60.  
  61. //Initialisation variables de préférences
  62. var autoScroll = initLocalMemory(false, "DCCE_autoScroll");
  63. var scrollBar = initLocalMemory(true, "DCCE_scrollBar");
  64. var typePredict = initLocalMemory(true, "DCCE_typePredict");
  65. var alertVolume = initLocalMemory(1, "DCCE_alertVolume");
  66. var chatExtend = initLocalMemory(0, "DCCE_chatExtend");
  67.  
  68. const mrpDefaultCommands = [
  69. { alias:"env", name:"Environment", color:"#00FF00", bold:false, rp:true },
  70. { alias:"sis", name:"Ta soeur", color:"#00FFFF", bold:true, rp:false },
  71. { alias:"creepy", name:"Le Monstre", color:"#FF6464", bold:false, rp:true }
  72. ];
  73. var mrpCommandsString = initLocalMemory(JSON.stringify(mrpDefaultCommands), "DCCE_MRP");
  74. var mrpCommands = JSON.parse(mrpCommandsString);
  75.  
  76. var scriptZoneDroiteBG = initLocalMemory(DEFAULT_SCRIPT_ZONE_DROITE_BG, "DCCE_scriptZoneDroiteBG");
  77. var scriptZoneChatBG = initLocalMemory(DEFAULT_SCRIPT_ZONE_CHAT_BG, "DCCE_scriptZoneChatBG");
  78.  
  79. var alertChatAudioURL = initLocalMemory(DEFAULT_ALERT_CHAT_AUDIO_URL, "DCCE_alertChatAudioURL");
  80. var activateAlertChat = initLocalMemory(false, "DCCE_activateAlertChat");
  81.  
  82. var chatWidthStyle = $('<style id="chatWidthStyle">').appendTo("head"); //Utilisation d'une règle CSS car objets créés dynamiquement.
  83.  
  84. var chatEmoteStyle = $('<style id="chatEmoteStyle">span[style*="color:#58DCF9;"] em{color: ' + DEFAULT_CHAT_COLOR + ';}</style>').appendTo("head"); //Règle CSS pour appliquer la couleur du skin aux emotes. Visible uniquement côté client.
  85. var chatEmoteStyleWe = $('<style id="chatEmoteStyleWe">.msg.couleur5 span[style*="color:#58DCF9;"] em{color: ' + DEFAULT_CHAT_COLOR5 + ';}</style>').appendTo("head");
  86. var chatEmoteStyleYe = $('<style id="chatEmoteStyleYe">.msg.couleur_rouge span[style*="color:#58DCF9;"] em{color: ' + DEFAULT_CHAT_COLOR_RED + ';}</style>').appendTo("head");
  87. var chatEmoteStyleSpeech = $('<style id="chatEmoteStyleSpeech">.msg em span[style*="color:#FFFFFF;"]{font-style: normal;}</style>').appendTo("head"); //Redresse les paroles dans des emotes
  88. //Un non-utilisateur du script aura la couleur de base bleu clair.
  89.  
  90. //**********************************************
  91. // DECLARATION DES FONCTIONS, MISE EN PLACE DU CSS
  92. //**********************************************
  93.  
  94. $("#chatContent").css({
  95. "overflow-x": 'hidden',
  96. "overflow-y": 'scroll',
  97. //height: '313px', //width traitée dans setChatCSS
  98. "height": '100%',
  99. });
  100.  
  101. //Applique la barre de défilement en fonction des préférences, et règle la largeur des lignes dans le chat.
  102. function setChatContentScroll() {
  103. if(scrollBar) {
  104. $("#chatContent").css({"overflow-y": 'scroll'});
  105. }
  106. else {
  107. $("#chatContent").css({"overflow-y": 'hidden'});
  108. }
  109. }
  110.  
  111.  
  112. var $dcce_background = $('<div id="dcce_background"></div>').prependTo($("#zone_page")).css({left: '907px', top: '142px', height: '461px'}).css({display: 'none'});
  113.  
  114. function setZoneChatBackground() {
  115. if(chatExtend > 0) {
  116. $dcce_background.css({background: 'url("' + scriptZoneChatBG + '")',
  117. "background-size": '100% 100%',
  118. width: (W_ZONE_CHAT + 13 + chatExtend) + 'px'});
  119. $("#zone_droite").css({background: 'url("' + scriptZoneDroiteBG + '")'});
  120. } else {
  121. $dcce_background.css({
  122. background: 'none',
  123. width: '0px'
  124. });
  125. $("#zone_droite").css({background: DEFAULT_ZONE_DROITE_BG});
  126. }
  127. }
  128.  
  129. function setChatCSS() {
  130. setChatContentScroll();
  131. /*setZoneChatBackground();
  132. //Fixer les largeurs restantes
  133. $("#chatContent").width(W_CHATCONTENT + chatExtend);
  134. $("#zone_chat .zone_infos .chat").width(W_CHAT + chatExtend);
  135. $("#zone_chat #onglets_chat").width(W_ONGLETS_CHAT + chatExtend);
  136. $("#chatForm").width(W_CHATFORM + chatExtend);*/
  137. }
  138.  
  139. setChatCSS();
  140.  
  141. //Initialisation du bouton d'alerte, utilisé quand l'autoScroll est désactivé.
  142. var $newMessageAlert = $('<div />').appendTo($('#zone_chat'));
  143. $newMessageAlert.text("⚠ Nouveau message! ⚠");
  144. $newMessageAlert.css({
  145. display: 'none',
  146. top: '45px',
  147. "text-align": 'center',
  148. cursor: 'pointer',
  149. background: '#fff',
  150. border: '1px solid #fff',
  151. color: '#0296bb',
  152. "margin-top": '2px',
  153. "-webkit-box-shadow": '0 0 4px 2px #329bc2',
  154. });
  155. $newMessageAlert.attr('onmouseover', 'this.style.backgroundColor=\"#0b9bcb\";this.style.color=\"#FFFFFF\";');
  156. $newMessageAlert.attr('onmouseout', 'this.style.backgroundColor=\"#FFFFFF\";this.style.color=\"#0296bb\";');
  157.  
  158. //Initialisation bandeau latéral
  159. var $toggleAutoScroll = $('<li id="toggleAutoScroll" class="couleur5" ></li>'+'<li class="separator"></li>').prependTo($('#bandeau ul.menus'));
  160. if(autoScroll) {
  161. $("#toggleAutoScroll").text("AS on");
  162. } else {
  163. $("#toggleAutoScroll").text("AS off");
  164. }
  165. $("#toggleAutoScroll").css({
  166. cursor: 'pointer',
  167. });
  168. //$("#toggleAutoScroll").attr('onmouseover', 'this.style.color=\"#0073d5\";');
  169. //$("#toggleAutoScroll").attr('onmouseout', 'this.style.color=\"#999\";');
  170. $("#toggleAutoScroll").hover(
  171. function(){
  172. $(this).css("color", "#0073d5");
  173. },
  174. function(){
  175. var colorAS = autoScroll ? "#999" : "#D00000";
  176. $(this).css("color", colorAS);
  177. }
  178. );
  179. //Changer l'autoscroll au clic sur le bandeau latéral.
  180. $("#toggleAutoScroll").click(function(){
  181. if(autoScroll) {
  182. autoScroll = false;
  183. $("#toggleAutoScroll").text("AS off");
  184. } else {
  185. autoScroll = true;
  186. $("#toggleAutoScroll").text("AS on");
  187. }
  188. GM_setValue("DCCE_autoScroll", autoScroll);
  189. });
  190.  
  191. //Fait défiler le chat jusqu'en bas.
  192. function scrollChat(){
  193. $('#chatContent').stop().animate({
  194. scrollTop: $('#chatContent')[0].scrollHeight
  195. }, 800);
  196. $newMessageAlert.stop().fadeOut(500);
  197. }
  198.  
  199. var colorTagStyle = $('<style id="colorTagStyle">').appendTo("head"); //Utilisation d'une règle CSS car objets créés dynamiquement.
  200.  
  201. function chatChangeColor(id) {
  202. var persoName = GM_getValue("dcce_name_" + id);
  203. var colorRule = GM_getValue("dcce_ctb_" + id);
  204. if (colorRule === undefined) colorRule = DEFAULT_CHAT_COLOR;
  205.  
  206. var newRule = '.c' + persoName + '{color: '+ colorRule +';}\n';
  207. colorTagStyle.text(colorTagStyle.text() + newRule);
  208.  
  209. }
  210.  
  211. function initChatColor() {
  212. var localValues = GM_listValues();
  213. for(var i = 0; i < localValues.length; i++) {
  214. if(localValues[i].includes("dcce_ctb_")) {
  215. chatChangeColor(localValues[i].slice(9));
  216. }
  217. }
  218. }
  219. initChatColor();
  220.  
  221. var chatCouleur5Important = $('<style id="chatCouleur5Important">.couleur5 span.link.linkable{color: #999 !important;}</style>').appendTo("head"); //Forcer la couleur grise sur les messages chuchotés.
  222.  
  223. //**********************************************
  224. //INTERFACE DE CONFIGURATION UTILISATEUR
  225. //**********************************************
  226. var $databox = $('#zone_dataBox');
  227. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  228. //Constructeur de fenêtre de configuration
  229. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  230. var DCCE_ConfigurationWindow = function () {
  231. var window_width = '560px';
  232. var window_height = '450px';
  233. var $config_window = $('<div id="dcce_configwindow" onclick="engine.switchDataBox(this)"/>');
  234. $config_window.draggable();
  235. $config_window.addClass('dataBox focused ui-draggable');
  236. $config_window.css({
  237. width: window_width,
  238. "margin-left": '-185px',
  239. display: 'block',
  240. position: 'absolute',
  241. "z-index": '2',
  242. });
  243. for (var i = 1; i <= 8; i++) {
  244. $('<div class="dbfond' + i + '" />').appendTo($config_window);
  245. }
  246. var $config_head = $('<div class="head ui-draggable-handle" ondblclick="$(\'#dcce_configwindow\').toggleClass(\'reduced\');" />').appendTo($config_window);
  247. $('<div title="Fermer la fenêtre (Q)" class="info1 link close" onclick="engine.closeDataBox($(this).parent().parent().attr(\'id\'));">X</div>').appendTo($config_head);
  248. $('<div title="Reduire/Agrandir la fenêtre" class="info1 link reduce" onclick="$(\'#dcce_configwindow\').toggleClass(\'reduced\');">-</div>').appendTo($config_head);
  249. $('<div class="title">Configuration DC Enhanced Chat</div>').appendTo($config_head);
  250. $('<div class="dbloader" />').appendTo($config_window);
  251. var $config_content = $('<div class="content" style="height:' + window_height + '; overflow: auto"/>').appendTo($config_window);
  252. //----------------------------------------
  253. //Widgets internes
  254. //----------------------------------------
  255. var $config_interface = $('<div />').appendTo($config_content);
  256. $config_interface.css({
  257. "margin-left": '3px',
  258. "font-variant": 'small-caps',
  259. color: '#fff',
  260. height: '100%',
  261. width: '98%',
  262. });
  263. //----------------------------------------
  264. //Configuration du défilement, auto-scroll
  265. //----------------------------------------
  266. var $autoconfig = $('<div />').appendTo($config_interface);
  267. var $autoconfig_title = $('<h2 class="couleur4 configTitre" />').appendTo($autoconfig);
  268. $autoconfig_title.text('Options de défilement du texte');
  269. $autoconfig_title.css({
  270. "margin-bottom": '5px',
  271. "border-bottom": '1px solid',
  272. display: 'block',
  273. "font-size": '17px',
  274. "-webkit-margin-before": '0.83em',
  275. "-webkit-margin-after": '0.83em',
  276. "-webkit-margin-start": '0px',
  277. "-webkit-margin-end": '0px',
  278. "font-weight": 'bold',
  279. position: 'relative',
  280. });
  281. var $autoconfig_container = $('<div class="ligne"/>').appendTo($config_interface);
  282. $autoconfig_container.text('Défilement automatique : ');
  283. $autoconfig_container.css({
  284. display: 'inline-block',
  285. "margin-bottom": '15px',
  286. "margin-left": '5px'
  287. });
  288. var $autoconfig_radio_activate = $('<input type="radio" name="typeAutoRadio" value="false">Activer</input>').appendTo($autoconfig_container);
  289. $autoconfig_radio_activate.css({
  290. margin: '0 5px',
  291. });
  292. $autoconfig_radio_activate.attr('checked', autoScroll);
  293. $autoconfig_radio_activate.change(function(){
  294. autoScroll = true;
  295. GM_setValue("DCCE_autoScroll", autoScroll);
  296. $("#toggleAutoScroll").text("AS on");
  297. });
  298. var $autoconfig_radio_deactivate = $('<input type="radio" name="typeAutoRadio" value="true">Désactiver</input>').appendTo($autoconfig_container);
  299. $autoconfig_radio_deactivate.css({
  300. margin: '0px 5px 0 25px',
  301. "padding-left": '20px',
  302. });
  303. $autoconfig_radio_deactivate.attr('checked', !autoScroll);
  304. $autoconfig_radio_deactivate.change(function(){
  305. autoScroll = false;
  306. GM_setValue("DCCE_autoScroll", autoScroll);
  307. $("#toggleAutoScroll").text("AS off");
  308. });
  309. //----------------------------------------
  310. //Configuration de l'affichage de la barre de défilement
  311. //----------------------------------------
  312. var $scrconfig_container = $('<div class="ligne"/>').appendTo($config_interface);
  313. $scrconfig_container.text('Barre de défilement : ');
  314. $scrconfig_container.css({
  315. display: 'inline-block',
  316. "margin-bottom": '15px',
  317. "margin-left": '5px'
  318. });
  319. var $scrconfig_radio_activate = $('<input type="radio" name="typeScrRadio" value="false">Afficher</input>').appendTo($scrconfig_container);
  320. $scrconfig_radio_activate.css({
  321. margin: '0 5px',
  322. });
  323. $scrconfig_radio_activate.attr('checked', scrollBar);
  324. $scrconfig_radio_activate.change(function(){
  325. scrollBar = true;
  326. GM_setValue("DCCE_scrollBar", scrollBar);
  327. setChatContentScroll();
  328. });
  329. var $scrconfig_radio_deactivate = $('<input type="radio" name="typeScrRadio" value="true">Masquer</input>').appendTo($scrconfig_container);
  330. $scrconfig_radio_deactivate.css({
  331. margin: '0px 5px 0 25px',
  332. "padding-left": '20px',
  333. });
  334. $scrconfig_radio_deactivate.attr('checked', !scrollBar);
  335. $scrconfig_radio_deactivate.change(function(){
  336. scrollBar = false;
  337. GM_setValue("DCCE_scrollBar", scrollBar);
  338. setChatContentScroll();
  339. });
  340. //----------------------------------------
  341. //Configuration de l'affichage de la barre de défilement
  342. //----------------------------------------
  343. var $predconfig_container = $('<div class="ligne"/>').appendTo($config_interface);
  344. $predconfig_container.text('Défiler le chat à l\'écriture : ');
  345. $predconfig_container.css({
  346. display: 'inline-block',
  347. "margin-bottom": '15px',
  348. "margin-left": '5px'
  349. });
  350. var $predconfig_radio_activate = $('<input type="radio" name="typePredRadio" value="false">Oui</input>').appendTo($predconfig_container);
  351. $predconfig_radio_activate.css({
  352. margin: '0 5px',
  353. });
  354. $predconfig_radio_activate.attr('checked', typePredict);
  355. $predconfig_radio_activate.change(function(){
  356. typePredict = true;
  357. GM_setValue("DCCE_typePredict", typePredict);
  358. });
  359. var $predconfig_radio_deactivate = $('<input type="radio" name="typePredRadio" value="true">Non</input>').appendTo($predconfig_container);
  360. $predconfig_radio_deactivate.css({
  361. margin: '0px 5px 0 25px',
  362. "padding-left": '20px',
  363. });
  364. $predconfig_radio_deactivate.attr('checked', !typePredict);
  365. $predconfig_radio_deactivate.change(function(){
  366. typePredict = false;
  367. GM_setValue("DCCE_typePredict", typePredict);
  368. });
  369.  
  370. //----------------------------------------
  371. //Configuration de l'audio joué avec AlertChat
  372. //----------------------------------------
  373. var $audioconfig_container = $('<div class="ligne"/>').appendTo($config_interface);
  374. $audioconfig_container.text('');
  375. $audioconfig_container.css({
  376. display: 'inline-block',
  377. "margin-bottom": '15px',
  378. });
  379. var $audioconfig_pzonechat = $('<div> </div><div>Audio joué à la réception d\'un message (indiquer URL de l\'audio) : </div>').appendTo($audioconfig_container);
  380. $audioconfig_pzonechat.css({
  381. margin: '0 5px',
  382. width: '500px'
  383. });
  384. var $audioconfig_zonechat = $('<input type="url" name="typealertchat" value="' + alertChatAudioURL + '" style="background-color: antiquewhite;"></input>').appendTo($audioconfig_container);
  385. $audioconfig_zonechat.css({
  386. margin: '0 5px',
  387. width: '500px'
  388. });
  389. $audioconfig_zonechat.keyup(function(){
  390. alertChatAudioURL = $(this).val();
  391. if(alertChatAudioURL === "") {
  392. GM_setValue("DCCE_alertChatAudioURL", DEFAULT_ALERT_CHAT_AUDIO_URL);
  393. $('#checkchat').attr('src', DEFAULT_ALERT_CHAT_AUDIO_URL);
  394. } else {
  395. GM_setValue("DCCE_alertChatAudioURL", alertChatAudioURL);
  396. $('#checkchat').attr('src', alertChatAudioURL);
  397. }
  398. });
  399. var $audioconfig_vol = $('<input type="range" name="typealertvolume" value="' + alertVolume + '" min="0" max="1" step="0.01"></input>').appendTo($audioconfig_container);
  400. $audioconfig_vol.css({
  401. margin: '0 5px',
  402. width: '500px'
  403. });
  404. $audioconfig_vol.change(function(){
  405. alertVolume = Number($audioconfig_vol.val());
  406. GM_setValue("DCCE_alertVolume", alertVolume);
  407. document.getElementById('checkchat').volume = (activateAlertChat) ? alertVolume : 0;
  408. });
  409.  
  410.  
  411. this.$window = $config_window;
  412.  
  413. //----------------------------------------
  414. //Configuration de la largeur du chat
  415. //----------------------------------------
  416. /*var $xtdconfig = $('<div />').appendTo($config_interface);
  417. var $xtdconfig_title = $('<h2 class="couleur4 configTitre" />').appendTo($xtdconfig);
  418. $xtdconfig_title.text('Largeur du chat');
  419. $xtdconfig_title.css({
  420. "margin-bottom": '5px',
  421. "border-bottom": '1px solid',
  422. display: 'block',
  423. "font-size": '17px',
  424. "-webkit-margin-before": '0.83em',
  425. "-webkit-margin-after": '0.83em',
  426. "-webkit-margin-start": '0px',
  427. "-webkit-margin-end": '0px',
  428. "font-weight": 'bold',
  429. position: 'relative',
  430. });
  431. var $xtdconfig_container = $('<div class="ligne"/>').appendTo($config_interface);
  432. //$xtdconfig_container.text('Défilement automatique : ');
  433. $xtdconfig_container.css({
  434. display: 'inline-block',
  435. "margin-bottom": '15px',
  436. });
  437. var $xtdconfig_range = $('<input type="range" name="typeXtdRange" value="' + chatExtend + '" min="0" max="300" step="1"></input>').appendTo($xtdconfig_container);
  438. $xtdconfig_range.css({
  439. margin: '0 5px',
  440. width: '500px'
  441. });
  442. $xtdconfig_range.change(function(){
  443. chatExtend = Number($xtdconfig_range.val());
  444. GM_setValue("DCCE_chatExtend", chatExtend);
  445. setChatCSS();
  446. });
  447.  
  448. //----------------------------------------
  449. //Configuration des fonds de zone droite/chat customs
  450. //----------------------------------------
  451. var $bgconfig = $('<div />').appendTo($config_interface);
  452. var $bgconfig_title = $('<h2 class="couleur4 configTitre" />').appendTo($bgconfig);
  453. $bgconfig_title.text('Fonds de zone customisés (pour réinitialiser, effacer la ligne)');
  454. $bgconfig_title.css({
  455. "margin-bottom": '5px',
  456. "border-bottom": '1px solid',
  457. display: 'block',
  458. "font-size": '17px',
  459. "-webkit-margin-before": '0.83em',
  460. "-webkit-margin-after": '0.83em',
  461. "-webkit-margin-start": '0px',
  462. "-webkit-margin-end": '0px',
  463. "font-weight": 'bold',
  464. position: 'relative',
  465. });
  466. var $bgconfig_container = $('<div class="ligne"/>').appendTo($config_interface);
  467. $bgconfig_container.css({
  468. display: 'inline-block',
  469. "margin-bottom": '15px',
  470. });
  471. var $bgconfig_pzonedroite = $('<div>Fond messagerie (indiquer URL de l\'image) :</div>').appendTo($bgconfig_container);
  472. $bgconfig_pzonedroite.css({
  473. margin: '0 5px',
  474. width: '500px'
  475. });
  476. var $bgconfig_zonedroite = $('<input type="url" name="typeBGzonedroite" value="' + scriptZoneDroiteBG + '" style="background-color: antiquewhite;"></input>').appendTo($bgconfig_container);
  477. $bgconfig_zonedroite.css({
  478. margin: '0 5px',
  479. width: '500px'
  480. });
  481. $bgconfig_zonedroite.keyup(function(){
  482. if($(this).val() === DEFAULT_SCRIPT_ZONE_DROITE_BG || $(this).val() === "") {
  483. GM_deleteValue("DCCE_scriptZoneDroiteBG");
  484. scriptZoneDroiteBG = DEFAULT_SCRIPT_ZONE_DROITE_BG;
  485. } else {
  486. scriptZoneDroiteBG = $(this).val();
  487. GM_setValue("DCCE_scriptZoneDroiteBG", scriptZoneDroiteBG);
  488. }
  489. setZoneChatBackground();
  490. });
  491. var $bgconfig_pzonechat = $('<div> </div><div>Fond chat (indiquer URL de l\'image) :</div>').appendTo($bgconfig_container);
  492. $bgconfig_pzonechat.css({
  493. margin: '0 5px',
  494. width: '500px'
  495. });
  496. var $bgconfig_zonechat = $('<input type="url" name="typeBGzonechat" value="' + scriptZoneChatBG + '" style="background-color: antiquewhite;"></input>').appendTo($bgconfig_container);
  497. $bgconfig_zonechat.css({
  498. margin: '0 5px',
  499. width: '500px'
  500. });
  501. $bgconfig_zonechat.keyup(function(){
  502. if($(this).val() === DEFAULT_SCRIPT_ZONE_CHAT_BG || $(this).val() === "") {
  503. GM_deleteValue("DCCE_scriptZoneChatBG");
  504. scriptZoneChatBG = DEFAULT_SCRIPT_ZONE_CHAT_BG;
  505. } else {
  506. scriptZoneChatBG = $(this).val();
  507. GM_setValue("DCCE_scriptZoneChatBG", scriptZoneChatBG);
  508. }
  509. setZoneChatBackground();
  510. });*/
  511.  
  512. //----------------------------------------
  513. //Configuration des couleurs de pseudos dans le chat
  514. //----------------------------------------
  515. var $clrconfig = $('<div />').appendTo($config_interface);
  516. var $clrconfig_title = $('<h2 class="couleur4 configTitre" />').appendTo($clrconfig);
  517. $clrconfig_title.text('Gestion des couleurs de pseudos');
  518. $clrconfig_title.css({
  519. "margin-bottom": '5px',
  520. "border-bottom": '1px solid',
  521. display: 'block',
  522. "font-size": '17px',
  523. "-webkit-margin-before": '0.83em',
  524. "-webkit-margin-after": '0.83em',
  525. "-webkit-margin-start": '0px',
  526. "-webkit-margin-end": '0px',
  527. "font-weight": 'bold',
  528. position: 'relative',
  529. });
  530. var $useritems_table = $('<table id="dcce_colorItems_config"/>').appendTo($clrconfig);
  531. $useritems_table.css({
  532. width: '100%',
  533. border: 'solid 1px white',
  534. margin: '5px 0',
  535. "font-size": '15px',
  536. });
  537. //Ligne d'en-têtes
  538. $useritems_table.append($('<thead><tr><th>Personnage</th><th>Couleur</th><th></th></tr></thead>'));
  539. var $useritems_tbody = $('<tbody />').appendTo($useritems_table);
  540. var localValues = GM_listValues();
  541. for (let j = 0; j < localValues.length; j++) {
  542. if(localValues[j].includes("dcce_ctb_")) {
  543. var type_id = localValues[j];
  544. var $row = $('<tr />').appendTo($useritems_tbody);
  545. $row.addClass("loaded_item");
  546. $row.attr('id', type_id);
  547. var item_perso = GM_getValue("dcce_name_" + localValues[j].slice(9));
  548. var $perso_td = $('<td class="perso_td" style="text-align:left;width:60%;font-size: 20px;padding-left: 5px;">' + item_perso + '</td>').appendTo($row);
  549. var item_couleur = '<input class="dcce_colortagbox" type="color" id="' + localValues[j] + '" value="' + GM_getValue(localValues[j]) + '"/>';
  550. var $couleur_td = $('<td class="couleur_td" style="/*padding-left:10px;*/width:20%;text-align:center">' + item_couleur + '</td>').appendTo($row);
  551. $couleur_td.data('type_ID', type_id);
  552. //Ajout d'un bouton pour la suppression
  553. var $last_td = $('<td style="width:20%"/>').appendTo($row);
  554. var $itemdel_btn = $('<div class="btnTxt" />').appendTo($last_td);
  555. $itemdel_btn.data('type_ID', type_id);
  556. $itemdel_btn.text('Reset');
  557. $itemdel_btn.css({
  558. height: '15px',
  559. margin: '5px 15px',
  560. });
  561. //Handler clic sur le bouton "Supprimer" d'une ligne du tableau
  562. $itemdel_btn.click(function () {
  563. if ($(this).data('confirmed')) {
  564. //Suppression des valeurs de la ligne
  565. var type_id = $(this).data('type_ID');
  566. GM_deleteValue("dcce_ctb_" + type_id.slice(9));
  567. chatChangeColor(type_id);
  568. $(this).parent().parent().children().children("input").val(DEFAULT_CHAT_COLOR); //Reset du color picker
  569. //Remise à zéro du bouton
  570. $(this).text('Reset');
  571. $(this).data('confirmed', false);
  572. } else {
  573. //Besoin d'un second clic, pour confirmation
  574. $(this).text('Confirmer');
  575. $(this).data('confirmed', true);
  576. }
  577. });
  578. $itemdel_btn.mouseleave(function () {
  579. //Annulation de la confirmation de suppression
  580. $(this).text('Reset');
  581. $(this).data('confirmed', false);
  582. });
  583. $couleur_td.children("input").change(function() {
  584. GM_setValue($couleur_td.data('type_ID'), $(this).val());
  585. chatChangeColor($couleur_td.data('type_ID').slice(9));
  586. });
  587. }
  588. }
  589.  
  590. //Css des éléments du tableau
  591. $useritems_table.find('td').css({
  592. border: '1px solid white',
  593. height: '15px'
  594. });
  595.  
  596.  
  597. //----------------------------------------
  598. //Configuration de MatriceRP
  599. //----------------------------------------
  600. var $mrpconfig = $('<div />').appendTo($config_interface);
  601. var $mrpconfig_title = $('<h2 class="couleur4 configTitre" />').appendTo($clrconfig);
  602. $mrpconfig_title.text('Gestion des commandes');
  603. $mrpconfig_title.css({
  604. "margin-bottom": '5px',
  605. "border-bottom": '1px solid',
  606. display: 'block',
  607. "font-size": '17px',
  608. "-webkit-margin-before": '0.83em',
  609. "-webkit-margin-after": '0.83em',
  610. "-webkit-margin-start": '0px',
  611. "-webkit-margin-end": '0px',
  612. "font-weight": 'bold',
  613. position: 'relative',
  614. });
  615. var $commands_table = $('<table id="dcce_commands_config"/>').appendTo($clrconfig);
  616. $commands_table.css({
  617. width: '100%',
  618. border: 'solid 1px white',
  619. margin: '5px 0',
  620. "font-size": '15px',
  621. });
  622.  
  623.  
  624.  
  625. //Ligne d'en-têtes
  626. $commands_table.append($('<thead><tr><th>Alias</th><th>Nom</th><th>Couleur</th><th>Gras</th><th>Action</th></tr></thead>'));
  627. var $commands_tbody = $('<tbody />').appendTo($commands_table);
  628. var cmdTotal = 0;
  629.  
  630. function updateCommand(id) {
  631. //console.log("Update on line: " + id);
  632. mrpCommands[id].alias = $("#mrp_alias_input_" + id).val();
  633. mrpCommands[id].name = $("#mrp_name_input_" + id).val();
  634. mrpCommands[id].color = $("#mrp_color_input_" + id).val();
  635. mrpCommands[id].bold = $("#mrp_bold_input_" + id).attr("checked") == "checked" ? true : false;
  636. mrpCommands[id].rp = $("#mrp_rp_input_" + id).attr("checked") == "checked" ? true : false;
  637. //console.log(mrpCommands[id]);
  638. GM_setValue("DCCE_MRP", JSON.stringify(mrpCommands));
  639. }
  640.  
  641. //Fonction pour générer une ligne au tableau
  642. //cmd {alias:"str", name:"str", color:"#008000", bold:false, rp:true}
  643. function drawCommand(cmd, id) {
  644. let $row = $('<tr id="cmd_row_' + id + '"/>').appendTo($commands_tbody);
  645. $row.addClass("loaded_item");
  646.  
  647. let $alias_td = $('<td class="alias_td" style="text-align:left;font-size: 20px;padding-left: 5px;"><input style="background-color: antiquewhite" type="text" id="mrp_alias_input_' + id + '" value="' + cmd.alias + '"/></td>').appendTo($row);
  648. let $name_td = $('<td class="name_td" style="text-align:left;font-size: 20px;padding-left: 5px;"><input style="background-color: antiquewhite" type="text" id="mrp_name_input_' + id + '" value="' + cmd.name + '"/></td>').appendTo($row);
  649. let $color_td = $('<td class="color_td" style="text-align:center;font-size: 20px;"><input type="color" id="mrp_color_input_' + id + '" value="' + cmd.color + '"/></td>').appendTo($row);
  650. let $bold_td = $('<td class="bold_td" style="text-align:center;font-size: 20px;"><input type="checkbox" id="mrp_bold_input_' + id + '"' + (cmd.bold ? ' checked' : '') + '/></td>').appendTo($row);
  651. let $rp_td = $('<td class="rp_td" style="text-align:center;font-size: 20px;"><input type="checkbox" id="mrp_rp_input_' + id + '"' + (cmd.rp ? ' checked' : '') + '/></td>').appendTo($row);
  652.  
  653. $alias_td.children("input").keyup(function(){updateCommand(id)});
  654. $name_td.children("input").keyup(function(){updateCommand(id)});
  655. $color_td.children("input").change(function(){updateCommand(id)});
  656. $bold_td.children("input").change(function(){updateCommand(id)});
  657. $rp_td.children("input").change(function(){updateCommand(id)});
  658. }
  659.  
  660. for (let j = 0; j < mrpCommands.length; j++) {
  661. $commands_tbody.append(drawCommand(mrpCommands[j], j));
  662. }
  663.  
  664. var $mrp_container = $('<div style="text-align: center"></div>').appendTo($clrconfig);
  665. var $mrp_remove = $('<input style="color: red; background-color: antiquewhite; width: 45%; margin: 5px" type="button" id="mrp_remove" value="Supprimer une ligne" />').click(function(){
  666. if (mrpCommands.length > 3) {
  667. mrpCommands.pop();
  668. GM_setValue("DCCE_MRP", JSON.stringify(mrpCommands));
  669. $("#cmd_row_" + mrpCommands.length).remove();
  670. }
  671. }).appendTo($mrp_container);
  672.  
  673. var $mrp_add = $('<input style="color: green; background-color: antiquewhite; width: 45%; margin: 5px" type="button" id="mrp_add" value="Ajouter une ligne" />').click(function(){
  674. drawCommand({alias:"", name:"", color:"#FFFFFF", bold:false, rp:false}, mrpCommands.length);
  675. stylizeTableCells();
  676. mrpCommands.push({alias:"", name:"", color:"#FFFFFF", bold:false, rp:false});
  677. GM_setValue("DCCE_MRP", JSON.stringify(mrpCommands));
  678. }).appendTo($mrp_container);
  679.  
  680. //Css des éléments du tableau
  681. function stylizeTableCells() {
  682. $commands_table.find('td').css({
  683. border: '1px solid white',
  684. height: '15px'
  685. });
  686. }
  687. stylizeTableCells();
  688. }
  689. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  690. //FIN Constructeur de fenêtre de configuration
  691. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  692.  
  693.  
  694. //---------------------------------------------------
  695. //Ajout d'un item au menu bandeau "Paramètres" de DC
  696. //---------------------------------------------------
  697. var $params_menu = $('.menus > .parametres > ul');
  698. var $dcce_config = $('<li />').appendTo($params_menu);
  699. $dcce_config.text("Configuration du Chat");
  700. $dcce_config.addClass('link couleur2 separator');
  701.  
  702. $dcce_config.click(function () {
  703. //Fermeture des autres instances de paramétrage ouvertes
  704. engine.closeDataBox('dcce_configwindow');
  705. var $config_window = new DCCE_ConfigurationWindow();
  706. $databox.append($config_window.$window);
  707. });
  708.  
  709. //**********************************************
  710. // FIN INTERFACE DE CONFIGURATION UTILISATEUR
  711. //**********************************************
  712.  
  713. //**********************************************
  714. // DEBUT MAIN
  715. //**********************************************
  716.  
  717. //Compte les charactères façon DreadCast: 7 bits = 1 char, 8-11 bits = 2 chars, 12-16 bits = 3 chars
  718. function chatCharCount(str) {
  719. if (!str) return 0;
  720. return str.split("").map(a => a.charCodeAt(0).toString(2).length >= 12 ? 3 : a.charCodeAt(0).toString(2).length >= 8 ? 2 : 1).reduce((a, b) => a + b);
  721. }
  722.  
  723. //ALERTCHAT, Script d'Odul
  724. (function() {
  725. var imgUnmute = 'url(https://i.imgur.com/uvIB44X.png)';
  726. var imgMute = 'url(https://i.imgur.com/8oV9IrJ.png)';
  727.  
  728. var audio = document.createElement('audio');
  729. audio.id='checkchat';
  730. document.body.appendChild(audio);
  731. $('#checkchat').attr('src', alertChatAudioURL);
  732. $("#checkchat").css("display","none");
  733.  
  734. $('<li class="separator"></li>').prependTo($('#bandeau ul.menus'));
  735. var End = $('<li>').prependTo($('#bandeau ul.menus'));
  736. End.attr("id", 'endAudiocheckchat');
  737. End.css({
  738. left: '5px',
  739. height: '30px',
  740. "z-index": '999999',
  741. "background-size": '29px 15px',
  742. "background-repeat": 'no-repeat',
  743. "background-position-y": '4px',
  744. color: '#999'
  745. });
  746. End.text("AC").addClass('link');
  747. End.hover(
  748. function(){
  749. $(this).css("color", "#0073d5");
  750. },
  751. function(){
  752. var colorAC = (activateAlertChat) ? "#999" : "#D00000";
  753. $(this).css("color", colorAC);
  754. }
  755. );
  756. End.click(function() {
  757. activateAlertChat = (activateAlertChat) ? false : true;
  758. GM_setValue("DCCE_activateAlertChat", activateAlertChat);
  759. document.getElementById('endAudiocheckchat').style.backgroundImage = (activateAlertChat) ? imgUnmute : imgMute;
  760. document.getElementById('checkchat').volume = (activateAlertChat) ? alertVolume : 0;
  761. var colorAC = (activateAlertChat) ? "#999" : "#D00000";
  762. End.css("color", colorAC);
  763. });
  764.  
  765. //Initialisation depuis le stockage local
  766. document.getElementById('endAudiocheckchat').style.backgroundImage = (activateAlertChat) ? imgUnmute : imgMute;
  767. document.getElementById('checkchat').volume = (activateAlertChat) ? alertVolume : 0;
  768. var colorAC = (activateAlertChat) ? "#999" : "#D00000";
  769. End.css("color", colorAC);
  770. })();
  771.  
  772.  
  773.  
  774. //MatriceRP
  775. //Par Isilin
  776.  
  777. const FORBIDDEN_ALIASES = ["me", "y", "ye", "yme", "w", "we", "wme", "roll", ""];
  778.  
  779. function tagMessage(inputStr) {
  780.  
  781. let message = inputStr;
  782.  
  783. let aliasUsed = inputStr.split(" ")[0].substr(1);
  784.  
  785. if (message[0] !== "/") return message; //Vérifier avant tout que l'utilisateur veut rentrer une commande...
  786.  
  787. if (FORBIDDEN_ALIASES.indexOf(aliasUsed) > -1) return message; //On ne modifie pas le message si l'alias utilisé est une commande du jeu ou un alias invalide
  788.  
  789. let command = mrpCommands.find(cmd => cmd.alias.toLowerCase() === aliasUsed.toLowerCase()); //On récupère les paramètres de la commande à partir de son alias (vérification non sensible à la casse)
  790.  
  791. if (command === undefined) return message; //On ne modifie pas le message si l'alias utilisé n'est pas défini
  792.  
  793. if (message.length <= command.alias.length + 2) return ""; //On vide le message si un alias est utilisé seul ou avec un espace sans texte
  794.  
  795. message = (command.rp ? "/me " : "")
  796. //+ "[b][c=" + command.color.substr(1) + "]{" + command.name + "}[/c][/b]"
  797. + "[b]{" + command.name + "}[/b]"
  798. + (command.bold ? "[b]" : "")
  799. + "[c=" + command.color.substr(1) + "]" + message.substr(command.alias.length + 1) + "[/c]"
  800. + (command.bold ? "[/b]" : "");
  801.  
  802. return message;
  803. }
  804.  
  805.  
  806.  
  807. //AmeliorationTchat2.0
  808. //Par Odul
  809. var $chatInput = $("#chatForm .text_chat");
  810.  
  811. function beautifyMessage(inputStr) {
  812.  
  813. let message = inputStr;
  814.  
  815. if (/^\/me/i.test(message)) {
  816. message = "/me" + message.substr(3); //Transforme /Me en /me pour que la casse soit respectée et que le chat ressorte bien une emote.
  817. message = message.replace(/"([^\"]+)"/gi, "[c=FFFFFF]$1[/c]");
  818. } else {
  819. message = message.replace(/\*([^\*]+)\*/gi, "[c=58DCF9][i]$1[/i][/c]");
  820. }
  821. return message;
  822. }
  823.  
  824. //Override honteux du code de base de DC
  825. MenuChat.prototype.send = function() {
  826. if (nav.getChat().kw("chatForm")) {
  827. if ("" == $("#chatForm input.text_chat").val())
  828. return !1;
  829. this.checkConversation();
  830. if ($("#chatForm input.text_chat").val().split("").map(a => a.charCodeAt(0).toString(2).length >= 12 ? 3 : a.charCodeAt(0).toString(2).length >= 8 ? 2 : 1).reduce((a, b) => a + b) >= (0 == this.currentMode ? 199 : 195)) return !1; //La seule chose ajoutée par l'override: refuser d'envoyer le message si trop long! :)
  831. 1 == this.currentMode ? $("#chatForm input.text_chat").val("/we " + $("#chatForm input.text_chat").val()) : 2 == this.currentMode && $("#chatForm input.text_chat").val("/ye " + $("#chatForm input.text_chat").val());
  832. engine.submitForm("Menu/Chat/default=Send&etat=2&room=" + this.getRoom(!0), "chatForm", this.update, !0),
  833. 6 == evolution.currentPoint && evolution.unlock(3)
  834. }
  835. }
  836.  
  837.  
  838. //Applique les scripts AmeliorationTchat2.0 et MatriceRP au moment de poster le message
  839. var isMessageLocked = false;
  840. function ameliorInput() {
  841. if (!isMessageLocked) {
  842. isMessageLocked = true;
  843.  
  844. let ogMessage = $chatInput.val(); //Message avant modifications
  845. let finalMessage = tagMessage(beautifyMessage(ogMessage)); //Message balisé, prêt à envoyer
  846. $chatInput.val(finalMessage);
  847.  
  848. //Si le message était trop long pour être envoyé, on attend le refus de la fonction overridée, puis on débalise le message
  849. let ml = $("#chatForm > .text_mode").text() == "N" ? 199 : 195;
  850. if (chatCharCount(finalMessage) >= ml) {
  851. setTimeout(function(){
  852. $chatInput.val(ogMessage);
  853. isMessageLocked = false;
  854. }, 2);
  855. } else {
  856. setTimeout(function(){ isMessageLocked = false; }, 2);
  857. }
  858. }
  859. }
  860.  
  861. function verifyKeyPressed(e) {
  862. if (e.keyCode==13) {
  863. ameliorInput();
  864. }
  865. }
  866.  
  867. $("#chatForm .text_chat").keypress(verifyKeyPressed);
  868. $("#chatForm .text_valider").click(ameliorInput);
  869.  
  870.  
  871. //HIGHLIGHT CHAT LIMIT
  872. //Code de Ladoria, modifications de débugging et implémentation au script.
  873. function HighlightChatLimit() {
  874.  
  875. var limitColor = 'red', //Couleurs pour chaque pallier de longueur
  876. alertColor = 'orange',
  877. warningColor = 'yellow',
  878. limitLength = 199, //Palliers de longueur
  879. alertLength = 170,
  880. warningLength = 135;
  881.  
  882. var c1 = $("#chatForm").css('border-color'); //CSS original de la box
  883. var c2 = $("#chatForm .text_mode").css('border-color');
  884. var c3 = $("#chatForm .text_valider").css('background-color');
  885. var c4 = $("#chatForm").css('box-shadow');
  886.  
  887. var animateChatInput = function(e) {
  888. var processedInput = tagMessage(beautifyMessage($("#chatForm .text_chat").val()));
  889. var len = chatCharCount(processedInput);
  890. let maxLength = $("#chatForm > .text_mode").text() == "N" ? 199 : 195; //Longueur max = 199, sauf si le chat est en mode chuchotement ou cri
  891. if (len >= maxLength) {
  892. highlight(limitColor); // limit reached
  893. $("#chatForm .text_chat").attr("maxlength", $("#chatForm .text_chat").val().length); //On bloque pour que le joueur arrête d'écrire
  894. }
  895. else if (len >= alertLength) {
  896. highlight(alertColor); // approach limit
  897. $("#chatForm .text_chat").attr("maxlength", maxLength);
  898. }
  899. else if (len >= warningLength) {
  900. highlight(warningColor); // first warning
  901. $("#chatForm .text_chat").attr("maxlength", maxLength);
  902. }
  903. else {
  904. originalHighlight(c1, c2, c3, c4); // far away from limit
  905. $("#chatForm .text_chat").attr("maxlength", maxLength);
  906. }
  907. };
  908.  
  909. function originalHighlight(formBorderColor, modeBorderColor, bgColor, bsSettings) {
  910. $("#chatForm").css('border-color', formBorderColor);
  911. $("#chatForm .text_mode").css('border-color', modeBorderColor);
  912. $("#chatForm .text_valider").css('background-color', bgColor);
  913.  
  914. $("#chatForm").css('box-shadow', bsSettings);
  915. }
  916.  
  917. function highlight(color) {
  918. originalHighlight(color, color, color, '0px 0px 3px 2px ' + color);
  919. }
  920.  
  921. $("#chatForm .text_chat").attr("maxlength", "199");
  922. $("#chatForm .text_chat").keyup(animateChatInput);
  923. $("#chatForm > .text_mode").click(animateChatInput);
  924.  
  925. }
  926. HighlightChatLimit(); //Exécution du script de limite de chat.
  927.  
  928.  
  929. //SCROLLING
  930. scrollChat(); //Place le chat au chargement du jeu.
  931. $newMessageAlert.click(scrollChat); //Scroll au clic du bouton d'alerte de nouveau message.
  932. $(".text_chat").keydown(function(key){ //Si en préférence, scroller le chat automatiquement quand on commence à écrire.
  933. if(typePredict && key != 13) scrollChat(); //Ne pas le faire avec la touche entrée car déjà fait quand la ligne apparaît dans le chat.
  934. });
  935. var lastChat = $('#chatContent').text(); //Sert à comparer pour voir si le chat a changé.
  936. setInterval(function(){ //Scrolle ou alerte à la réception d'un message.
  937. if(lastChat != $('#chatContent').text()) {
  938. lastChat = $('#chatContent').text(); //Actualiser la copie local du chat.
  939.  
  940. document.getElementById('checkchat').play();
  941.  
  942. if(autoScroll) {
  943. scrollChat();
  944. }
  945. else if($("#chatContent .link.linkable:last").text() !== $("#txt_pseudo").text()) {
  946. $newMessageAlert.stop().fadeIn(500); //Afficher uniquement le bouton si l'utilisateur ne vient pas de poster.
  947. }
  948. }
  949. }, 1000);
  950.  
  951. //COLOR TAG
  952. $(document).on("click", "span.perso.link", function(){
  953. var idPerso = $(this).attr('id').slice(9);
  954. $(document).one("ajaxSuccess", {idPerso: idPerso}, function(e){ //Permet d'attendre le chargement de la fenêtre, one() pour éviter un duplicata.
  955. var idctb = '#colorTagBox_' + e.data.idPerso;
  956. var colorTagBox = $('<div style="margin-top: 15px; text-align: center;">' + 'Couleur chat: ' +
  957. '<input type="color" id="' + idctb.slice(1) + '" value="' + DEFAULT_CHAT_COLOR + '"/>' +
  958. '<input type="button" id="' + idctb.slice(1) + '_reset" value="Reset" style="background-color: buttonface; margin-left: 5px; height: 16px; font-size: 12px;"/>' +
  959. '</div>').appendTo($("#ib_persoBox_" + e.data.idPerso + " #char_inspect_faketooltip .content"));
  960.  
  961. GM_setValue("dcce_name_" + e.data.idPerso, $("#ib_persoBox_" + e.data.idPerso + " .titreinfo").contents().filter(function(){
  962. return this.nodeType == 3;
  963. })[0].nodeValue); //Récupère le nom du personnage, utilisé dans le nommage de la classe du pseudo.
  964.  
  965. if(GM_getValue("dcce_ctb_" + e.data.idPerso) !== undefined) { //Récupère et applique au bouton couleur la couleur enregistrée
  966. $(idctb).val((GM_getValue("dcce_ctb_" + e.data.idPerso)));
  967. }
  968. $(idctb).on("change", {idPerso: e.data.idPerso}, function(e) { //Enregistre en mémoire la nouvelle couleur
  969. GM_setValue("dcce_ctb_" + e.data.idPerso, $(this).val());
  970. chatChangeColor(e.data.idPerso);
  971. });
  972. $(idctb + "_reset").on("click", {idPerso: e.data.idPerso}, function(e) { //Reset de la couleur
  973. GM_deleteValue("dcce_ctb_" + e.data.idPerso);
  974. $(idctb).val(DEFAULT_CHAT_COLOR);
  975. chatChangeColor(e.data.idPerso);
  976. });
  977. });
  978.  
  979. });
  980.  
  981. //OVERWRITE pour que seul DCCE gère le scroll du chat
  982. MenuChat.prototype.update = function(a) {
  983. if (!xml_result(a))
  984. return !1;
  985. if ($(a).find("cydive").length)
  986. return cydiving.readChat(a),
  987. !0;
  988. $(a).find("chat").each(function() {
  989. if ($(this).attr("key"))
  990. $("#" + $(this).attr("key")).html($(this).xml());
  991. else {
  992. var a = $.trim($(this).find("#chatContent").xml());
  993. if (a && ($("#zone_droite #zone_chat #chatContent, #chat_preview .chatContent").append(a),
  994. //$("#chatContent").scrollTop(jQuery("#chatContent").innerHeight()), //RETRAIT DE CETTE LIGNE
  995. Tutoriel.instance.tutoData.actif && !Tutoriel.instance.isTutoCompleted(Tutoriel.EVENT_CHAT) && $(this).find("span.link.linkable").length)) {
  996. var b = $(this).find("span.link.linkable").attr("alt");
  997. engine.getIdPersonnage() != b && $(window).trigger(Tutoriel.EVENT_CHAT)
  998. }
  999. }
  1000. }),
  1001. $(a).find("connectes").length && $("#zone_chat .connectes").html($(a).find("connectes").xml());
  1002. $("#zone_chat").height(),
  1003. $("#zone_chat .connectes").height(),
  1004. $("#zone_chat .chatForm").height(),
  1005. $("#zone_chat").height(),
  1006. $("#zone_chat .chatForm").height();
  1007. $(a).find("chat").attr("time") && nav.getChat().setTimeCurrentRoom($(a).find("chat").attr("time")),
  1008. $("#zone_chat .loader").hide()
  1009. }
  1010. });