Greasy Fork 还支持 简体中文。

-:TA Chat Colorize:-

Let's change username color (chat) in dependence of role in alliance.

目前為 2015-10-01 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name -:TA Chat Colorize:-
  3. // @description Let's change username color (chat) in dependence of role in alliance.
  4. // @namespace http*://prodgame*.alliances.commandandconquer.com/*/index.aspx*
  5. // @include https://prodgame*.alliances.commandandconquer.com/*/index.aspx*
  6. // @icon http://i.imgur.com/0dweZMu.png
  7. // @version 0.1.1
  8. // @author der_flake
  9. // ==/UserScript==
  10. (function ()
  11. {
  12. var ta_chat_colorize_main = function ()
  13. {
  14. function ta_chat_initialize()
  15. {
  16. console.log('-:TA Chat Colorize:- loaded');
  17.  
  18. var role_colors = {
  19. 168: '#5b7b37', // inactive
  20. //166: '#a5f25b', // member
  21. 165: '#42B27C', // veteran
  22. 164: '#FFEB5F', // officer
  23. 163: '#a75fb4', // sic
  24. 162: '#FF6060', // cic
  25. }
  26. var players = ClientLib.Data.MainData.GetInstance().get_Alliance().get_MemberDataAsArray();
  27. var colorize_comments = false;
  28. var pre_css = '';
  29.  
  30. for (var key in players)
  31. {
  32. var current_player = players[key];
  33. if (typeof role_colors[current_player.Role] != 'undefined')
  34. {
  35. if(colorize_comments)
  36. pre_css += '#CHAT_SENDER_' + current_player.Name + ',#CHAT_SENDER_' + current_player.Name + ' + * {color: ' + role_colors[current_player.Rank] + '}';
  37. else
  38. pre_css += '#CHAT_SENDER_' + current_player.Name + ' {color: ' + role_colors[current_player.Role] + '}';
  39. }
  40. }
  41.  
  42. if(pre_css !== '')
  43. {
  44. var tachatStyle = document.createElement("style");
  45. tachatStyle.innerHTML = pre_css;
  46. if (/commandandconquer\.com/i.test(document.domain)) {
  47. document.getElementsByTagName('head') [0].appendChild(tachatStyle);
  48.  
  49. console.log('-:TA Chat Colorize:- CSS loaded');
  50. }
  51. }
  52. }
  53.  
  54. function tachat_checkIfLoaded() {
  55. try {
  56. if (typeof qx != 'undefined') {
  57. if (qx.core.Init.getApplication() && qx.core.Init.getApplication().getMenuBar()) {
  58. // @TODO try to find other method to make ClientLib "WORKABLE"
  59. window.setTimeout(ta_chat_initialize, 15000);
  60. } else
  61. window.setTimeout(tachat_checkIfLoaded, 1000);
  62. } else {
  63. window.setTimeout(tachat_checkIfLoaded, 1000);
  64. }
  65. } catch (e) {
  66. console.log("tachat_checkIfLoaded: ", e);
  67. }
  68. }
  69. if (/commandandconquer\.com/i.test(document.domain)) {
  70. window.setTimeout(tachat_checkIfLoaded, 1000);
  71. }
  72. }
  73.  
  74. var tachatScript = document.createElement('script');
  75. tachatScript.innerHTML = '(' + ta_chat_colorize_main.toString() + ')();';
  76. tachatScript.type = 'text/javascript';
  77. if (/commandandconquer\.com/i.test(document.domain)) {
  78. document.getElementsByTagName('head') [0].appendChild(tachatScript);
  79. }
  80. })();