Advertisement
Guest User

NothingXD

a guest
Aug 28th, 2014
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.     Copyright (c) 2013-2014 by Olivier Houle (Fungus)
  3.     Please do not copy or modify without my permission.
  4. */
  5.  
  6. SockJS.prototype.msg = function(a){this.send(JSON.stringify(a))};
  7. SockJS.prototype.connected = function(){return this.readyState==1};
  8. Array.prototype.isArray = true;
  9. var tastyPlugShutDown;
  10. if (typeof tastyPlugShutDown != 'undefined') tastyPlugShutDown();
  11. (function(){
  12.     var sock, afktime = Date.now(), reconint = 2, pms = false, drag = false, hidevideo = false,
  13.     version = '1.3.0.0', commands = {}, tos = {}, boothcd = false, reconnect = true, emotes, cd = false,
  14.     settings = {
  15.         show: true,
  16.         autowoot: false,
  17.         autojoin: false,
  18.         chatmentions: false,
  19.         joinnotifs: {toggle:false,ranks:false,friends:false},
  20.         joinmode: 1,
  21.         msgs: [],
  22.         afkalert: false,
  23.         lastPM: null,
  24.         uipos: {'top':'54px','left':'0'},
  25.         boothalert: false,
  26.         histalert: false,
  27.         chatimgs: false,
  28.         emotes: false,
  29.         twitch: false,
  30.         userfaces: false,
  31.         tastycat: false,
  32.         logos: false,
  33.         misc: false,
  34.         gifs: false,
  35.         friends: {},
  36.         hidden: false
  37.     };
  38.     function socket() {
  39.         sock = new SockJS('https://fungustime.pw:4957');
  40.         sock.onopen = function() {
  41.             reconint = 2;
  42.             console.log('[TastyPlug v' + version + '] Connected to socket!');
  43.             return sock.msg({z:'userjoin',a:API.getUser(),r:location.pathname});
  44.         };
  45.         sock.onmessage = function(data) {
  46.             data = JSON.parse(data.data);
  47.             switch (data.z) {
  48.                 case 'load':
  49.                     $('#tp-antiAfk span.result').text(data.a.antiAfk?'on':'off');
  50.                     $('#tp-antiAfkLimit span.result').text(data.a.antiAfkLimit);
  51.                     $('#tp-lottery span.result').text(data.a.lottery?'on':'off');
  52.                     $('#tp-lotTime span.result').text(60-new Date().getMinutes());
  53.                     $('#tp-userCmds span.result').text(data.a.userCmds?'on':'off');
  54.                     $('#tp-duels span.result').text(data.a.duels?'on':'off');
  55.                     return console.log('[TastyPlug v' + version + '] Loaded TastyBot settings.');
  56.                 case 'settupdate':
  57.                     if (typeof data.b == 'boolean') data.b = data.b ? 'on' : 'off';
  58.                     else if (data.a == 'lottime') data.b = 60 - data.b;
  59.                     return $('#tp-' + data.a + ' span.result').text(data.b);
  60.                 case 'cmderr':
  61.                     return Chat('error', data.e);
  62.                 case 'afkwarning':
  63.                     if (!settings.afkalert) return;
  64.                     if (data.m) {
  65.                         Chat('error', data.m);
  66.                         chatSound();
  67.                     }
  68.                     else clearInterval(tos.afkalert);
  69.                     if (data.n) tos.afkalert = setInterval(chatSound,4000);
  70.                     break;
  71.                 case 'clientmsg':
  72.                     return Chat('info', data.a);
  73.                 case 'pm':
  74.                     settings.lastPM = data.user.username;
  75.                     chatSound();
  76.                     return ChatPM(data.user.username, data.m);
  77.                 case 'reload':
  78.                     return commands.reset();
  79.                 default:
  80.                     console.log('[TastyPlug v' + version + '] Unknown socket command');
  81.             }
  82.         };
  83.         sock.onclose = function() {
  84.             console.log('[TastyPlug v' + version + '] Disconnected from socket!');
  85.             if (reconnect) tos.reconnect = setTimeout(function(){
  86.                 if (sock.readyState == 3) socket();
  87.                 if (reconint < 6) reconint++;
  88.             },Math.pow(2,reconint)*1000);
  89.         };
  90.     }
  91.     function startup() {
  92.         loadSettings();
  93.         loadUI();
  94.         loadEvents();
  95.         loadEmotes();
  96.         if (location.pathname != '/tastycat/') {
  97.             $('#tp-roominfo').remove();
  98.             $('#tp-afkalert').remove();
  99.         } else {
  100.             eta();
  101.             tos.lottery = setInterval(function(){
  102.                 var lot = $('#tp-lotTime span.result'), num = +lot.text();
  103.                 --num;
  104.                 if (num < 0) num = 59;
  105.                 lot.text(num);
  106.             },6E4);
  107.         }
  108.         if (settings.autowoot) woot();
  109.         if (settings.autojoin) {
  110.             afkCheck();
  111.             if (!getLocked() && API.getWaitListPosition() == -1 && API.getDJ().id != API.getUser().id) API.djJoin();
  112.         }
  113.         socket();
  114.         Chat('init', 'TastyPlug v' + version + ' now running!');
  115.         console.log('[TastyPlug v' + version + '] Now running.');
  116.     }
  117.     function loadSettings() {
  118.         var a = JSON.parse(localStorage.getItem('tastyPlugSettings'));
  119.         if (a) {
  120.             for (var i in settings) {
  121.                 if (typeof a[i] != 'undefined') {
  122.                     if (a[i] !== null && a[i].isArray && settings[i] !== null && settings[i].isArray) settings[i] = a[i];
  123.                     else if (typeof settings[i] == 'object' && settings[i] !== null) {
  124.                         var j = undefined;
  125.                         for (j in settings[i]) {
  126.                             if (typeof a[i][j] != 'undefined') settings[i][j] = a[i][j];
  127.                         }
  128.                         if (typeof j == 'undefined') settings[i] = a[i];
  129.                     } else settings[i] = a[i];
  130.                 }
  131.             }
  132.         }
  133.     }
  134.     function loadUI() {
  135.         $('head').append('<style type="text/css" id="tastyplug-css"> #tastyplug-ui{-moz-user-select:none;-webkit-user-select:none;position:absolute;width:150px;border-radius:10px;background-color:#1C1F25;background-image:-webkit-gradient(linear,left bottom,left top,color-stop(0,#1C1F25),color-stop(1,#282D33));background-image:-o-linear-gradient(top,#1C1F25 0,#282D33 100%);background-image:-moz-linear-gradient(top,#1C1F25 0,#282D33 100%);background-image:-webkit-linear-gradient(top,#1C1F25 0,#282D33 100%);background-image:-ms-linear-gradient(top,#1C1F25 0,#282D33 100%);background-image:linear-gradient(to top,#1C1F25 0,#282D33 100%);z-index:9;padding-bottom:1.5px;color:#DDD}#tastyplug-ui a{color:inherit;text-decoration:none}.tastyplug-icon{position:relative;float:right}#tastyplug-ui .tp-toggle{color:#F04F30}#tastyplug-ui .tp-toggle.button-on{color:#1CC7ED}#tp-title{margin:0 15px;padding:3px 0;color:#A874FC;font-size:19px;cursor:pointer}.tp-mainbutton,.tp-secbutton{margin:0 15px;padding:2px 0 3px;font-size:15px;border-top:1px solid rgba(56,60,68,.85);cursor:pointer}.tp-highlight{background-color:rgba(168,116,252,.33)}.tp-secbutton{padding-left:8px}.tp-infobutt{margin:0 15px;padding:1px 0 2px;font-size:12px;border-top:1px solid rgba(56,60,68,.85);cursor:default}.tp-infobutt span{font-weight:700}.tp-infobutt .result{font-weight:400}#tastyplug-ui .icon-drag-handle{position:relative;float:right;top:3px;height:14px;width:14px;background-position:-183px -113px}#waitlist-button .eta{position:relative;top:33px;left:57px;font-size:10px}#chat-messages .tastyplug-pm .icon{top:-1px;left:-3px}#chat-pm-button{left:-3px}#chat-messages .tastyplug-pm{border-left-style:solid;border-left-width:3px;border-color:#F59425;padding-left:25px}#chat-messages .tastyplug-pm .from{color:#F59425;font-weight:700}#user-lists .list.room .user .icon-meh{left:auto;right:8px;top:-1px}#chat-messages [data-cid|="50aeafd9d6e4a94f77473433"] .icon{top:7px;left:6px;background-position:-145px -287px;width:18px;height:16px}#chat-messages [data-cid|="50aeafd9d6e4a94f77473433"].mention .icon{left:3px}#chat-messages[data-cid|="50aeafd9d6e4a94f77473433"]{background-color:#2D002D}#chat .mention:nth-child(2n+1)[data-cid|="50aeafd9d6e4a94f77473433"],#chat .message:nth-child(2n+1)[data-cid|="50aeafd9d6e4a94f77473433"],#chat-messages .emote:nth-child(2n+1)[data-cid|="50aeafd9d6e4a94f77473433"]{background-color:#240024}#chat .emote[data-cid|="50aeafd9d6e4a94f77473433"] .text,#chat .mention[data-cid|="50aeafd9d6e4a94f77473433"] .text,#chat .message[data-cid|="50aeafd9d6e4a94f77473433"] .text{font-weight:700;color:#CFCFCF}#chat .emote[data-cid|="50aeafd9d6e4a94f77473433"] .text{font-style:normal}.tp-info{border-left:3px solid #1CC7ED}#chat .update.tp-info .text{color:#1CC7ED}#chat .update.tp-info .text span{color:#EEE}.tp-error{border-left:3px solid red}#chat .update.tp-error .text{color:red}.tp-init{border-left:3px solid #D1D119}#chat .update.tp-init .text{color:#D1D119}.tp-join-admin{border-left:3px solid #1CC7ED}#chat .update.tp-join-admin .text{color:#1CC7ED}.tp-join-ba{border-left:3px solid #088C30}#chat .update.tp-join-ba .text{color:#088C30}.tp-join-host{border-left:3px solid #D1D119}#chat .update.tp-join-host .text{color:#D1D119}.tp-join-cohost{border-left:3px solid #F59425}#chat .update.tp-join-cohost .text{color:#F59425}.tp-join-staff{border-left:3px solid #C322E3}#chat .update.tp-join-staff .text{color:#C322E3}.tp-join-friend{border-left:3px solid #009CDD}#chat .update.tp-join-friend .text{color:#009CDD}.tp-img.wide{width:280px;height:auto}.tp-img.high{height:350px;width:auto}.tp-img-delete{position:absolute;top:25px;left:8px;background-color:#F04F30;padding:0 3px;cursor:pointer}.tp-video-hide{height:0!important}.custom-emote{display:inline-block;vertical-align:top}#tp-flist{position:absolute;top:54px;left:0;width:141px;height:522px;background:rgba(0,0,0,.85);background:-moz-linear-gradient(left,rgba(0,0,0,.85) 0,rgba(0,0,0,.75) 100%);background:-webkit-gradient(left top,right top,color-stop(0%,rgba(0,0,0,.85)),color-stop(100%,rgba(0,0,0,.75)));background:-webkit-linear-gradient(left,rgba(0,0,0,.85) 0,rgba(0,0,0,.75) 100%);background:-o-linear-gradient(left,rgba(0,0,0,.85) 0,rgba(0,0,0,.75) 100%);background:-ms-linear-gradient(left,rgba(0,0,0,.85) 0,rgba(0,0,0,.75) 100%);background:linear-gradient(to right,rgba(0,0,0,.85) 0,rgba(0,0,0,.75) 100%);overflow-y:scroll;font-size:13px;padding-top:8px;padding-left:8px;color:#F04F30;z-index:2}#tp-fl-title{font-size:17px;color:#A874FC;margin-bottom:5px}#tp-flist .tp-online{color:#1CC7ED}</style>');
  136.         $('body').append('<div id="tp-flist"><div id="tp-fl-title">Friends List</div></div><div id="tastyplug-ui"><div id="tp-title"> TastyPlug <img class="tastyplug-icon" src="https://fungustime.pw/tastyplug/tastyplug.png"></div><div class="tp-mainbutton tp-toggle button-on" id="tp-autowoot"><span>Autowoot</span></div><div class="tp-mainbutton tp-toggle button-on" id="tp-autojoin"><span>Autojoin</span></div><div class="tp-mainbutton tp-toggle button-on" id="tp-afkalert"><span>AFK Alert</span></div><div class="tp-mainbutton tp-toggle" id="tp-hidevideo"><span>Hide Video</span></div><div class="tp-mainbutton tp-toggle button-on" id="tp-boothalert"><span>Booth Alert</span></div><div class="tp-mainbutton tp-toggle button-on" id="tp-histalert"><span>History Alert</span></div><div class="tp-mainbutton tp-toggle button-on" id="tp-chatimgs"><span>Chat Images</span></div><div class="tp-mainbutton tp-toggle button-on" id="tp-emotes"><div class="icon icon-drag-handle"></div><span>Cust. Emotes</span></div><div class="tp-secbutton tp-secemotes tp-toggle button-on" id="tp-tastycat"><span>Tastycat</span></div><div class="tp-secbutton tp-secemotes tp-toggle button-on" id="tp-logos"><span>Logos</span></div><div class="tp-secbutton tp-secemotes tp-toggle button-on" id="tp-twitch"><span>Twitch.tv</span></div><div class="tp-secbutton tp-secemotes tp-toggle button-on" id="tp-userfaces"><span>User Faces</span></div><div class="tp-secbutton tp-secemotes tp-toggle button-on" id="tp-misc"><span>Misc. Emotes</span></div><div class="tp-secbutton tp-secemotes tp-toggle button-on" id="tp-gifs"><span>GIFs</span></div><a href="http://fungustime.pw/tastyplug/emotes" target="_blank"><div class="tp-secbutton tp-secemotes" id="tp-listemotes"><span>Emotes List</span></div></a><div class="tp-mainbutton tp-toggle button-on" id="tp-mentions"><div class="icon icon-drag-handle"></div><span>Chat Mentions</span></div><div class="tp-secbutton tp-secmention" id="tp-addmention"><span>Add</span></div><div class="tp-secbutton tp-secmention" id="tp-delmention"><span>Delete</span></div><div class="tp-secbutton tp-secmention" id="tp-listmention"><span>List</span></div><div class="tp-mainbutton tp-toggle button-on" id="tp-joinnotifs"><div class="icon icon-drag-handle"></div><span>Join Notifs.</span></div><div class="tp-secbutton tp-secjoin tp-toggle button-on" id="tp-joinranks"><span>Ranks</span></div><div class="tp-secbutton tp-secjoin tp-toggle button-on" id="tp-joinfriends"><span>Friends</span></div><div class="tp-mainbutton" id="tp-roominfo"><div class="icon icon-drag-handle"></div><span>Room Info</span></div><div class="tp-infobutt" id="tp-antiAfk"><span>AntiAFK: <span class="result">off</span></span></div><div class="tp-infobutt" id="tp-antiAfkLimit"><span>AFK Limit: <span class="result">0</span>m</span></div><div class="tp-infobutt" id="tp-lottery"><span>Lottery: <span class="result">off</span></span></div><div class="tp-infobutt" id="tp-lotTime"><span>Next Lottery: <span class="result">0</span>m</span></div><div class="tp-infobutt" id="tp-userCmds"><span>User Cmds.: <span class="result">off</span></span></div><div class="tp-infobutt" id="tp-duels"><span>Duels: <span class="result">off</span></span></div></div>');
  137.         if (location.pathname == '/tastycat/') $('#waitlist-button').append('<span class="eta" >ETA: N/A</span>');
  138.         $('#chat-header').append('<div id="chat-pm-button" class="chat-header-button"><i class="icon icon-ignore"></i></div>');
  139.         if (!settings.autowoot) $('#tp-autowoot').removeClass('button-on');
  140.         if (!settings.autojoin) $('#tp-autojoin').removeClass('button-on');
  141.         if (!settings.afkalert) $('#tp-afkalert').removeClass('button-on');
  142.         if (!settings.boothalert) $('#tp-boothalert').removeClass('button-on');
  143.         if (!settings.histalert) $('#tp-histalert').removeClass('button-on');
  144.         if (!settings.chatimgs) $('#tp-chatimgs').removeClass('button-on');
  145.         if (!settings.emotes) $('#tp-emotes').removeClass('button-on');
  146.         if (!settings.twitch) $('#tp-twitch').removeClass('button-on');
  147.         if (!settings.userfaces) $('#tp-userfaces').removeClass('button-on');
  148.         if (!settings.tastycat) $('#tp-tastycat').removeClass('button-on');
  149.         if (!settings.logos) $('#tp-logos').removeClass('button-on');
  150.         if (!settings.misc) $('#tp-misc').removeClass('button-on');
  151.         if (!settings.gifs) $('#tp-gifs').removeClass('button-on');
  152.         if (!settings.chatmentions) $('#tp-mentions').removeClass('button-on');
  153.         if (!settings.joinnotifs.toggle) $('#tp-joinnotifs').removeClass('button-on');
  154.         if (!settings.joinnotifs.ranks) $('#tp-joinranks').removeClass('button-on');
  155.         if (!settings.joinnotifs.friends) $('#tp-joinfriends').removeClass('button-on');
  156.         if (!settings.show) {
  157.             $('.tp-mainbutton').hide();
  158.             $('#tastyplug-ui').css('padding-bottom','0');
  159.         }
  160.         if (getRank(API.getUser()) < 2) $('#tp-histalert').remove();
  161.         $('.tp-secbutton,.tp-infobutt').hide();
  162.         $('#tastyplug-ui').css(settings.uipos);
  163.         for (var i in settings.friends) {
  164.             $('#tp-flist').append('<div class="tp-fl-friend ' + (API.getUser(i).username ? 'tp-online' : '') + '">' + settings.friends[i] + '</div>');
  165.         }
  166.         sortFriends();
  167.     }
  168.     function loadEvents() {
  169.         API.on({
  170.             'chat':eventChat,
  171.             'userJoin':eventJoin,
  172.             'userLeave':eventLeave,
  173.             'waitListUpdate':eventWLUpd,
  174.             'advance':eventDjAdv,
  175.             'chatCommand':eventCommand
  176.         });
  177.         $(window).resize(resize);
  178.         if (getRank(API.getUser()) >= 2) {
  179.             API.on('voteUpdate',refreshMehs);
  180.             $('#users-button:not(.selected)').click(refreshMehs);
  181.         }
  182.         //make it draggable
  183.         var dragopts = {
  184.             distance:20,
  185.             handle:'#tp-title',
  186.             snap:'#playback-container',
  187.             snapMode:'outer',
  188.             containment:'.room-background',
  189.             scroll:false,
  190.             start:function(){drag = true},
  191.             stop:function(e,ui){
  192.                 drag = false;
  193.                 settings.uipos = ui.position;
  194.                 saveSettings();
  195.             }
  196.         };
  197.         if ($.ui == undefined) {
  198.             $.getScript('https://fungustime.pw/jquery-ui-1.10.4.custom.min.js',function(){
  199.                 $('#tastyplug-ui').draggable(dragopts);
  200.             });
  201.         } else $('#tastyplug-ui').draggable(dragopts);
  202.         //quick reply to pm
  203.         $('#chat-messages').on('click','.pm-from',function(){
  204.             if ($('#chat-input-field').val()) return;
  205.             var a = '/pm @' + $(this).text();
  206.             $('#chat-input-field').val(a);
  207.             $('#chat-input-field').focus();
  208.         });
  209.         //pm button
  210.         $('#chat-pm-button i').click(function(){
  211.             if (!$('.icon-mention-off').length) return Chat('error', 'Don\'t use this button while the mentions button is on! (Button to the left)');
  212.             pms = !pms;
  213.             $('#chat-pm-button i').attr('class',(pms ? 'icon icon-unignore' : 'icon icon-ignore'));
  214.             $('#chat-messages').children().not('.tastyplug-pm').toggle();
  215.             $('#chat-messages').scrollTop(20000);
  216.         });
  217.         //highlight ui buttons
  218.         $('.tp-mainbutton,.tp-secbutton,.tp-infobutt').hover(
  219.             function(){$(this).addClass('tp-highlight')},
  220.             function(){$(this).removeClass('tp-highlight')}
  221.         );
  222.         //tp title
  223.         $('#tp-title').mouseup(function(){
  224.             if (!drag) {
  225.                 settings.show = !settings.show;
  226.                 if (!settings.show) {
  227.                     $('#tastyplug-ui').css('padding-bottom','0');
  228.                     $('.tp-mainbutton').css('border-top','0');
  229.                     $('.tp-secbutton').css('border-top','0');
  230.                 }
  231.                 $('#tastyplug-ui .tp-mainbutton').slideToggle(function(){
  232.                     if (settings.show) {
  233.                         $('#tastyplug-ui').css('padding-bottom','');
  234.                         $('.tp-mainbutton').css('border-top','');
  235.                         $('.tp-secbutton').css('border-top','');
  236.                     }
  237.                 });
  238.                 $('.tp-secbutton,.tp-infobutt').slideUp();
  239.                 saveSettings();
  240.             }
  241.         });
  242.         //tp autowoot
  243.         $('#tp-autowoot').click(function(){
  244.             settings.autowoot = !settings.autowoot;
  245.             $(this).toggleClass('button-on');
  246.             if (settings.autowoot) woot();
  247.             saveSettings();
  248.         });
  249.         //autojoin
  250.         $('#tp-autojoin').click(function(){
  251.             settings.autojoin = !settings.autojoin;
  252.             $(this).toggleClass('button-on');
  253.             if (settings.autojoin && !getLocked() && API.getWaitListPosition() == -1) API.djJoin();
  254.             afkCheck();
  255.             saveSettings();
  256.         });
  257.         //afk alert
  258.         $('#tp-afkalert').click(function(){
  259.             settings.afkalert = !settings.afkalert;
  260.             $(this).toggleClass('button-on');
  261.             saveSettings();
  262.         });
  263.         //hide video
  264.         $('#tp-hidevideo').click(function(){
  265.             hidevideo = !hidevideo;
  266.             $('#playback-container').toggleClass('tp-video-hide');
  267.             $('#playback').toggleClass('tp-video-hide');
  268.             $('.background').toggle();
  269.             $(this).toggleClass('button-on');
  270.         });
  271.         //booth alert
  272.         $('#tp-boothalert').click(function(){
  273.             settings.boothalert = !settings.boothalert;
  274.             $(this).toggleClass('button-on');
  275.             saveSettings();
  276.         });
  277.         //history alert
  278.         $('#tp-histalert').click(function(){
  279.             settings.histalert = !settings.histalert;
  280.             $(this).toggleClass('button-on');
  281.             saveSettings();
  282.         });
  283.         //chat images
  284.         $('#tp-chatimgs').click(function(){
  285.             settings.chatimgs = !settings.chatimgs;
  286.             $(this).toggleClass('button-on');
  287.             saveSettings();
  288.         });
  289.         //custom emotes
  290.         $('#tp-emotes span').click(function(){
  291.             settings.emotes = !settings.emotes;
  292.             $(this).parent().toggleClass('button-on');
  293.             saveSettings();
  294.         });
  295.         $('#tp-tastycat').click(function(){
  296.             settings.tastycat = !settings.tastycat;
  297.             $(this).toggleClass('button-on');
  298.             saveSettings();
  299.         });
  300.         $('#tp-logos').click(function(){
  301.             settings.logos = !settings.logos;
  302.             $(this).toggleClass('button-on');
  303.             saveSettings();
  304.         });
  305.         $('#tp-twitch').click(function(){
  306.             settings.twitch = !settings.twitch;
  307.             $(this).toggleClass('button-on');
  308.             saveSettings();
  309.         });
  310.         $('#tp-userfaces').click(function(){
  311.             settings.userfaces = !settings.userfaces;
  312.             $(this).toggleClass('button-on');
  313.             saveSettings();
  314.         });
  315.         $('#tp-misc').click(function(){
  316.             settings.misc = !settings.misc;
  317.             $(this).toggleClass('button-on');
  318.             saveSettings();
  319.         });
  320.         $('#tp-gifs').click(function(){
  321.             settings.gifs = !settings.gifs;
  322.             $(this).toggleClass('button-on');
  323.             saveSettings();
  324.         });
  325.         $('#tp-emotes .icon-drag-handle').click(function(){
  326.             $('.tp-secemotes').slideToggle();
  327.         });
  328.         //chat mentions
  329.         $('#tp-mentions span').click(function(){
  330.             settings.chatmentions = !settings.chatmentions;
  331.             $(this).parent().toggleClass('button-on');
  332.             saveSettings();
  333.         });
  334.         $('#tp-addmention').click(function(){
  335.             var len = settings.msgs.length;
  336.             var a = prompt('Add words to the chat mentions list! Separate them with a comma.').trim().split(',');
  337.             if (!a) return Chat('error', 'Please enter at least one word!');
  338.             for (var i = 0; i < a.length; i++) {
  339.                 a[i] = a[i].trim().toLowerCase();
  340.                 if (a[i].length < 3) Chat('error', 'Did not add: ' + _.escape(a[i]) + ' (too short)');
  341.                 else if (settings.msgs.indexOf(a[i]) > -1) Chat('error', 'Did not add: ' + _.escape(a[i]) + ' (already on list)');
  342.                 else settings.msgs.push(a[i]);
  343.             }
  344.             if (settings.msgs.length > len) {
  345.                 Chat('info', 'Added word(s) to chat mentions list');
  346.                 saveSettings();
  347.             }
  348.         });
  349.         $('#tp-delmention').click(function(){
  350.             var a = prompt('Which word would you like to remove from the mentions list?');
  351.             if (settings.msgs.indexOf(a) > -1) {
  352.                 settings.msgs.splice(settings.msgs.indexOf(a),1);
  353.                 Chat('info', 'Removed "' + _.escape(a) + '" from the chat mentions list');
  354.                 saveSettings();
  355.             } else Chat('error', 'That word isn\'t in the mentions list!');
  356.         });
  357.         $('#tp-listmention').click(function(){
  358.             var a = settings.msgs;
  359.             for (var i = 0; i < a.length; i++) a[i] = _.escape(a[i]);
  360.             if (a.length) return Chat('info', 'Chat mentions list:<br>' + a.join('<br>'));
  361.             return Chat('error', 'You don\'t have anything in your chat mentions list!');
  362.         });
  363.         $('#tp-mentions .icon-drag-handle').click(function(){
  364.             $('.tp-secmention').slideToggle();
  365.         });
  366.         //join notifs
  367.         $('#tp-joinnotifs span').click(function(){
  368.             settings.joinnotifs.toggle = !settings.joinnotifs.toggle;
  369.             $(this).parent().toggleClass('button-on');
  370.             saveSettings();
  371.         });
  372.         $('#tp-joinranks').click(function(){
  373.             settings.joinnotifs.ranks = !settings.joinnotifs.ranks;
  374.             $(this).toggleClass('button-on');
  375.             saveSettings();
  376.         });
  377.         $('#tp-joinfriends').click(function(){
  378.             settings.joinnotifs.friends = !settings.joinnotifs.friends;
  379.             $(this).toggleClass('button-on');
  380.             saveSettings();
  381.         });
  382.         $('#tp-joinnotifs .icon-drag-handle').click(function(){
  383.             $('.tp-secjoin').slideToggle();
  384.         });
  385.         //room info
  386.         $('#tp-roominfo').click(function(){
  387.             $('.tp-infobutt').slideToggle();
  388.         });
  389.     }
  390.     function loadEmotes() {
  391.         $.ajax({
  392.             cache: false,
  393.             url: "https://fungustime.pw/tastyplug/emotes/json/emotes.json",
  394.             dataType: "json",
  395.             success: function(a){emotes=a},
  396.             error: function(){Chat('error','Could not load custom emotes. Refresh and/or try again later.')}
  397.         });
  398.     }
  399.     tastyPlugShutDown = function() {
  400.         API.off({
  401.             'chat':eventChat,
  402.             'userJoin':eventJoin,
  403.             'userLeave':eventLeave,
  404.             'waitListUpdate':eventWLUpd,
  405.             'advance':eventDjAdv,
  406.             'chatCommand':eventCommand,
  407.             'voteUpdate':refreshMehs
  408.         });
  409.         $(window).off('resize',resize);
  410.         $('#users-button').off('click',refreshMehs);
  411.         $('#chat-messages .pm-from').off('click');
  412.         $('.tp-img-delete').off('click');
  413.         $('#chat-messages .message,#chat-messages .mention,#chat-messages .emote').has('img').off('mouseenter mouseleave');
  414.         $('#chat-pm-button').remove();
  415.         $('#waitlist-button').find('.eta').remove();
  416.         $('#playback-container').removeClass('tp-video-hide');
  417.         $('.background').show();
  418.         $('#playback').removeClass('tp-video-hide');
  419.         $('#tastyplug-ui').remove();
  420.         $('#tastyplug-css').remove();
  421.         $('#tp-flist').remove();
  422.         $('#chat-popout-button').show();
  423.         reconnect = false;
  424.         for (var i in tos) clearInterval(tos[i]);
  425.         saveSettings();
  426.         if (sock) sock.close();
  427.         console.log('[TastyPlug v' + version + '] Shut down.');
  428.     };
  429.     function eventChat(a) {
  430.         if (!a.cid) return;
  431.         var msg = $('#chat-messages').children('[data-cid="' + a.cid + '"]');
  432.         if (pms && !msg.hasClass('.tastyplug-pm')) msg.hide();
  433.         if (settings.emotes) custEmotes(msg.find('.text'));
  434.         if (settings.chatimgs) {
  435.             var txt = msg.find('.text'), txts = txt.text().trim().split(' ');
  436.             for (var i = 0; i < txts.length; i++) if (/.(gif|png|jpg)/i.test(txts[i]) && /^https?:\/\//.test(txts[i])) return checkImg(txts[i],txt);
  437.         }
  438.         var b = document.createElement('div');
  439.         b.innerHTML = a.message;
  440.         var message = b.textContent.replace(/  +/g, ' ').trim();
  441.         if (a.uid == API.getUser().id) {
  442.             afktime = Date.now();
  443.             clearInterval(tos.afkalert);
  444.             if (API.getUser().status == 1) API.setStatus(0);
  445.             if (!message.toLowerCase().indexOf('!afk')) API.setStatus(1);
  446.         }
  447.         if (!settings.chatmentions || a.uid == API.getUser().id) return;
  448.         b = message.toLowerCase().split(' ');
  449.         for (var i = 0; i < settings.msgs.length; i++) {
  450.             if (b.indexOf(settings.msgs[i]) > -1) return chatSound();
  451.         }
  452.     }
  453.     function eventJoin(a) {
  454.         if (!settings.joinnotifs.toggle || !a.username || (!settings.joinnotifs.ranks && !settings.joinnotifs.friends)) return;
  455.         var b, rank = getRank(a);
  456.         if (rank) switch (rank) {
  457.             case 10: b = 'admin'; break;
  458.             case 8: b = 'ba'; break;
  459.             case 5: b = 'host'; break;
  460.             case 4: b = 'cohost'; break;
  461.             case 3:case 2:case 1: b = 'staff'; break;
  462.             default: b = 'undef'; break;
  463.         }
  464.         else if (settings.joinnotifs.friends && settings.friends[a.id]) b = 'friend';
  465.         if (b) Chat('join-' + b, _.escape(a.username) + ' joined the room');
  466.         if (a.id in settings.friends) {
  467.             $('.tp-fl-friend').filter(function(){return $(this).text() == a.username}).addClass('tp-online');
  468.             sortFriends();
  469.         }
  470.     }
  471.     function eventLeave(a) {
  472.         if (a.id in settings.friends) {
  473.             $('.tp-fl-friend.tp-online').filter(function(){return $(this).text() == a.username}).removeClass('tp-online');
  474.             sortFriends();
  475.         }
  476.     }
  477.     function eventWLUpd() {
  478.         if (settings.autojoin && !getLocked() && API.getWaitListPosition() == -1) API.djJoin();
  479.         if (settings.boothalert && API.getWaitListPosition() < 3 && API.getWaitListPosition() != -1 && !boothcd) {
  480.             chatSound();
  481.             Chat('info','[Booth Alert] It\'s almost your turn to DJ! Make sure to pick a song!');
  482.             boothcd = true;
  483.         }
  484.     }
  485.     function eventDjAdv(a) {
  486.         if (settings.autojoin && !getLocked() && API.getWaitListPosition() == -1) API.djJoin();
  487.         if (settings.autowoot) setTimeout(woot,(Math.floor(Math.random()*10)+1)*1000);
  488.         if (hidevideo) $('#tp-hidevideo').click();
  489.         if (a.dj.id == API.getUser().id) boothcd = false;
  490.         if (settings.histalert && getRank(API.getUser()) >= 2 && a.media) {
  491.             var hist = API.getHistory();
  492.             for (var i = 0; i < hist.length; i++) {
  493.                 if (hist[i].media.id == a.media.id) {
  494.                     chatSound();
  495.                     Chat('error','This song is on the history! (played ' + (i + 1) + ' song' + (i == 0 ? '' : 's') + ' ago)');
  496.                     break;
  497.                 }
  498.             }
  499.         }
  500.     }
  501.     function eventCommand(a) {
  502.         var cmd = a.trim().substr(1).split(' ')[0].toLowerCase();
  503.         if (cmd == 'afk' || cmd == 'away') API.setStatus(1);
  504.         else if (cmd == 'work' || cmd == 'working') API.setStatus(2);
  505.         else if (cmd == 'gaming' || cmd == 'game' || cmd == 'ingame') API.setStatus(3);
  506.         var data = {
  507.             uid: API.getUser().id,
  508.             un: API.getUser().username,
  509.             message: a.trim(),
  510.             room: location.pathname
  511.         }, a;
  512.         if (commands[cmd]) a = commands[cmd](data);
  513.         else if (location.pathname == '/tastycat/' && sock.readyState == 1) {
  514.             sock.msg({z:'command',a:data});
  515.             a = true;
  516.         }
  517.         if (a) {
  518.             cd = true;
  519.             setTimeout(function(){cd = false},2E3);
  520.         }
  521.     }
  522.     function refreshMehs() {
  523.         if ($('#users-button').hasClass('selected') && $('.button.room').hasClass('selected')) {
  524.             $('#user-lists .list.room i.icon.icon-meh').remove();
  525.             var users = $(API.getUsers()).filter(function(){return this.vote == -1 && !this.curated;});
  526.             users.each(function(i){
  527.                 $('#user-lists .list.room .user span').filter(function(){return $(this).text()==users[i].username;}).parent().append('<i class="icon icon-meh"></i>');
  528.             });
  529.         }
  530.     }
  531.     commands.lock = function() {
  532.         if (getRank(API.getUser()) < 3) return;
  533.         API.moderateLockWaitList(true);
  534.     };
  535.     commands.unlock = function() {
  536.         if (getRank(API.getUser()) < 3) return;
  537.         API.moderateLockWaitList(false);
  538.     };
  539.     commands.cycle = function() {
  540.         if (getRank(API.getUser()) < 3) return;
  541.         $('.cycle-toggle').click();
  542.     };
  543.     commands.ban = function(a) {
  544.         if (getRank(API.getUser()) < 3) return;
  545.         var user = getUser(a.message.substr(a.message.indexOf('@')+1));
  546.         if (!user) return Chat('error', 'User not found.');
  547.         if (getRank(API.getUser()) <= getRank(user)) return Chat('error', 'You can\'t ban people who are of equal or higher rank as you!');
  548.         API.moderateBanUser(user.id,0,API.BAN.PERMA);
  549.     };
  550.     commands.kick = function(a) {
  551.         if (getRank(API.getUser()) < 2) return;
  552.         var msg = a.message.split(' '), user, dur;
  553.         if (msg[msg.length-1] != 'day' && msg[msg.length-1] != 'hour') {
  554.             user = getUser(a.message.substr(a.message.indexOf('@')+1));
  555.             dur = API.BAN.HOUR;
  556.         } else {
  557.             user = getUser(msg.slice(1,msg.length-1).join(' ').substr(1));
  558.             dur = msg[msg.length-1] == 'day' ? API.BAN.DAY : API.BAN.HOUR;
  559.         }
  560.         if (!user) return Chat('error', 'User not found.');
  561.         if (getRank(API.getUser()) <= getRank(user)) return Chat('error', 'You can\'t kick people who are of equal or higher rank as you!');
  562.         API.moderateBanUser(user.id,0,dur);
  563.     };
  564.     commands.skip = function() {
  565.         if (getRank(API.getUser()) < 2) return;
  566.         API.moderateForceSkip();
  567.     };
  568.     commands.pm = function(a) {
  569.         if (cd) return Chat('error', 'PMs have a 2 second slow-mode!');
  570.         if (!sock.connected) return Chat('error', 'Not connected to TastyPlug\'s server!');
  571.         if (a.message.split(' ').length == 1) return Chat('info', 'Usage: /pm @user message<br>Sends a private message to the user if they are using Tastyplug and you are each other\'s fans');
  572.         var str = a.message.split(' '), msg = str.slice(2).join(' '), user = getUser(str[1].substr(1));
  573.         if (!user) return Chat('error', 'User not found.');
  574.         if (user.id == API.getUser().id) return Chat('error', 'You can\'t PM yourself!');
  575.         if (!msg) return Chat('error', 'Please input a message to send!');
  576.         sock.msg({z:'pm',m:msg,f:API.getUser(),t:user})
  577.         ChatPM('To: ' + user.username,msg);
  578.         return true;
  579.     };
  580.     commands.r = function(a) {
  581.         if (settings.lastPM) eventCommand('/pm @' + settings.lastPM + ' ' + a.message.split(' ').slice(1).join(' '));
  582.         else Chat('error', 'Nobody has PMed you yet!');
  583.     };
  584.     commands.opcheck = function(a) {
  585.         if (cd) return Chat('error', '/opcheck has a 2 second slow-mode!');
  586.         if (location.pathname != '/tastycat/') return;
  587.         if (!sock.connected) return Chat('error', 'Not connected to TastyPlug\'s server!');
  588.         var b = API.getNextMedia().media;
  589.         sock.msg({z:'songcheck',id:b.id,song:'Next on your playlist',author:b.author,title:b.title});
  590.         return true;
  591.     };
  592.     commands.reset = function() {
  593.         Chat('init', 'Reloading...');
  594.         setTimeout(function(){$.getScript('https://fungustime.pw/tastyplug/tastyplug.js')},1000);
  595.     };
  596.     commands.commands = function() {
  597.         if (location.pathname == '/tastycat/') Chat('info', 'TastyBot commands: <a href="https://fungustime.pw/tastybot" target="_blank">Click Here</a>');
  598.         Chat('info', 'TastyPlug commands: ' + Object.keys(commands).join(', '));
  599.     };
  600.     commands.whois = function(a) {
  601.         var user = getUser(a.message.split(' ').slice(1).join(' ').substr(1)), rank;
  602.         if (!user) return Chat('error','User not found.');
  603.         var pos = API.getWaitListPosition(user.id);
  604.         switch (getRank(user)) {
  605.             case 10: rank = 'plug.dj Admin'; break;
  606.             case 8: rank = 'Brand Ambassador'; break;
  607.             case 5: rank = 'Host'; break;
  608.             case 4: rank = 'Co-Host'; break;
  609.             case 3: rank = 'Manager'; break;
  610.             case 2: rank = 'Bouncer'; break;
  611.             case 1: rank = 'Resident DJ'; break;
  612.             case 0: rank = 'User'; break;
  613.             default: rank = 'Unknown';
  614.         }
  615.         if (API.getDJ().id == user.id) pos = 'Currently DJing';
  616.         else if (pos == -1) pos = 'Not on list';
  617.         else pos++;
  618.         Chat('info','Username: <span>' + user.username + '</span><br>ID: <span>' + user.id +
  619.             '</span><br>Rank: <span>' + rank + '</span><br>Level: <span>' + user.level + '</span><br>Wait List: <span>' + pos + '</span>');
  620.     };
  621.     commands.link = function() {
  622.         var b = API.getMedia();
  623.         if (b.format == '1') Chat('info', 'Current song: <a href="http://youtu.be/' + b.cid + '" target="_blank">Click Here</a>');
  624.         else SC.get('/tracks/' + b.cid, function(c) {
  625.             Chat('info', 'Current song: ' + (c.permalink_url ? ('<a href="' + c.permalink_url + '" target="_blank">Click Here') : 'Link not found'));
  626.         });
  627.     };
  628.     commands.addfriend = function(a) {
  629.         var user = getUser(a.message.split(' ').slice(1).join(' ').substr(1));
  630.         if (!user) return Chat('error', 'User not found.');
  631.         if (user.id in settings.friends) return Chat('error', user.username + ' is already on your Friends list!');
  632.         settings.friends[user.id] = user.username;
  633.         $('#tp-flist').append('<div class="tp-fl-friend tp-online">' + user.username + '</div>');
  634.         sortFriends();
  635.         Chat('info', 'Added ' + user.username + ' to your Friends list.');
  636.         saveSettings();
  637.     };
  638.     commands.removefriend = function(a) {
  639.         var user = a.message.split(' ').slice(1).join(' ').substr(1).toLowerCase();
  640.         for (var i in settings.friends) {
  641.             if (settings.friends[i].toLowerCase() == user) {
  642.                 Chat('info', 'Removed ' + user + ' from your Friends list.');
  643.                 delete settings.friends[i];
  644.                 var friends = $('.tp-fl-friend');
  645.                 for (var i = 0; i < friends.length; i++) {
  646.                     if (friends[i].innerText.toLowerCase() == user) {
  647.                         $(friends[i]).remove();
  648.                         sortFriends();
  649.                         break;
  650.                     }
  651.                 }
  652.                 return saveSettings();
  653.             }
  654.         }
  655.         Chat('error', user + ' isn\'t on your Friends list.');
  656.     };
  657.     commands.uireset = function() {
  658.         settings.uipos = {'top':'54px','left':'0'};
  659.         $('#tastyplug-ui').css(settings.uipos);
  660.         saveSettings();
  661.         Chat('info', 'UI position reset');
  662.     };
  663.     commands.hidden = function() {
  664.         settings.hidden = !settings.hidden;
  665.         saveSettings();
  666.         Chat('info', 'Hidden emotes ' + (settings.hidden ? 'enabled!' : 'disabled!'));
  667.     };
  668.     function Chat(type, m) {
  669.         if ($('#chat-button').css('display') == 'block') {
  670.             var chat = $('#chat-messages'), a = chat.scrollTop() > chat[0].scrollHeight - chat.height() - 28;
  671.             chat.append('<div class="update tp-' + type + '"><span class="text">' + m + '</span></div>');
  672.             if (a) chat.scrollTop(chat[0].scrollHeight);
  673.             if (chat.children().length >= 512) chat.children().first().remove();
  674.         } else API.chatLog(m.replace(/<br>/g,', '),true);
  675.     }
  676.     function ChatPM(user, msg) {
  677.         if ($('#chat-button').css('display') == 'block') {
  678.             var chat = $('#chat-messages'), a = chat.scrollTop() > chat[0].scrollHeight - chat.height() - 28,
  679.             c = !user.indexOf('To: ') ? '-to' : '-from clickable',
  680.             d = $('#chat-timestamp-button .icon').attr('class').substr(21),
  681.             e = d == 'off' ? 'none' : 'block',
  682.             f = new Date().toTimeString().substr(0,5), j = false,
  683.             k = !user.indexOf('To: ') ? ' message' : ' mention';
  684.             if (d == '12') {
  685.                 var g = parseInt(f),
  686.                     h = g >= 12 ? 'pm' : 'am',
  687.                     i = g%12 == 0 ? '12' : g%12;
  688.                 f = i + f.substr(2) + h;
  689.             }
  690.             if (f.charAt(0) == '0') f = f.substr(1);
  691.             msg = urlFix(_.escape(msg));
  692.             if (!msg.indexOf('&#x2F;me')) { msg = msg.replace('&#x2F;me','<em>'); j = true; }
  693.             else if (!msg.indexOf('&#x2F;em')) { msg = msg.replace('&#x2F;em','<em>'); j = true; }
  694.             j = j ? '' : '&nbsp;';
  695.             chat.append('<div class="tastyplug-pm' + k + '"><i class="icon icon-ignored"></i><div class="timestamp" style="display:' + e + '">' + f + '</div><span class="from pm' + c + '">' + user + ' </span><span class="text">' + j + msg + '</span></div>');
  696.             if (a) chat.scrollTop(chat[0].scrollHeight);
  697.             if (chat.children().length >= 512) chat.children().first().remove();
  698.         } else API.chatLog('[PM] ' + user + ': ' + msg);
  699.     }
  700.     function eta() {
  701.         tos.eta = setInterval(function(){
  702.             var pos = API.getWaitListPosition(), str = 'ETA: ';
  703.             str += pos == -1 ? 'N/A' : getTime(pos*1000*60*(25/6) + API.getTimeRemaining()*1000);
  704.             $('#waitlist-button').find('.eta').text(str);
  705.         },10000);
  706.     }
  707.     function resize() {
  708.         var room = $('.room-background'), rpos = room.position(), rwidth = room.width(), rheight = room.height(),
  709.             ui = $('#tastyplug-ui'), uipos = ui.position(), uiwidth = ui.width(), uiheight = ui.height(), a = Object.keys(rpos);
  710.         for (var i = 0; i < a.length; i++) if (uipos[a[i]] < rpos[a[i]]) ui.css({i:rpos[a[i]]});
  711.         if (uiwidth + uipos.left > rwidth) ui.css({'left':rwidth-uiwidth});
  712.         if (uiheight + uipos.top > rheight) ui.css({'top':rheight-uiheight});
  713.         settings.uipos = ui.position();
  714.         saveSettings();
  715.     }
  716.     function getUser(a) {
  717.         a = a.trim();
  718.         var b = API.getUsers();
  719.         for (var i = 0; i < b.length; i++) if (b[i].username == a) return b[i];
  720.         return null;
  721.     }
  722.     function getTime(a) {
  723.         a = Math.floor(a/60000);
  724.         var minutes = (a-Math.floor(a/60)*60);
  725.         var hours = (a-minutes)/60;
  726.         var str = '';
  727.         str += hours + 'h';
  728.         str += minutes<10?'0':'';
  729.         str += minutes;
  730.         return str;
  731.     }
  732.     function getRank(a) {
  733.         if (a.gRole) switch (a.gRole) {
  734.             case 5: return 10;
  735.             case 4:case 3:case 2: return 8;
  736.             default:return 6;
  737.         }
  738.         return a.role;
  739.     }
  740.     function urlFix(a) {
  741.         if (a.indexOf('http') == -1) return a;
  742.         a = a.split(' ');
  743.         for (var i = 0; i < a.length; i++) if (!a[i].indexOf('http')) a[i] = '<a href="' + a[i] + '" target="_blank">' + a[i] + '</a>';
  744.         return a.join(' ');
  745.     }
  746.     function afkCheck() {
  747.         if (settings.autojoin) tos.afkInt = setInterval(function(){
  748.             if (Date.now() - afktime >= 12E5) {
  749.                 settings.autojoin = false;
  750.                 $('#tp-autojoin').removeClass('button-on');
  751.                 clearInterval(tos.afkInt);
  752.             }
  753.         },6E4);
  754.         else clearInterval(tos.afkInt);
  755.     }
  756.     function checkImg(a,b) {
  757.         var img = new Image();
  758.         img.onload =  function() {
  759.             img.className += 'tp-img';
  760.             if (img.height > 350 && 280*img.height/img.width > 350) return;
  761.             if (img.width > 280) img.className += ' wide';
  762.             else if (img.height > 350) img.className += ' high';
  763.             var c = b.html().replace('<a href="' + a + '" target="_blank">' + a + '</a>', '<br><a href="' + a + '" target="_blank">' + img.outerHTML + '</div></a>');
  764.             b.parent().append('<div class="tp-img-delete" style="display:none">X</div>');
  765.             b.parent().hover(
  766.                 function(){$(this).find('.tp-img-delete').css('display','block')},
  767.                 function(){$(this).find('.tp-img-delete').css('display','none')}
  768.             );
  769.             b.parent().find('.tp-img-delete').click(function(){
  770.                 var a = $(this).parent().find('img')[0].src;
  771.                 $(this).parent().find('br').remove();
  772.                 $(this).parent().find('img').parent().append(a).find('img').remove();
  773.                 $(this).remove();
  774.             });
  775.             var chat = $('#chat-messages'), d = chat.scrollTop() > chat[0].scrollHeight - chat.height() - 28;
  776.             b.html(c);
  777.             if (d) chat.scrollTop(chat[0].scrollHeight);
  778.         };
  779.         img.src = a;
  780.     }
  781.     function custEmotes(a) {
  782.         if (!emotes) return;
  783.         var b = a.html();
  784.         if (typeof b != 'string') return;
  785.         var c = b.toLowerCase(), chat = $('#chat-messages'), d = chat.scrollTop() > chat[0].scrollHeight - chat.height() - 28;
  786.         for (var i in emotes) {
  787.             if (settings[i]) {
  788.                 for (var j in emotes[i]) {
  789.                     if (emotes[i][j].hidden && !settings.hidden) continue;
  790.                     var k = ':' + j.toLowerCase() + ':';
  791.                     if (c.indexOf(k) > -1) b = b.replace(new RegExp(k,'gi'),'<div class="custom-emote" ' + (emotes[i][j].hidden ? '' : 'title=":' + j + ':" ') + 'style="background-image:url(' + emotes[i][j].url + ');width:' + emotes[i][j].width + ';height:' + emotes[i][j].height + ';"></div>');
  792.                 }
  793.             }
  794.         }
  795.         a.html(b);
  796.         if (d) chat.scrollTop(chat[0].scrollHeight);
  797.     }
  798.     function sortFriends() {
  799.         var a = $('.tp-fl-friend').sort(function(a,b){
  800.             if (a.className == b.className) {
  801.                 return a.innerText.toLowerCase() > b.innerText.toLowerCase();
  802.             } else return a.className < b.className;
  803.         });
  804.         $('#tp-flist').append(a);
  805.     }
  806.     function saveSettings(){localStorage.setItem('tastyPlugSettings',JSON.stringify(settings))}
  807.     function getLocked(){return $('.lock-toggle .icon').hasClass('icon-locked')}
  808.     function chatSound(){document.getElementById('chat-sound').playChatSound()}
  809.     function woot(){$('#woot').click()}
  810.     var z = function() {
  811.         if (typeof API === 'undefined') setTimeout(z,200);
  812.         else startup();
  813.     };
  814.     z();
  815. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement