Dreadcast Chat Enhancer

Améliore le chat de Dreadcast.

当前为 2020-02-19 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Dreadcast Chat Enhancer
  3. // @namespace https://greasyfork.org/scripts/21359-dreadcast-chat-enhancer/
  4. // @version 2.3.8
  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 = 'http://i.imgur.com/kPzRqS2.png';
  57. const DEFAULT_SCRIPT_ZONE_CHAT_BG = 'http://i.imgur.com/0J3wOK0.png';
  58.  
  59. const DEFAULT_ALERT_CHAT_AUDIO_URL = 'https://bacon-network.net/dreadcast/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. GM_setValue("DCCE_alertChatAudioURL", alertChatAudioURL);
  395. $('#checkchat').attr('src', alertChatAudioURL);
  396. });
  397. var $audioconfig_vol = $('<input type="range" name="typealertvolume" value="' + alertVolume + '" min="0" max="1" step="0.01"></input>').appendTo($audioconfig_container);
  398. $audioconfig_vol.css({
  399. margin: '0 5px',
  400. width: '500px'
  401. });
  402. $audioconfig_vol.change(function(){
  403. alertVolume = Number($audioconfig_vol.val());
  404. GM_setValue("DCCE_alertVolume", alertVolume);
  405. document.getElementById('checkchat').volume = (activateAlertChat) ? alertVolume : 0;
  406. });
  407.  
  408.  
  409. this.$window = $config_window;
  410.  
  411. //----------------------------------------
  412. //Configuration de la largeur du chat
  413. //----------------------------------------
  414. var $xtdconfig = $('<div />').appendTo($config_interface);
  415. var $xtdconfig_title = $('<h2 class="couleur4 configTitre" />').appendTo($xtdconfig);
  416. $xtdconfig_title.text('Largeur du chat');
  417. $xtdconfig_title.css({
  418. "margin-bottom": '5px',
  419. "border-bottom": '1px solid',
  420. display: 'block',
  421. "font-size": '17px',
  422. "-webkit-margin-before": '0.83em',
  423. "-webkit-margin-after": '0.83em',
  424. "-webkit-margin-start": '0px',
  425. "-webkit-margin-end": '0px',
  426. "font-weight": 'bold',
  427. position: 'relative',
  428. });
  429. var $xtdconfig_container = $('<div class="ligne"/>').appendTo($config_interface);
  430. //$xtdconfig_container.text('Défilement automatique : ');
  431. $xtdconfig_container.css({
  432. display: 'inline-block',
  433. "margin-bottom": '15px',
  434. });
  435. var $xtdconfig_range = $('<input type="range" name="typeXtdRange" value="' + chatExtend + '" min="0" max="300" step="1"></input>').appendTo($xtdconfig_container);
  436. $xtdconfig_range.css({
  437. margin: '0 5px',
  438. width: '500px'
  439. });
  440. $xtdconfig_range.change(function(){
  441. chatExtend = Number($xtdconfig_range.val());
  442. GM_setValue("DCCE_chatExtend", chatExtend);
  443. setChatCSS();
  444. });
  445.  
  446. //----------------------------------------
  447. //Configuration des fonds de zone droite/chat customs
  448. //----------------------------------------
  449. var $bgconfig = $('<div />').appendTo($config_interface);
  450. var $bgconfig_title = $('<h2 class="couleur4 configTitre" />').appendTo($bgconfig);
  451. $bgconfig_title.text('Fonds de zone customisés (pour réinitialiser, effacer la ligne)');
  452. $bgconfig_title.css({
  453. "margin-bottom": '5px',
  454. "border-bottom": '1px solid',
  455. display: 'block',
  456. "font-size": '17px',
  457. "-webkit-margin-before": '0.83em',
  458. "-webkit-margin-after": '0.83em',
  459. "-webkit-margin-start": '0px',
  460. "-webkit-margin-end": '0px',
  461. "font-weight": 'bold',
  462. position: 'relative',
  463. });
  464. var $bgconfig_container = $('<div class="ligne"/>').appendTo($config_interface);
  465. $bgconfig_container.css({
  466. display: 'inline-block',
  467. "margin-bottom": '15px',
  468. });
  469. var $bgconfig_pzonedroite = $('<div>Fond messagerie (indiquer URL de l\'image) :</div>').appendTo($bgconfig_container);
  470. $bgconfig_pzonedroite.css({
  471. margin: '0 5px',
  472. width: '500px'
  473. });
  474. var $bgconfig_zonedroite = $('<input type="url" name="typeBGzonedroite" value="' + scriptZoneDroiteBG + '" style="background-color: antiquewhite;"></input>').appendTo($bgconfig_container);
  475. $bgconfig_zonedroite.css({
  476. margin: '0 5px',
  477. width: '500px'
  478. });
  479. $bgconfig_zonedroite.keyup(function(){
  480. if($(this).val() === DEFAULT_SCRIPT_ZONE_DROITE_BG || $(this).val() === "") {
  481. GM_deleteValue("DCCE_scriptZoneDroiteBG");
  482. scriptZoneDroiteBG = DEFAULT_SCRIPT_ZONE_DROITE_BG;
  483. } else {
  484. scriptZoneDroiteBG = $(this).val();
  485. GM_setValue("DCCE_scriptZoneDroiteBG", scriptZoneDroiteBG);
  486. }
  487. setZoneChatBackground();
  488. });
  489. var $bgconfig_pzonechat = $('<div> </div><div>Fond chat (indiquer URL de l\'image) :</div>').appendTo($bgconfig_container);
  490. $bgconfig_pzonechat.css({
  491. margin: '0 5px',
  492. width: '500px'
  493. });
  494. var $bgconfig_zonechat = $('<input type="url" name="typeBGzonechat" value="' + scriptZoneChatBG + '" style="background-color: antiquewhite;"></input>').appendTo($bgconfig_container);
  495. $bgconfig_zonechat.css({
  496. margin: '0 5px',
  497. width: '500px'
  498. });
  499. $bgconfig_zonechat.keyup(function(){
  500. if($(this).val() === DEFAULT_SCRIPT_ZONE_CHAT_BG || $(this).val() === "") {
  501. GM_deleteValue("DCCE_scriptZoneChatBG");
  502. scriptZoneChatBG = DEFAULT_SCRIPT_ZONE_CHAT_BG;
  503. } else {
  504. scriptZoneChatBG = $(this).val();
  505. GM_setValue("DCCE_scriptZoneChatBG", scriptZoneChatBG);
  506. }
  507. setZoneChatBackground();
  508. });
  509.  
  510. //----------------------------------------
  511. //Configuration des couleurs de pseudos dans le chat
  512. //----------------------------------------
  513. var $clrconfig = $('<div />').appendTo($config_interface);
  514. var $clrconfig_title = $('<h2 class="couleur4 configTitre" />').appendTo($clrconfig);
  515. $clrconfig_title.text('Gestion des couleurs de pseudos');
  516. $clrconfig_title.css({
  517. "margin-bottom": '5px',
  518. "border-bottom": '1px solid',
  519. display: 'block',
  520. "font-size": '17px',
  521. "-webkit-margin-before": '0.83em',
  522. "-webkit-margin-after": '0.83em',
  523. "-webkit-margin-start": '0px',
  524. "-webkit-margin-end": '0px',
  525. "font-weight": 'bold',
  526. position: 'relative',
  527. });
  528. var $useritems_table = $('<table id="dcce_colorItems_config"/>').appendTo($clrconfig);
  529. $useritems_table.css({
  530. width: '100%',
  531. border: 'solid 1px white',
  532. margin: '5px 0',
  533. "font-size": '15px',
  534. });
  535. //Ligne d'en-têtes
  536. $useritems_table.append($('<thead><tr><th>Personnage</th><th>Couleur</th><th></th></tr></thead>'));
  537. var $useritems_tbody = $('<tbody />').appendTo($useritems_table);
  538. var localValues = GM_listValues();
  539. for (let j = 0; j < localValues.length; j++) {
  540. if(localValues[j].includes("dcce_ctb_")) {
  541. var type_id = localValues[j];
  542. var $row = $('<tr />').appendTo($useritems_tbody);
  543. $row.addClass("loaded_item");
  544. $row.attr('id', type_id);
  545. var item_perso = GM_getValue("dcce_name_" + localValues[j].slice(9));
  546. var $perso_td = $('<td class="perso_td" style="text-align:left;width:60%;font-size: 20px;padding-left: 5px;">' + item_perso + '</td>').appendTo($row);
  547. var item_couleur = '<input class="dcce_colortagbox" type="color" id="' + localValues[j] + '" value="' + GM_getValue(localValues[j]) + '"/>';
  548. var $couleur_td = $('<td class="couleur_td" style="/*padding-left:10px;*/width:20%;text-align:center">' + item_couleur + '</td>').appendTo($row);
  549. $couleur_td.data('type_ID', type_id);
  550. //Ajout d'un bouton pour la suppression
  551. var $last_td = $('<td style="width:20%"/>').appendTo($row);
  552. var $itemdel_btn = $('<div class="btnTxt" />').appendTo($last_td);
  553. $itemdel_btn.data('type_ID', type_id);
  554. $itemdel_btn.text('Reset');
  555. $itemdel_btn.css({
  556. height: '15px',
  557. margin: '5px 15px',
  558. });
  559. //Handler clic sur le bouton "Supprimer" d'une ligne du tableau
  560. $itemdel_btn.click(function () {
  561. if ($(this).data('confirmed')) {
  562. //Suppression des valeurs de la ligne
  563. var type_id = $(this).data('type_ID');
  564. GM_deleteValue("dcce_ctb_" + type_id.slice(9));
  565. chatChangeColor(type_id);
  566. $(this).parent().parent().children().children("input").val(DEFAULT_CHAT_COLOR); //Reset du color picker
  567. //Remise à zéro du bouton
  568. $(this).text('Reset');
  569. $(this).data('confirmed', false);
  570. } else {
  571. //Besoin d'un second clic, pour confirmation
  572. $(this).text('Confirmer');
  573. $(this).data('confirmed', true);
  574. }
  575. });
  576. $itemdel_btn.mouseleave(function () {
  577. //Annulation de la confirmation de suppression
  578. $(this).text('Reset');
  579. $(this).data('confirmed', false);
  580. });
  581. $couleur_td.children("input").change(function() {
  582. GM_setValue($couleur_td.data('type_ID'), $(this).val());
  583. chatChangeColor($couleur_td.data('type_ID').slice(9));
  584. });
  585. }
  586. }
  587.  
  588. //Css des éléments du tableau
  589. $useritems_table.find('td').css({
  590. border: '1px solid white',
  591. height: '15px'
  592. });
  593.  
  594.  
  595. //----------------------------------------
  596. //Configuration de MatriceRP
  597. //----------------------------------------
  598. var $mrpconfig = $('<div />').appendTo($config_interface);
  599. var $mrpconfig_title = $('<h2 class="couleur4 configTitre" />').appendTo($clrconfig);
  600. $mrpconfig_title.text('Gestion des commandes');
  601. $mrpconfig_title.css({
  602. "margin-bottom": '5px',
  603. "border-bottom": '1px solid',
  604. display: 'block',
  605. "font-size": '17px',
  606. "-webkit-margin-before": '0.83em',
  607. "-webkit-margin-after": '0.83em',
  608. "-webkit-margin-start": '0px',
  609. "-webkit-margin-end": '0px',
  610. "font-weight": 'bold',
  611. position: 'relative',
  612. });
  613. var $commands_table = $('<table id="dcce_commands_config"/>').appendTo($clrconfig);
  614. $commands_table.css({
  615. width: '100%',
  616. border: 'solid 1px white',
  617. margin: '5px 0',
  618. "font-size": '15px',
  619. });
  620.  
  621.  
  622.  
  623. //Ligne d'en-têtes
  624. $commands_table.append($('<thead><tr><th>Alias</th><th>Nom</th><th>Couleur</th><th>Gras</th><th>Action</th></tr></thead>'));
  625. var $commands_tbody = $('<tbody />').appendTo($commands_table);
  626. var cmdTotal = 0;
  627.  
  628. function updateCommand(id) {
  629. //console.log("Update on line: " + id);
  630. mrpCommands[id].alias = $("#mrp_alias_input_" + id).val();
  631. mrpCommands[id].name = $("#mrp_name_input_" + id).val();
  632. mrpCommands[id].color = $("#mrp_color_input_" + id).val();
  633. mrpCommands[id].bold = $("#mrp_bold_input_" + id).attr("checked") == "checked" ? true : false;
  634. mrpCommands[id].rp = $("#mrp_rp_input_" + id).attr("checked") == "checked" ? true : false;
  635. //console.log(mrpCommands[id]);
  636. GM_setValue("DCCE_MRP", JSON.stringify(mrpCommands));
  637. }
  638.  
  639. //Fonction pour générer une ligne au tableau
  640. //cmd {alias:"str", name:"str", color:"#008000", bold:false, rp:true}
  641. function drawCommand(cmd, id) {
  642. let $row = $('<tr id="cmd_row_' + id + '"/>').appendTo($commands_tbody);
  643. $row.addClass("loaded_item");
  644.  
  645. 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);
  646. 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);
  647. 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);
  648. 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);
  649. 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);
  650.  
  651. $alias_td.children("input").keyup(function(){updateCommand(id)});
  652. $name_td.children("input").keyup(function(){updateCommand(id)});
  653. $color_td.children("input").change(function(){updateCommand(id)});
  654. $bold_td.children("input").change(function(){updateCommand(id)});
  655. $rp_td.children("input").change(function(){updateCommand(id)});
  656. }
  657.  
  658. for (let j = 0; j < mrpCommands.length; j++) {
  659. $commands_tbody.append(drawCommand(mrpCommands[j], j));
  660. }
  661.  
  662. var $mrp_container = $('<div style="text-align: center"></div>').appendTo($clrconfig);
  663. 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(){
  664. if (mrpCommands.length > 3) {
  665. mrpCommands.pop();
  666. GM_setValue("DCCE_MRP", JSON.stringify(mrpCommands));
  667. $("#cmd_row_" + mrpCommands.length).remove();
  668. }
  669. }).appendTo($mrp_container);
  670.  
  671. 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(){
  672. drawCommand({alias:"", name:"", color:"#FFFFFF", bold:false, rp:false}, mrpCommands.length);
  673. stylizeTableCells();
  674. mrpCommands.push({alias:"", name:"", color:"#FFFFFF", bold:false, rp:false});
  675. GM_setValue("DCCE_MRP", JSON.stringify(mrpCommands));
  676. }).appendTo($mrp_container);
  677.  
  678. //Css des éléments du tableau
  679. function stylizeTableCells() {
  680. $commands_table.find('td').css({
  681. border: '1px solid white',
  682. height: '15px'
  683. });
  684. }
  685. stylizeTableCells();
  686. }
  687. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  688. //FIN Constructeur de fenêtre de configuration
  689. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  690.  
  691.  
  692. //---------------------------------------------------
  693. //Ajout d'un item au menu bandeau "Paramètres" de DC
  694. //---------------------------------------------------
  695. var $params_menu = $('.menus > .parametres > ul');
  696. var $dcce_config = $('<li />').appendTo($params_menu);
  697. $dcce_config.text("Configuration du Chat");
  698. $dcce_config.addClass('link couleur2 separator');
  699.  
  700. $dcce_config.click(function () {
  701. //Fermeture des autres instances de paramétrage ouvertes
  702. engine.closeDataBox('dcce_configwindow');
  703. var $config_window = new DCCE_ConfigurationWindow();
  704. $databox.append($config_window.$window);
  705. });
  706.  
  707. //**********************************************
  708. // FIN INTERFACE DE CONFIGURATION UTILISATEUR
  709. //**********************************************
  710.  
  711. //**********************************************
  712. // DEBUT MAIN
  713. //**********************************************
  714.  
  715. //Compte les charactères façon DreadCast: 7 bits = 1 char, 8-11 bits = 2 chars, 12-16 bits = 3 chars
  716. function chatCharCount(str) {
  717. if (!str) return 0;
  718. 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);
  719. }
  720.  
  721. //ALERTCHAT, Script d'Odul
  722. (function() {
  723. var imgUnmute = 'url(http://i.imgur.com/uvIB44X.png)';
  724. var imgMute = 'url(http://i.imgur.com/8oV9IrJ.png)';
  725.  
  726. var audio = document.createElement('audio');
  727. audio.id='checkchat';
  728. document.body.appendChild(audio);
  729. $('#checkchat').attr('src', alertChatAudioURL);
  730. $("#checkchat").css("display","none");
  731.  
  732. $('<li class="separator"></li>').prependTo($('#bandeau ul.menus'));
  733. var End = $('<li>').prependTo($('#bandeau ul.menus'));
  734. End.attr("id", 'endAudiocheckchat');
  735. End.css({
  736. left: '5px',
  737. height: '30px',
  738. "z-index": '999999',
  739. "background-size": '29px 15px',
  740. "background-repeat": 'no-repeat',
  741. "background-position-y": '6px',
  742. color: '#999'
  743. });
  744. End.text("AC").addClass('link');
  745. End.hover(
  746. function(){
  747. $(this).css("color", "#0073d5");
  748. },
  749. function(){
  750. var colorAC = (activateAlertChat) ? "#999" : "#D00000";
  751. $(this).css("color", colorAC);
  752. }
  753. );
  754. End.click(function() {
  755. activateAlertChat = (activateAlertChat) ? false : true;
  756. GM_setValue("DCCE_activateAlertChat", activateAlertChat);
  757. document.getElementById('endAudiocheckchat').style.backgroundImage = (activateAlertChat) ? imgUnmute : imgMute;
  758. //document.getElementById('checkchat').volume = (activateAlertChat) ? 1 : 0;
  759. document.getElementById('checkchat').volume = (activateAlertChat) ? alertVolume : 0;
  760. var colorAC = (activateAlertChat) ? "#999" : "#D00000";
  761. End.css("color", colorAC);
  762. });
  763.  
  764. //Initialisation depuis le stockage local
  765. document.getElementById('endAudiocheckchat').style.backgroundImage = (activateAlertChat) ? imgUnmute : imgMute;
  766. //document.getElementById('checkchat').volume = (activateAlertChat) ? 1 : 0;
  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. var audio = document.getElementById('checkchat');
  941. audio.load();
  942. audio.play();
  943.  
  944. if(autoScroll) {
  945. scrollChat();
  946. }
  947. else if($("#chatContent .link.linkable:last").text() !== $("#txt_pseudo").text()) {
  948. $newMessageAlert.stop().fadeIn(500); //Afficher uniquement le bouton si l'utilisateur ne vient pas de poster.
  949. }
  950. }
  951. }, 1000);
  952.  
  953. //COLOR TAG
  954. $(document).on("click", "span.perso.link", function(){
  955. var idPerso = $(this).attr('id').slice(9);
  956. $(document).one("ajaxSuccess", {idPerso: idPerso}, function(e){ //Permet d'attendre le chargement de la fenêtre, one() pour éviter un duplicata.
  957. var idctb = '#colorTagBox_' + e.data.idPerso;
  958. var colorTagBox = $('<div style="margin-top: 15px; text-align: center;">' + 'Couleur chat: ' +
  959. '<input type="color" id="' + idctb.slice(1) + '" value="' + DEFAULT_CHAT_COLOR + '"/>' +
  960. '<input type="button" id="' + idctb.slice(1) + '_reset" value="Reset" style="background-color: buttonface; margin-left: 5px; height: 16px; font-size: 12px;"/>' +
  961. '</div>').appendTo($("#ib_persoBox_" + e.data.idPerso + " .fakeToolTip"));
  962.  
  963. GM_setValue("dcce_name_" + e.data.idPerso, $("#ib_persoBox_" + e.data.idPerso + " .titreinfo").contents().filter(function(){
  964. return this.nodeType == 3;
  965. })[0].nodeValue); //Récupère le nom du personnage, utilisé dans le nommage de la classe du pseudo.
  966.  
  967. if(GM_getValue("dcce_ctb_" + e.data.idPerso) !== undefined) { //Récupère et applique au bouton couleur la couleur enregistrée
  968. $(idctb).val((GM_getValue("dcce_ctb_" + e.data.idPerso)));
  969. }
  970. $(idctb).on("change", {idPerso: e.data.idPerso}, function(e) { //Enregistre en mémoire la nouvelle couleur
  971. GM_setValue("dcce_ctb_" + e.data.idPerso, $(this).val());
  972. chatChangeColor(e.data.idPerso);
  973. });
  974. $(idctb + "_reset").on("click", {idPerso: e.data.idPerso}, function(e) { //Reset de la couleur
  975. GM_deleteValue("dcce_ctb_" + e.data.idPerso);
  976. $(idctb).val(DEFAULT_CHAT_COLOR);
  977. chatChangeColor(e.data.idPerso);
  978. });
  979. });
  980.  
  981. });
  982. });