Dreadcast Chat Enhancer

Améliore le chat de Dreadcast.

当前为 2020-03-12 提交的版本,查看 最新版本

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