Picarto - Disable round, yellow emotes in chat

Replaces the yellow emotes in Picarto chat with their text-based counterparts (aka "normal" emotes).

  1. // ==UserScript==
  2. // @name Picarto - Disable round, yellow emotes in chat
  3. // @namespace http://github.com/SnowySailor
  4. // @include https://picarto.tv/*
  5. // @version 1.1
  6. // @grant none
  7. // @description Replaces the yellow emotes in Picarto chat with their text-based counterparts (aka "normal" emotes).
  8. // ==/UserScript==
  9. /*
  10. Created by SnowySailor - http://github.com/SnowySailor
  11. Redefining of a Picarto JS function emoticonize
  12. */
  13. window.$.fn.emoticonize = function(options) {
  14. var opts = $.extend({}, $.fn.emoticonize.defaults, options);
  15.  
  16. var escapeCharacters = [ ")", "(", "*", "[", "]", "{", "}", "|", "^", "<", ">", "\\", "?", "+", "=", "." ];
  17.  
  18. var threeCharacterEmoticons = [
  19. // really weird bug if you have :{ and then have :{) in the same container anywhere *after* :{ then :{ doesn't get matched, e.g. :] :{ :) :{) :) :-) will match everything except :{
  20. // But if you take out the :{) or even just move :{ to the right of :{) then everything works fine. This has something to do with the preMatch string below I think, because
  21. // it'll work again if you set preMatch equal to '()'
  22. // So for now, we'll just remove :{) from the emoticons, because who actually uses this mustache man anyway?
  23. // ":{)",
  24. ":-)", ":o)", ":c)", ":^)", ":-D", ":-(", ":-9", ";-)", ":-P", ":-p", ":-Þ", ":-b", ":-O", ":-/", ":-X", ":-#", ":'(", "B-)", "8-)", ";*(", ":-*", ":-\\",
  25. "?-)", // <== This is my own invention, it's a smiling pirate (with an eye-patch)!
  26. // and the twoCharacterEmoticons from below, but with a space inserted
  27. ": )", ": ]", "= ]", "= )", "8 )", ": }", ": D", "8 D", "X D", "x D", "= D", ": (", ": [", ": {", "= (", "; )", "; ]", "; D", ": P", ": p", "= P", "= p", ": b", ": Þ", ": O", "8 O", ": /", "= /", ": S", ": #", ": X", "B )", ": |", ": \\", "= \\", ": *", ": &gt;", ": &lt;"//, "* )"
  28. ];
  29.  
  30. var twoCharacterEmoticons = [ // separate these out so that we can add a letter-spacing between the characters for better proportions
  31. ":)", ":]", "=]", "=)", "8)", ":}", ":D", ":(", ":[", ":{", "=(", ";)", ";]", ";D", ":P", ":p", "=P", "=p", ":b", ":Þ", ":O", ":/", "=/", ":S", ":#", ":X", "B)", ":|", ":\\", "=\\", ":*", ":&gt;", ":&lt;"//, "*)"
  32. ];
  33.  
  34.  
  35. var specialRegex = new RegExp( '(\\' + escapeCharacters.join('|\\') + ')', 'g' );
  36. // One of these characters must be present before the matched emoticon, or the matched emoticon must be the first character in the container HTML
  37. // This is to ensure that the characters in the middle of HTML properties or URLs are not matched as emoticons
  38. // Below matches ^ (first character in container HTML), \s (whitespace like space or tab), or \0 (NULL character)
  39. // (<\\S+.*>) matches <\\S+.*> (matches an HTML tag like <span> or <div>), but haven't quite gotten it working yet, need to push this fix now
  40. var preMatch = '(^|[\\s\\0])';
  41.  
  42. for ( var i=threeCharacterEmoticons.length-1; i>=0; --i ){
  43. threeCharacterEmoticons[i] = threeCharacterEmoticons[i].replace(specialRegex,'\\$1');
  44. threeCharacterEmoticons[i] = new RegExp( preMatch+'(' + threeCharacterEmoticons[i] + ')', 'g' );
  45. }
  46.  
  47. for ( var i=twoCharacterEmoticons.length-1; i>=0; --i ){
  48. twoCharacterEmoticons[i] = twoCharacterEmoticons[i].replace(specialRegex,'\\$1');
  49. twoCharacterEmoticons[i] = new RegExp( preMatch+'(' + twoCharacterEmoticons[i] + ')', 'g' );
  50. }
  51.  
  52. /*for ( var emoticon in specialEmoticons ){
  53. specialEmoticons[emoticon].regexp = emoticon.replace(specialRegex,'\\$1');
  54. specialEmoticons[emoticon].regexp = new RegExp( preMatch+'(' + specialEmoticons[emoticon].regexp + ')', 'g' );
  55. }*/
  56.  
  57. var exclude = 'span.css-emoticon';
  58. if(opts.exclude){ exclude += ','+opts.exclude; }
  59. var excludeArray = exclude.split(',')
  60.  
  61. return this.not(exclude).each(function() {
  62. var container = $(this);
  63. var cssClass = 'css-emoticon'
  64. if(opts.animate){ cssClass += ' un-transformed-emoticon animated-emoticon'; }
  65.  
  66.  
  67. var time_var = new Date().getTime();
  68. var content = container.html();
  69.  
  70.  
  71. /* NORMAL SMILIES */
  72. if(content.match(/:sad:/g)){
  73. content = (content.replace(/:sad:/g,"<img title='...' class='emoti animated rubberBand' src='../images/chat/emoticons/sad.png'>"));
  74. }
  75. if(content.match(/:angry:/g)){
  76. content = (content.replace(/:angry:/g,"<img title='...' class='emoti animated jello' src='../images/chat/emoticons/angry.png'>"));
  77. }
  78. if(content.match(/:condescending:/g)){
  79. content = (content.replace(/:condescending:/g,"<img title='...' class='emoti animated swing' src='../images/chat/emoticons/condescending.png'>"));
  80. }
  81. if(content.match(/:confused:/g)){
  82. content = (content.replace(/:confused:/g,"<img title='...' class='emoti animated shake' src='../images/chat/emoticons/confused.png'>"));
  83. }
  84. if(content.match(/:excited:/g)){
  85. content = (content.replace(/:excited:/g,"<img title='...' class='emoti animated shake' src='../images/chat/emoticons/excited.png'>"));
  86. }
  87. if(content.match(/:grossedout:/g)){
  88. content = (content.replace(/:grossedout:/g,"<img title='...' class='emoti animated wobble' src='../images/chat/emoticons/grossedout.png'>"));
  89. }
  90. if(content.match(/:laugh:/g)){
  91. content = (content.replace(/:laugh:/g,"<img title='...' class='emoti animated bounce' src='../images/chat/emoticons/laugh.png'>"));
  92. }
  93. if(content.match(/:ohmy:/g)){
  94. content = (content.replace(/:ohmy:/g,"<img title='...' class='emoti animated shake' src='../images/chat/emoticons/ohmy.png'>"));
  95. }
  96. if(content.match(/:pouty:/g)){
  97. content = (content.replace(/:pouty:/g,"<img title='...' class='emoti animated jello' src='../images/chat/emoticons/pouty.png'>"));
  98. }
  99. if(content.match(/:sad:/g)){
  100. content = (content.replace(/:sad:/g,"<img title='...' class='emoti animated swing' src='../images/chat/emoticons/sad.png'>"));
  101. }
  102. if(content.match(/:shock:/g)){
  103. content = (content.replace(/:shock:/g,"<img title='...' class='emoti animated tada' src='../images/chat/emoticons/shock.png'>"));
  104. }
  105. if(content.match(/:sleepy:/g)){
  106. content = (content.replace(/:sleepy:/g,"<img title='...' class='emoti animated pulse' src='../images/chat/emoticons/sleepy.png'>"));
  107. }
  108. if(content.match(/:snicker:/g)){
  109. content = (content.replace(/:snicker:/g,"<img title='...' class='emoti animated bounce' src='../images/chat/emoticons/snicker.png'>"));
  110. }
  111. if(content.match(/:uneasy:/g)){
  112. content = (content.replace(/:uneasy:/g,"<img title='...' class='emoti animated jello' src='../images/chat/emoticons/uneasy.png'>"));
  113. }
  114. if(content.match(/:unimpressed:/g)){
  115. content = (content.replace(/:unimpressed:/g,"<img title='...' class='emoti animated shake' src='../images/chat/emoticons/unimpressed.png'>"));
  116. }
  117. if(content.match(/:whiny:/g)){
  118. content = (content.replace(/:whiny:/g,"<img title='...' class='emoti animated rubberBand' src='../images/chat/emoticons/whiny.png'>"));
  119. }
  120. if(content.match(/:kippi:/g)){
  121. content = (content.replace(/:kippi:/g,"<img title='...' class='emoti animated tada' src='../images/chat/emoticons/kippi.png'>"));
  122. }
  123. if(content.match(/:kippi2:/g)){
  124. content = (content.replace(/:kippi2:/g,"<img title='...' class='emoti animated tada' src='../images/chat/emoticons/kippi2.png'>"));
  125. }
  126. if(content.match(/:kippi3:/g)){
  127. content = (content.replace(/:kippi3:/g,"<img title='...' class='emoti animated tada' src='../images/chat/emoticons/kippi3.png'>"));
  128. }
  129. //Special Emotes
  130. if(content.match(/:special1:/g)){
  131. content = (content.replace(/:special1:/g,"<span class='special_emote'>͡° ͜ʖ ͡°</span>"));
  132. }
  133. if(content.match(/:special2:/g)){
  134. content = (content.replace(/:special2:/g,"<span class='special_emote'>ಠ_ಠ</span>"));
  135. }
  136. if(content.match(/:special3:/g)){
  137. content = (content.replace(/:special3:/g,"<span class='special_emote'>ΘεΘ</span>"));
  138. }
  139. if(content.match(/:special4:/g)){
  140. content = (content.replace(/:special4:/g,"<span class='animated jello special_emote green_emote'>ᕕ( ᐛ )ᕗ</span>"));
  141. }
  142. if(content.match(/:special5:/g)){
  143. content = (content.replace(/:special5:/g,"<span class='special_emote'> ͠° ͟ʖ ͡°</span>"));
  144. }
  145. if(content.match(/:special6:/g)){
  146. content = (content.replace(/:special6:/g,"<span class='animated tada special_emote brown_emote'>ᕦʳ ´º㉨ºᕤ</span>"));
  147. }
  148. if(content.match(/:special7:/g)){
  149. content = (content.replace(/:special7:/g,"<span class='animated swing special_emote'>ಥ_ಥ</span>"));
  150. }
  151. if(content.match(/:special8:/g)){
  152. content = (content.replace(/:special8:/g,"<span class='animated bounceIn special_emote red_emote'>╬ ಠ益ಠ</span>"));
  153. }
  154.  
  155. //Speechbubble
  156. if(content.match(/\*\[/g)){
  157. content = (content.replace(/\*\[/g,"<span class='speechbubble_right'>"));
  158. }
  159. if(content.match(/\[/g)){
  160. content = (content.replace(/\[/g,"<span>"));
  161. }
  162. if(content.match(/\]\*/g)){
  163. content = (content.replace(/\]\*/g,"</span>"));
  164. content = (content.replace("<span>","<span class='speechbubble_left'>"));
  165. }
  166. if(content.match(/\]/g)){
  167. content = (content.replace(/\]/g,"</span>"));
  168. }
  169.  
  170. //SDFSDAFGSADF
  171.  
  172.  
  173. //MEME
  174. /*
  175. if(content.match(/:meme1:/g)){
  176. content = (content.replace(/\:meme1\:/g,"<img title='Forever alone ;_;' class='memeEmoti animated jello' src='../images/chat/emoticons/meme/alone.png'>"));
  177. }
  178. if(content.match(/:meme2:/g)){
  179. content = (content.replace(/\:meme2\:/g,"<img title='Jackie why?!' class='memeEmoti animated shake' src='../images/chat/emoticons/meme/jackie.png'>"));
  180. }
  181. if(content.match(/:meme3:/g)){
  182. content = (content.replace(/\:meme3\:/g,"<img title='NO WAY!' class='memeEmoti animated flash' src='../images/chat/emoticons/meme/whaaat.jpg'>"));
  183. }
  184. if(content.match(/:meme4:/g)){
  185. content = (content.replace(/:meme4:/g,"<img title='DSFGHG ERUJW TGDF J' class='memeEmoti animated swing' src='../images/chat/emoticons/meme/arms.gif'>"));
  186. }
  187. if(content.match(/:meme5:/g)){
  188. content = (content.replace(/:meme5:/g,"<img title='FU DA BI' class='memeEmoti animated rubberBand' src='../images/chat/emoticons/meme/fubu.png'>"));
  189. }
  190. */
  191. /* HEART */
  192. if(content.match(/&lt;3/g)){
  193. content = (content.replace(/&lt;3/g,"<span class='animated rubberBand heart'></span>"));
  194. }
  195.  
  196. container.html(content);
  197. // fix emoticons that got matched more then once (where one emoticon is a subset of another emoticon), and thus got nested spans
  198. $.each(excludeArray,function(index,item){
  199. container.find($.trim(item)+" span.css-emoticon").each(function(){
  200. $(this).replaceWith($(this).text());
  201. });
  202. });
  203. if(opts.animate){
  204. setTimeout(function(){$('.un-transformed-emoticon').removeClass('un-transformed-emoticon');}, opts.delay);
  205. }
  206. });
  207. }