Advertisement
dgz345

CC - RAINBOW

Jul 30th, 2018
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. // ==UserScript==
  2. // @name CC Chat RAINBOW!!
  3. // @namespace dgz345
  4. // @version 0.1
  5. // @description try to take over the world!
  6. // @author You
  7. // @match http*://www.conquerclub.com/chat13/*
  8. // @grant unsafeWindow
  9. // 16f0075bdf38db1ce497
  10. // ==/UserScript==
  11.  
  12. function init()
  13. {
  14. unsafeWindow.colorText = function(str,phase) {
  15. if (phase == undefined)
  16. phase = 0;
  17. var center = 128;
  18. var width = 127;
  19. var frequency = Math.PI*2/str.length;
  20. var cstr="";
  21. for (var i = 0; i < str.length; ++i) {
  22. var red = Math.sin(frequency*i+2+phase) * width + center;
  23. var green = Math.sin(frequency*i+0+phase) * width + center;
  24. var blue = Math.sin(frequency*i+4+phase) * width + center;
  25. cstr+= "[color=" + RGB2Color(red,green,blue) + "]" + str.substr(i,1) + "[/color]";
  26. }
  27. ColorMatters();
  28. return cstr;
  29. };
  30.  
  31. unsafeWindow.ColorMatters = function() {
  32.  
  33. };
  34.  
  35. unsafeWindow.RGB2Color = function(r,g,b) {
  36. return '#' + byte2Hex(r) + byte2Hex(g) + byte2Hex(b);
  37. };
  38.  
  39. unsafeWindow.byte2Hex=function(n) {
  40. var nybHexString = "0123456789ABCDEF";
  41. return String(nybHexString.substr((n >> 4) & 0x0F,1)) + nybHexString.substr(n & 0x0F,1);
  42. };
  43. var p=0;
  44. console.log(unsafeWindow.pfc);
  45. unsafeWindow.pfc.doSendMessage=function () {
  46. var w = this.el_words;
  47. var wval = w.value; // Append the string to the history.
  48. this.cmdhistory.push(wval);
  49. this.cmdhistoryid = this.cmdhistory.length;
  50. this.cmdhistoryissearching = false; // Send the string to the server.
  51. re = new RegExp("^(/[a-zA-Z0-9]+)( (.*)|)");
  52. if (wval.match(re)) { // A user command.
  53. cmd = wval.replace(re, '$1');
  54. param = wval.replace(re, '$3');
  55. this.sendRequest(cmd +' '+ param.substr(0, pfc_max_text_len + 2*this.clientid.length));
  56. } else { // A classic 'send' command.
  57. // Empty messages with only spaces.
  58. rx = new RegExp('^[ ]*$','g');
  59. wval = wval.replace(rx,''); // Truncate the text length.
  60. wval = wval.substr(0,pfc_max_text_len); // Colorize the text with current_text_color.
  61. if (this.current_text_color != '' && wval.length != '') {
  62. p=p+1;
  63. wval = colorText(wval,p);
  64. }
  65. this.sendRequest('/send '+ wval);
  66. } w.value = '';
  67. return false;
  68. };
  69.  
  70. }
  71.  
  72. var loadCheck = setInterval(function(){
  73. console.log("Waiting for pfc");
  74. if (unsafeWindow.pfc) {
  75. clearInterval(loadCheck);
  76. console.log("pfc loaded!");
  77. init();
  78. }
  79.  
  80. }, 250);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement