rainbow gamevn

This script add color text in gamevn and some xenforo 4r else.

  1. // ==UserScript==
  2. // @name rainbow gamevn
  3. // @namespace https://greasyfork.org/en/scripts/8685-rainbow-gamevn
  4. // @description This script add color text in gamevn and some xenforo 4r else.
  5. // @run-at document-end
  6. // @version 1.2.1
  7. // @grant GM_setValue
  8. // @grant GM_getValue
  9. // @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js
  10. // @include /^https?:\/\/.*.tinhte.vn/(threads|conversations)/*
  11. // @include /^https?:\/\/.*.nhattao.com/(threads|conversations)/*
  12. // @include /^https?:\/\/.*.gamevn.com/(threads|conversations)/*
  13. // ==/UserScript==vvar SIZE = 2;
  14. var COLOR = 'black';
  15. var inDam = 0;
  16. var inNghieng = 0;
  17. var sizeDefault = false;
  18. var colorDefault = false;
  19.  
  20. var rainbow_fontsize = 'rainbow_fontsize';
  21. var rainbow_fontcolor = 'rainbow_fontcolor';
  22. var rainbow_bold = 'rainbow_bold';
  23. var rainbow_italic = 'rainbow_italic';
  24. var spoiler = 'spoiler';
  25.  
  26. var optionCSS = "<style>div.rainbow_option_box {display:inline-block;margin-left:5px;margin-right:5px;} div.rainbow_option_area{margin:5px 1px; padding:5px;border-top:1px solid gray;} div.rainbow_button{display:inline-block;margin:3px 3px;padding:3px 4px;background-color:grey;color:white;cursor:pointer}</style>";
  27. $('head').append(optionCSS);
  28. var optionHTML = "<div class='rainbow_option_area' align='center'><div class='rainbow_option_box'>Font size <select id='rainbow_fontsize'><option value='1'>1</option><option value='2'>2 (default)</option><option value='3'>3</option><option value='4'>4</option><option value='5'>5</option></select></div><div class='rainbow_option_box'>Color <input type='text' id='rainbow_fontcolor' title='Màu chữ có thể ở dạng tên (vd: black, blue) hoặc mã HEX (vd: #4827F3)' style='width: 6em; padding-left: 5px' /></div><div class='rainbow_option_box'><input type='checkbox' id='rainbow_bold' />Bold</div><div class='rainbow_option_box'><input type='checkbox' id='rainbow_italic' />Italic</div><div class='rainbow_option_box'><input type='checkbox' id='spoiler' />Spoiler</div><div class='rainbow_option_box'><div class='rainbow_button' id='rainbow_btn_save'>Save</div><div class='rainbow_button' id='rainbow_btn_default'>Restore Default</div></div><div align='center' style='margin-top: 5px' id='rainbow_version'>VOZ Rainbow</div></div>";
  29.  
  30. var quickRep = $('#QuickReply');
  31. var fullRep = $('#ThreadReply');
  32. var Rep = null;
  33. if (quickRep.length>0) {
  34. Rep = $('#QuickReply');
  35. }else if (fullRep.length>0) {
  36. Rep = $('#ThreadReply');
  37. }else {Rep = $('form.xenForm.Preview');}
  38. Rep.append(optionHTML);
  39.  
  40. function loadSetting() {
  41. SIZE = GM_getValue(rainbow_fontsize, 2);
  42. COLOR = GM_getValue(rainbow_fontcolor, 'black');
  43. inDam = GM_getValue(rainbow_bold, 0);
  44. inNghieng = GM_getValue(rainbow_italic, 0);
  45. spoil = GM_getValue(spoiler, 0);
  46. sizeDefault = false;
  47. colorDefault = false;
  48. $('#' + rainbow_fontsize).val(SIZE);
  49. $('#' + rainbow_fontcolor).val(COLOR);
  50. if (inDam > 0) $('#' + rainbow_bold).attr('checked', 'checked');
  51. else $('#' + rainbow_bold).removeAttr('checked');
  52. if (spoil > 0) $('#' + spoiler).attr('checked', 'checked');
  53. else $('#' + spoiler).removeAttr('checked');
  54. if (inNghieng > 0) $('#' + rainbow_italic).attr('checked', 'checked');
  55. else $('#' + rainbow_italic).removeAttr('checked');
  56. if (SIZE == 2) sizeDefault = true;
  57. if (COLOR.toLowerCase() == "black" || COLOR.toLowerCase() == "#000000") colorDefault = true;
  58. console.log('loaded ' + SIZE + ' , ' + COLOR + ' , ' + inDam + ' , ' + inNghieng);
  59. }
  60.  
  61. function saveSetting() {
  62. SIZE = $('#' + rainbow_fontsize).val();
  63. COLOR = $('#' + rainbow_fontcolor).val();
  64. if (COLOR === '') COLOR = 'black';
  65. if ($('#' + rainbow_bold).is(':checked')) inDam = 1;
  66. else inDam = 0;
  67. if ($('#' + spoiler).is(':checked')) spoil = 1;
  68. else spoil = 0;
  69. if ($('#' + rainbow_italic).is(':checked')) inNghieng = 1;
  70. else inNghieng = 0;
  71. var r = confirm("Do you want to save these settings?" + "\n\nFont size: " + SIZE + "\nFont color: " + COLOR + "\nBold: " + inDam + "\nItalic: " + inNghieng);
  72. if (r === true) {
  73. GM_setValue(rainbow_fontsize, SIZE);
  74. GM_setValue(rainbow_fontcolor, COLOR);
  75. GM_setValue(rainbow_bold, inDam);
  76. GM_setValue(spoiler, spoil);
  77. GM_setValue(rainbow_italic, inNghieng);
  78. loadSetting();
  79. }
  80.  
  81. }
  82.  
  83. function loadDefault() {
  84. var r = confirm("Do you want to restore to default settings?");
  85. if (r === true) {
  86. GM_setValue(rainbow_fontsize, 2);
  87. GM_setValue(rainbow_fontcolor, 'black');
  88. GM_setValue(rainbow_bold, 0);
  89. GM_setValue(rainbow_italic, 0);
  90. GM_setValue(spoiler, 0);
  91. loadSetting();
  92. }
  93. }
  94.  
  95. loadSetting();
  96. $('#rainbow_btn_default').click(loadDefault);
  97. $('#rainbow_btn_save').click(saveSetting);
  98. $('#rainbow_version').html(
  99. 'VOZ Rainbow ' + GM_info.script.version + ' | Author: <b>skyfall</b> @ vozforums.com and edited by <b>Doctor Who</b> @ vozforums.com');
  100. /*
  101. * hết tùy chọn
  102. */
  103. var reply = Rep.find("input[type='submit'].button.primary");
  104. reply.click(submit);
  105. var view = Rep.find("input[type='button']");
  106. view.click(submit);
  107. function submit(){
  108. comment = Rep.find('iframe').contents().find('body');
  109. var s = appendCode(comment.html());
  110. comment.empty();
  111. comment.append(s);
  112. }
  113. $("div.messageInfo.primaryContent > div.messageMeta.ToggleTriggerAnchor > div.privateControls > a.item.control.edit.OverlayTrigger").click(function(){
  114. setTimeout (function(){var edit = $('form[action*="save-inline"]');
  115. edit.click(submit_edit);
  116. }, 4000);
  117. });
  118. function submit_edit(){
  119. comment = $('form[action*="save-inline"] iframe').contents().find('body');
  120. var s = appendCode(comment.html());
  121. comment.empty();
  122. comment.append(s);
  123. }
  124. function appendCode(s) {
  125. var bString = "";
  126. var eString = "";
  127. if (spoil == 1) {
  128. bString = "[spoiler]" + bString;
  129. eString = eString + "[/spoiler]";
  130. }
  131. if (inDam == 1) {
  132. bString = "[b]" + bString;
  133. eString = eString + "[/b]";
  134. }
  135. if (inNghieng == 1) {
  136. bString = "[i]" + bString;
  137. eString = eString + "[/i]";
  138. }
  139. if (!colorDefault) {
  140. bString = "[color=" + COLOR + "]" + bString;
  141. eString = eString + "[/color]";
  142. }
  143. if (!sizeDefault) {
  144. bString = "[size=" + SIZE + "]" + bString;
  145. eString = eString + "[/size]";
  146. }
  147. s = s.split('[QUOTE]').join(eString+'[QUOTE]');
  148. s = s.split('[QUOTE=').join(eString+'[QUOTE=');
  149. s = s.split('[/QUOTE]').join('[/QUOTE]'+bString);
  150. s = bString + s + eString;
  151.  
  152. s = s.split(bString+'<p>'+eString).join('<p>');
  153. s = s.split(bString+bString).join(bString);
  154. s = s.split(eString+eString).join(eString);
  155. return s;
  156. }