mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-06-28 05:15:54 +00:00
4 lines
No EOL
120 KiB
JavaScript
4 lines
No EOL
120 KiB
JavaScript
!function(e){!function t(e,s,n){function o(a,r){if(!s[a]){if(!e[a]){var c="function"==typeof require&&require;if(!r&&c)return c(a,!0);if(i)return i(a,!0);throw new Error("Cannot find module '"+a+"'")}var l=s[a]={exports:{}};e[a][0].call(l.exports,function(t){var s=e[a][1][t];return o(s?s:t)},l,l.exports,t,e,s,n)}return s[a].exports}for(var i="function"==typeof require&&require,a=0;a<n.length;a++)o(n[a]);return o}({1:[function(t){var s=e.FrankerFaceZ,n=t("./constants"),o=t("./utils");s.settings_info.show_badges={type:"boolean",value:!0,category:"Chat",name:"Additional Badges",help:"Show additional badges for bots, FrankerFaceZ donors, and other special users."},s.prototype.setup_badges=function(){this.log("Preparing badge system."),this.badges={},this.log("Creating badge style element.");var e=this._badge_style=document.createElement("style");e.id="ffz-badge-css",document.head.appendChild(e),this.log("Adding legacy donor badges."),this._legacy_add_donors()},s.ws_commands.reload_badges=function(){this._legacy_load_bots(),this._legacy_load_donors()},s.ws_commands.set_badge=function(e){var t=e[0],s=e[1],n=e[2],o=this.users[t]=this.users[t]||{},i=o.badges=o.badges||{};void 0===n?delete i[s]:i[s]=n};var i=function(e){return".badges .ffz-badge-"+e.id+" { background-color: "+e.color+'; background-image: url("'+e.image+'"); '+(e.extra_css||"")+"}"};s.prototype.bttv_badges=function(e){if(this.settings.show_badges){var t=e.sender,s=this.users[t],n=[],o=-1,i=BetterTTV.settings.get("alphaTags");if(s&&s.badges){for(var a=0;a<e.badges.length;a++){var r=e.badges[a];if("subscriber"==r.type||"turbo"==r.type){o=a;break}}for(var c in s.badges)if(s.badges.hasOwnProperty(c)){var r=s.badges[c],l=this.badges[r.id]||{},h=r.title||l.title,u="";if(void 0!==l.visible){var d=l.visible;if("function"==typeof d&&(d=d.bind(this)(null,t)),!d)continue}if(l.replaces){for(var f=!1,a=0;a<e.badges.length;a++){var _=e.badges[a];if(_.type==l.replaces){_.type="ffz-badge-replacement "+_.type,_.description+=", "+(r.title||l.title)+'" style="background-image: url("'+(r.image||l.image)+"")",f=!0;break}}if(f)continue}r.image&&(u+="background-image: url(""+r.image+""); "),r.color&&!i&&(u+="background-color: "+r.color+"; "),r.extra_css&&(u+=r.extra_css),u&&(h+='" style="'+u),n.push([(-1==o?1:-1)*c,{type:"ffz-badge-"+r.id+(i?" alpha":""),name:"",description:h}])}if(n.sort(function(e,t){return e[0]-t[0]}),-1==o)for(;n.length;)e.badges.push(n.shift()[1]);else for(;n.length;)e.badges.insertAt(o,n.shift()[1])}}},s.prototype.render_badge=function(e){if(this.settings.show_badges){var t=e.get("msgObject.from"),s=App.__container__.lookup("controller:chat").get("currentRoom.id"),n=e.$(".badges"),o=this.users[t];if(o&&o.badges){if(!n.length){var i=document.createElement("span"),a=e.$(".from");if(i.className="badges float-left",!a)return;a.before(i),n=$(i)}var r=n.find(".badge").filter(function(){var e=this.title.toLowerCase();return"subscriber"==e||"turbo"==e}).first(),c=[],l=!!r.length;for(var h in o.badges)if(o.badges.hasOwnProperty(h)){var u=o.badges[h],d=this.badges[u.id]||{};if(void 0!==d.visible){var f=d.visible;if("function"==typeof f&&(f=f.bind(this)(s,t)),!f)continue}if(d.replaces){var _=n[0].querySelector(".badge."+d.replaces);if(_){_.style.backgroundImage='url("'+(u.image||d.image)+'")',_.classList.add("ffz-badge-replacement"),_.title+=", "+(u.title||d.title);continue}}var _=document.createElement("div");_.className="badge float-left tooltip ffz-badge-"+u.id,_.setAttribute("title",u.title||d.title),u.image&&(_.style.backgroundImage='url("'+u.image+'")'),u.color&&(_.style.backgroundColor=u.color),u.extra_css&&(_.style.cssText+=u.extra_css),c.push([(l?1:-1)*h,_])}if(c.sort(function(e,t){return e[0]-t[0]}),l)for(;c.length;)n.before(c.shift()[1]);else for(;c.length;)n.append(c.shift()[1])}}},s.bttv_known_bots=["nightbot","moobot","sourbot","xanbot","manabot","mtgbot","ackbot","baconrobot","tardisbot","deejbot","valuebot","stahpbot"],s.prototype._legacy_add_donors=function(){this.badges[0]={id:0,title:"FFZ Developer",color:"#FAAF19",image:"//cdn.frankerfacez.com/script/devicon.png"},o.update_css(this._badge_style,0,i(this.badges[0])),this.badges[1]={id:1,title:"FFZ Donor",color:"#755000",image:"//cdn.frankerfacez.com/script/donoricon.png"},o.update_css(this._badge_style,1,i(this.badges[1])),this.badges[2]={id:2,title:"Bot",color:"#595959",image:"//cdn.frankerfacez.com/script/boticon.png",replaces:"moderator",visible:function(e,t){return!(this.has_bttv&&-1!==s.bttv_known_bots.indexOf(t))}},o.update_css(this._badge_style,2,i(this.badges[2]));for(var e=0;e<s.bttv_known_bots.length;e++){var t=s.bttv_known_bots[e],n=this.users[t]=this.users[t]||{},a=n.badges=n.badges||{};a[0]||(a[0]={id:2})}this.users.sirstendec={badges:{1:{id:0}},sets:[4330]},this.users.zenwan={badges:{0:{id:2,image:"//cdn.frankerfacez.com/script/momiglee_badge.png",title:"WAN"}}},this._legacy_load_bots(),this._legacy_load_donors()},s.prototype._legacy_load_bots=function(e){jQuery.ajax(n.SERVER+"script/bots.txt",{cache:!1,context:this}).done(function(e){this._legacy_parse_badges(e,0,2)}).fail(function(t){404!=t.status&&(e=(e||0)+1,10>e&&this._legacy_load_bots(e))})},s.prototype._legacy_load_donors=function(e){jQuery.ajax(n.SERVER+"script/donors.txt",{cache:!1,context:this}).done(function(e){this._legacy_parse_badges(e,1,1)}).fail(function(t){return 404!=t.status?(e=(e||0)+1,10>e?this._legacy_load_donors(e):void 0):void 0})},s.prototype._legacy_parse_badges=function(e,t,s){var n=this.badges[s].title,i=0;if(ds=null,null!=e)for(var a=e.trim().split(/\W+/),r=0;r<a.length;r++){var c=a[r],l=this.users[c]=this.users[c]||{},h=l.badges=l.badges||{},u=l.sets=l.sets||[];null!==ds&&-1===u.indexOf(ds)&&u.push(ds),h[t]||(h[t]={id:s},i+=1)}this.log('Added "'+n+'" badge to '+o.number_commas(i)+" users.")}},{"./constants":3,"./utils":29}],2:[function(){var t=e.FrankerFaceZ;t.ffz_commands.log=function(e){this._pastebin(this._log_data.join("\n"),function(t){return t?void this.room_message(e,"Your FrankerFaceZ log has been pasted to: "+t):this.room_message(e,"There was an error uploading the FrankerFaceZ log.")})},t.ffz_commands.massunmod=function(e,t){if(t=t.join(" ").trim(),!t.length)return"You must provide a list of users to unmod.";t=t.split(/\W*,\W*/);var s=this.get_user();if(!s||!s.login==e.id)return"You must be the broadcaster to use massunmod.";if(t.length>50)return"Each user you unmod counts as a single message. To avoid being globally banned, please limit yourself to 50 at a time and wait between uses.";for(var n=t.length;t.length;){var o=t.shift();e.room.tmiRoom.sendMessage("/unmod "+o)}return"Sent unmod command for "+n+" users."},t.ffz_commands.massunmod.help="Usage: /ffz massunmod <list, of, users>\nBroadcaster only. Unmod all the users in the provided list.",t.ffz_commands.massmod=function(e,t){if(t=t.join(" ").trim(),!t.length)return"You must provide a list of users to mod.";t=t.split(/\W*,\W*/);var s=this.get_user();if(!s||!s.login==e.id)return"You must be the broadcaster to use massmod.";if(t.length>50)return"Each user you mod counts as a single message. To avoid being globally banned, please limit yourself to 50 at a time and wait between uses.";for(var n=t.length;t.length;){var o=t.shift();e.room.tmiRoom.sendMessage("/mod "+o)}return"Sent mod command for "+n+" users."},t.ffz_commands.massmod.help="Usage: /ffz massmod <list, of, users>\nBroadcaster only. Mod all the users in the provided list."},{}],3:[function(e,t){var s='<path d="m120.95 1.74c4.08-0.09 8.33-0.84 12.21 0.82 3.61 1.8 7 4.16 11.01 5.05 2.08 3.61 6.12 5.46 8.19 9.07 3.6 5.67 7.09 11.66 8.28 18.36 1.61 9.51 7.07 17.72 12.69 25.35 3.43 7.74 1.97 16.49 3.6 24.62 2.23 5.11 4.09 10.39 6.76 15.31 1.16 2 4.38 0.63 4.77-1.32 1.2-7.1-2.39-13.94-1.97-21.03 0.38-3.64-0.91-7.48 0.25-10.99 2.74-3.74 4.57-8.05 7.47-11.67 3.55-5.47 10.31-8.34 16.73-7.64 2.26 2.89 5.13 5.21 7.58 7.92 2.88 4.3 6.52 8.01 9.83 11.97 1.89 2.61 3.06 5.64 4.48 8.52 2.81 4.9 4 10.5 6.63 15.49 2.16 6.04 5.56 11.92 5.37 18.5 0.65 1.95 0.78 4 0.98 6.03 1.01 3.95 2.84 8.55 0.63 12.42-2.4 5.23-7.03 8.97-11.55 12.33-6.06 4.66-11.62 10.05-18.37 13.75-4.06 2.65-8.24 5.17-12.71 7.08-3.59 1.57-6.06 4.94-9.85 6.09-2.29 1.71-3.98 4.51-6.97 5.02-4.56 1.35-8.98-3.72-13.5-1.25-2.99 1.83-6.19 3.21-9.39 4.6-8.5 5.61-18.13 9.48-28.06 11.62-8.36-0.2-16.69 0.62-25.05 0.47-3.5-1.87-7.67-1.08-11.22-2.83-6.19-1.52-10.93-6.01-16.62-8.61-2.87-1.39-5.53-3.16-8.11-4.99-2.58-1.88-4.17-4.85-6.98-6.44-3.83-0.11-6.54 3.42-10.24 3.92-2.31 0.28-4.64 0.32-6.96 0.31-3.5-3.65-5.69-8.74-10.59-10.77-5.01-3.68-10.57-6.67-14.84-11.25-2.52-2.55-5.22-4.87-8.24-6.8-4.73-4.07-7.93-9.51-11.41-14.62-3.08-4.41-5.22-9.73-4.6-15.19 0.65-8.01 0.62-16.18 2.55-24.02 4.06-10.46 11.15-19.34 18.05-28.06 3.71-5.31 9.91-10.21 16.8-8.39 3.25 1.61 5.74 4.56 7.14 7.89 1.19 2.7 3.49 4.93 3.87 7.96 0.97 5.85 1.6 11.86 0.74 17.77-1.7 6.12-2.98 12.53-2.32 18.9 0.01 2.92 2.9 5.36 5.78 4.57 3.06-0.68 3.99-4.07 5.32-6.48 1.67-4.06 4.18-7.66 6.69-11.23 3.61-5.28 5.09-11.57 7.63-17.37 2.07-4.56 1.7-9.64 2.56-14.46 0.78-7.65-0.62-15.44 0.7-23.04 1.32-3.78 1.79-7.89 3.8-11.4 3.01-3.66 6.78-6.63 9.85-10.26 1.72-2.12 4.21-3.32 6.55-4.6 7.89-2.71 15.56-6.75 24.06-7z"/>',n="true"==localStorage.ffzDebugMode&&document.body.classList.contains("ffz-dev");t.exports={DEBUG:n,SERVER:n?"//localhost:8000/":"//cdn.frankerfacez.com/",API_SERVER:"//api.frankerfacez.com/",SVGPATH:s,ZREKNARF:'<svg style="padding:1.75px 0" class="svg-glyph_views ffz-svg svg-zreknarf" width="16px" viewBox="0 0 249 195" version="1.1" height="12.5px">'+s+"</svg>",CHAT_BUTTON:'<svg class="svg-emoticons ffz-svg" height="18px" width="24px" viewBox="0 0 249 195" version="1.1">'+s+"</svg>",ROOMS:'<svg class="svg-glyph_views svg-roomlist" height="16px" version="1.1" viewBox="0 0 16 16" width="16px" x="0px" y="0px"><path clip-rule="evenodd" d="M1,13v-2h14v2H1z M1,5h13v2H1V5z M1,2h10v2H1V2z M12,10H1V8h11V10z" fill-rule="evenodd"></path></svg>',CAMERA:'<svg class="svg-camera" height="16px" version="1.1" viewBox="0 0 36 36" width="16px" x="0px" y="0px"><path fill-rule="evenodd" clip-rule="evenodd" d="M24,20v6H4V10h20v6l8-6v16L24,20z"/></svg>',INVITE:'<svg class="svg-plus" height="16px" version="1.1" viewBox="0 0 16 16" width="16px" x="0px" y="0px"><path clip-rule="evenodd" d="M15,9h-3v3h-2V9H7V7h3V4h2v3h3V9z M9,6H6v4h2h1v3h4l0,0l0,0v1h-3H4H1v-1l3-3h2L4,8V2h6v1H9V6z" fill-rule="evenodd"></path></svg>',EYE:'<svg class="svg-glyph_views ffz-svg svg-eye" height="16px" version="1.1" viewBox="0 0 16 16" width="16px" x="0px" y="0px"><path clip-rule="evenodd" d="M11,13H5L1,9V8V7l4-4h6l4,4v1v1L11,13z M8,5C6.344,5,5,6.343,5,8c0,1.656,1.344,3,3,3c1.657,0,3-1.344,3-3C11,6.343,9.657,5,8,5z M8,9C7.447,9,7,8.552,7,8s0.447-1,1-1s1,0.448,1,1S8.553,9,8,9z" fill-rule="evenodd"></path></svg>',CLOCK:'<svg class="svg-glyph_views ffz-svg svg-clock" height="16px" version="1.1" viewBox="0 0 16 16" width="16px" x="0px" y="0px"><path fill-rule="evenodd" clip-rule="evenodd" fill="#888888" d="M8,15c-3.866,0-7-3.134-7-7s3.134-7,7-7s7,3.134,7,7 S11.866,15,8,15z M8,3C5.238,3,3,5.238,3,8s2.238,5,5,5s5-2.238,5-5S10.762,3,8,3z M7.293,8.707L7,8l1-4l0.902,3.607L11,11 L7.293,8.707z"/></svg>',GEAR:'<svg class="svg-gear" height="16px" version="1.1" viewBox="0 0 16 16" width="16px" x="0px" y="0px"><path clip-rule="evenodd" d="M15,7v2h-2.115c-0.125,0.615-0.354,1.215-0.713,1.758l1.484,1.484l-1.414,1.414l-1.484-1.484C10.215,12.531,9.615,12.76,9,12.885V15H7v-2.12c-0.614-0.126-1.21-0.356-1.751-0.714l-1.491,1.49l-1.414-1.414l1.491-1.49C3.477,10.211,3.247,9.613,3.12,9H1V7h2.116C3.24,6.384,3.469,5.785,3.829,5.242L2.343,3.757l1.414-1.414l1.485,1.485C5.785,3.469,6.384,3.24,7,3.115V1h2v2.12c0.613,0.126,1.211,0.356,1.752,0.714l1.49-1.491l1.414,1.414l-1.49,1.492C12.523,5.79,12.754,6.387,12.88,7H15z M8,6C6.896,6,6,6.896,6,8s0.896,2,2,2s2-0.896,2-2S9.104,6,8,6z" fill-rule="evenodd"></path></svg>',HEART:'<svg class="svg-heart" height="16px" version="1.1" viewBox="0 0 16 16" width="16px" x="0px" y="0px"><path clip-rule="evenodd" d="M8,13.5L1.5,7V4l2-2h3L8,3.5L9.5,2h3l2,2v3L8,13.5z" fill-rule="evenodd"></path></svg>',EMOTE:'<svg class="svg-emote" height="16px" version="1.1" viewBox="0 0 18 18" width="16px" x="0px" y="0px"><path clip-rule="evenodd" d="M9,18c-4.971,0-9-4.029-9-9s4.029-9,9-9s9,4.029,9,9S13.971,18,9,18z M14,4.111V4h-0.111C12.627,2.766,10.904,2,9,2C7.095,2,5.373,2.766,4.111,4H4v0.111C2.766,5.373,2,7.096,2,9s0.766,3.627,2,4.889V14l0.05-0.051C5.317,15.217,7.067,16,9,16c1.934,0,3.684-0.783,4.949-2.051L14,14v-0.111c1.234-1.262,2-2.984,2-4.889S15.234,5.373,14,4.111zM11,6h2v4h-2V6z M12.535,12.535C11.631,13.44,10.381,14,9,14s-2.631-0.56-3.536-1.465l0.707-0.707C6.896,12.553,7.896,13,9,13s2.104-0.447,2.828-1.172L12.535,12.535z M5,6h2v4H5V6z" fill-rule="evenodd"></path></svg>',STAR:'<svg class="svg-star" height="16px" version="1.1" viewbox="0 0 16 16" width="16px" x="0px" y="0px"><path clip-rule="evenodd" d="M15,6l-4.041,2.694L13,14l-5-3.333L3,14l2.041-5.306L1,6h5.077L8,1l1.924,5H15z" fill-rule="evenodd"></path></svg>'}},{}],4:[function(){var t=e.FrankerFaceZ;t.settings_info.developer_mode={type:"boolean",value:!1,storage_key:"ffzDebugMode",visible:function(){return this.settings.developer_mode||Date.now()-parseInt(localStorage.ffzLastDevMode||"0")<6048e5},category:"Debugging",name:"Developer Mode",help:"Load FrankerFaceZ from the local development server instead of the CDN. Please refresh after changing this setting.",on_update:function(){localStorage.ffzLastDevMode=Date.now()}},t.ffz_commands.developer_mode=function(e,t){var s,t=t&&t.length?t[0].toLowerCase():null;return"y"==t||"yes"==t||"true"==t||"on"==t?s=!0:("n"==t||"no"==t||"false"==t||"off"==t)&&(s=!1),void 0===s?"Developer Mode is currently "+(this.settings.developer_mode?"enabled.":"disabled."):(this.settings.set("developer_mode",s),"Developer Mode is now "+(s?"enabled":"disabled")+". Please refresh your browser.")},t.ffz_commands.developer_mode.help="Usage: /ffz developer_mode <on|off>\nEnable or disable Developer Mode. When Developer Mode is enabled, the script will be reloaded from //localhost:8000/script.js instead of from the CDN."},{}],5:[function(t){var s=e.FrankerFaceZ,n=t("../utils"),o=t("../constants");s.prototype.setup_channel=function(){document.body.classList.toggle("ffz-hide-view-count",!this.settings.channel_views),this.log("Creating channel style element.");var e=this._channel_style=document.createElement("style");e.id="ffz-channel-css",document.head.appendChild(e),this.log("Hooking the Ember Channel Index view.");var t=App.__container__.resolve("view:channel/index"),n=this;if(t){this._modify_cindex(t);try{t.create().destroy()}catch(o){}for(var i in Ember.View.views)if(Ember.View.views.hasOwnProperty(i)){var a=Ember.View.views[i];a instanceof t&&(this.log("Manually updating Channel Index view.",a),this._modify_cindex(a),a.ffzInit())}this.log("Hooking the Ember Channel controller."),t=App.__container__.lookup("controller:channel"),t&&t.reopen({ffzUpdateUptime:function(){n._cindex&&n._cindex.ffzUpdateUptime()}.observes("isLive","content.id"),ffzUpdateTitle:function(){var e=this.get("content.name"),t=this.get("content.display_name");t&&(s.capitalization[e]=[t,Date.now()]),n._cindex&&n._cindex.ffzFixTitle()}.observes("content.status","content.id"),ffzHostTarget:function(){var e=this.get("content.hostModeTarget"),t=e&&e.get("name"),o=e&&e.get("display_name");o&&(s.capitalization[t]=[o,Date.now()]),n.settings.group_tabs&&n._chatv&&n._chatv.ffzRebuildTabs()}.observes("content.hostModeTarget")})}},s.prototype._modify_cindex=function(e){var t=this;e.reopen({didInsertElement:function(){this._super();try{this.ffzInit()}catch(e){t.error("CIndex didInsertElement: "+e)}},willClearRender:function(){try{this.ffzTeardown()}catch(e){t.error("CIndex willClearRender: "+e)}return this._super()},ffzInit:function(){t._cindex=this,this.get("element").setAttribute("data-channel",this.get("controller.id")),this.ffzFixTitle(),this.ffzUpdateUptime(),this.ffzUpdateChatters();var e=this.get("element").querySelector(".svg-glyph_views:not(.ffz-svg)");e&&e.parentNode.classList.add("twitch-channel-views")},ffzFixTitle:function(){if(!t.has_bttv&&t.settings.stream_title){var e=this.get("controller.status"),s=this.get("controller.id");e=t.render_tokens(t.tokenize_line(s,s,e,!0)),this.$(".title span").each(function(t,s){var n=s.querySelectorAll("script");s.innerHTML=n[0].outerHTML+e+n[1].outerHTML})}},ffzUpdateChatters:function(){var e=this.get("controller.id"),s=t.rooms&&t.rooms[e];if(!s||!t.settings.chatter_count){var i=this.get("element").querySelector("#ffz-chatter-display");return i&&i.parentElement.removeChild(i),i=this.get("element").querySelector("#ffz-ffzchatter-display"),void(i&&i.parentElement.removeChild(i))}var a=Object.keys(s.room.get("ffz_chatters")||{}).length,r=s.ffz_chatters||0,i=this.get("element").querySelector("#ffz-chatter-display span");if(!i){var c=this.get("element").querySelector(".stats-and-actions .channel-stats");if(!c)return;var l=document.createElement("span");l.className="ffz stat",l.id="ffz-chatter-display",l.title="Current Chatters",l.innerHTML=o.ROOMS+" ",i=document.createElement("span"),l.appendChild(i);var h=c.querySelector("#ffz-ffzchatter-display");h?c.insertBefore(l,h):c.appendChild(l),jQuery(l).tipsy()}if(i.innerHTML=n.number_commas(a),!r)return i=this.get("element").querySelector("#ffz-ffzchatter-display"),void(i&&i.parentNode.removeChild(i));if(i=this.get("element").querySelector("#ffz-ffzchatter-display span"),!i){var c=this.get("element").querySelector(".stats-and-actions .channel-stats");if(!c)return;var l=document.createElement("span");l.className="ffz stat",l.id="ffz-ffzchatter-display",l.title="Chatters with FrankerFaceZ",l.innerHTML=o.ZREKNARF+" ",i=document.createElement("span"),l.appendChild(i);var h=c.querySelector("#ffz-chatter-display");h?c.insertBefore(l,h.nextSibling):c.appendChild(l),jQuery(l).tipsy()}i.innerHTML=n.number_commas(r)},ffzUpdateUptime:function(){if(this._ffz_update_uptime&&(clearTimeout(this._ffz_update_uptime),delete this._ffz_update_uptime),!t.settings.stream_uptime||!this.get("controller.isLiveAccordingToKraken")){var e=this.get("element").querySelector("#ffz-uptime-display");return void(e&&e.parentElement.removeChild(e))}this._ffz_update_uptime=setTimeout(this.ffzUpdateUptime.bind(this),1e3);var s=this.get("controller.content.stream.created_at");if(s&&(s=n.parse_date(s))){var i=Math.floor((Date.now()-s.getTime())/1e3);if(!(0>i)){var e=this.get("element").querySelector("#ffz-uptime-display span");if(!e){var a=this.get("element").querySelector(".stats-and-actions .channel-stats");if(!a)return;var r=document.createElement("span");r.className="ffz stat",r.id="ffz-uptime-display",r.title="Stream Uptime <nobr>(since "+s.toLocaleString()+")</nobr>",r.innerHTML=o.CLOCK+" ",e=document.createElement("span"),r.appendChild(e);var c=a.querySelector(".live-count");if(c)a.insertBefore(r,c.nextSibling);else try{c=a.querySelector("script:nth-child(0n+2)"),a.insertBefore(r,c.nextSibling)}catch(l){a.insertBefore(r,a.childNodes[0])}jQuery(r).tipsy({html:!0})}e.innerHTML=n.time_to_string(i)}}},ffzTeardown:function(){this.get("element").setAttribute("data-channel",""),t._cindex=void 0,this._ffz_update_uptime&&clearTimeout(this._ffz_update_uptime)}})},s.settings_info.chatter_count={type:"boolean",value:!1,category:"Channel Metadata",name:"Chatter Count",help:"Display the current number of users connected to chat beneath the channel.",on_update:function(e){if(this._cindex&&this._cindex.ffzUpdateChatters(),e&&this.rooms)for(var t in this.rooms)this.rooms.hasOwnProperty(t)&&this.rooms[t].room&&this.rooms[t].room.ffzInitChatterCount()}},s.settings_info.channel_views={type:"boolean",value:!0,category:"Channel Metadata",name:"Channel Views",help:"Display the number of times the channel has been viewed beneath the stream.",on_update:function(e){document.body.classList.toggle("ffz-hide-view-count",!e)}},s.settings_info.stream_uptime={type:"boolean",value:!1,category:"Channel Metadata",name:"Stream Uptime",help:"Display the stream uptime under a channel by the viewer count.",on_update:function(){this._cindex&&this._cindex.ffzUpdateUptime()}},s.settings_info.stream_title={type:"boolean",value:!0,no_bttv:!0,category:"Channel Metadata",name:"Title Links",help:"Make links in stream titles clickable.",on_update:function(){this._cindex&&this._cindex.ffzFixTitle()}}},{"../constants":3,"../utils":29}],6:[function(t){var s=e.FrankerFaceZ,n=t("../utils"),o=t("../constants"),i=function(e){return 1>e?"":e>=99?"99+":""+e};s.settings_info.prevent_clear={type:"boolean",value:!1,no_bttv:!0,category:"Chat",name:"Show Deleted Messages",help:"Fade deleted messages instead of replacing them, and prevent chat from being cleared.",on_update:function(e){if(!this.has_bttv&&this.rooms)for(var t in this.rooms){var s=this.rooms[t],n=s&&s.room;n&&n.get("messages").forEach(function(t,s){e&&!t.ffz_deleted&&t.deleted?n.set("messages."+s+".deleted",!1):!t.ffz_deleted||e||t.deleted||n.set("messages."+s+".deleted",!0)})}}},s.settings_info.chat_history={type:"boolean",value:!0,visible:!1,category:"Chat",name:"Chat History <span>Alpha</span>",help:"Load previous chat messages when loading a chat room so you can see what people have been talking about. <b>This currently only works in a handful of channels due to server capacity.</b>"},s.settings_info.group_tabs={type:"boolean",value:!1,no_bttv:!0,category:"Chat",name:"Chat Room Tabs <span>Beta</span>",help:"Enhanced UI for switching the current chat room and noticing new messages.",on_update:function(e){var t=!this.has_bttv&&e;this._chatv&&t!==this._group_tabs_state&&(t?this._chatv.ffzEnableTabs():this._chatv.ffzDisableTabs())}},s.settings_info.pinned_rooms={type:"button",value:[],category:"Chat",visible:!1,name:"Pinned Chat Rooms",help:"Set a list of channels that should always be available in chat."},s.prototype.setup_chatview=function(){this.log("Hooking the Ember Chat controller.");var e=App.__container__.lookup("controller:chat"),t=this;e&&e.reopen({ffzUpdateChannels:function(){t.settings.group_tabs&&t._chatv&&t._chatv.ffzRebuildTabs()}.observes("currentChannelRoom","connectedPrivateGroupRooms")}),this.log("Hooking the Ember Chat view.");var e=App.__container__.resolve("view:chat");this._modify_cview(e);try{e.create().destroy()}catch(s){}for(var n in Ember.View.views)if(Ember.View.views.hasOwnProperty(n)){var o=Ember.View.views[n];if(o instanceof e){this.log("Manually updating existing Chat view.",o);try{o.ffzInit()}catch(s){this.error("setup: build_ui_link: "+s)}}}this.log("Hooking the Ember Layout controller.");var i=App.__container__.lookup("controller:layout");if(i){i.reopen({ffzFixTabs:function(){t.settings.group_tabs&&t._chatv&&t._chatv._ffz_tabs&&setTimeout(function(){t._chatv&&t._chatv.$(".chat-room").css("top",t._chatv._ffz_tabs.offsetHeight+"px")},0)}.observes("isRightColumnClosed")}),this.log("Hooking the Ember 'Right Column' controller. Seriously...");var a=App.__container__.lookup("controller:right-column");a&&a.reopen({ffzFixTabs:function(){t.settings.group_tabs&&t._chatv&&t._chatv._ffz_tabs&&setTimeout(function(){t._chatv&&t._chatv.$(".chat-room").css("top",t._chatv._ffz_tabs.offsetHeight+"px")},0)}.observes("firstTabSelected")})}},s.prototype._modify_cview=function(e){var t=this;e.reopen({didInsertElement:function(){this._super();try{this.ffzInit()}catch(e){t.error("ChatView didInsertElement: "+e)}},willClearRender:function(){try{this.ffzTeardown()}catch(e){t.error("ChatView willClearRender: "+e)}this._super()},ffzInit:function(){t._chatv=this,this.$(".textarea-contain").append(t.build_ui_link(this)),!t.has_bttv&&t.settings.group_tabs&&this.ffzEnableTabs(),setTimeout(function(){t.settings.group_tabs&&t._chatv._ffz_tabs&&t._chatv.$(".chat-room").css("top",t._chatv._ffz_tabs.offsetHeight+"px");var e=t._chatv.get("controller");e&&e.set("showList",!1)},1e3)},ffzTeardown:function(){t._chatv===this&&(t._chatv=null),this.$(".textarea-contain .ffz-ui-toggle").remove(),t.settings.group_tabs&&this.ffzDisableTabs()},ffzChangeRoom:Ember.observer("controller.currentRoom",function(){try{if(t.update_ui_link(),!t.has_bttv&&t.settings.group_tabs&&this._ffz_tabs){var e=this.get("controller.currentRoom");e&&e.resetUnreadCount();var s=jQuery(this._ffz_tabs);s.children(".ffz-chat-tab").removeClass("active"),e&&s.children('.ffz-chat-tab[data-room="'+e.get("id")+'"]').removeClass("tab-mentioned").addClass("active").children("span").text("");var n=e&&e.get("canInvite");this._ffz_invite&&this._ffz_invite.classList.toggle("hidden",!n),this.set("controller.showInviteUser",n&&this.get("controller.showInviteUser")),this.$(".chat-room").css("top",this._ffz_tabs.offsetHeight+"px")}}catch(o){t.error("ChatView ffzUpdateLink: "+o)}}),ffzEnableTabs:function(){if(!t.has_bttv&&t.settings.group_tabs){this.$(".chat-header").addClass("hidden");var e=this._ffz_tabs=document.createElement("div");e.id="ffz-group-tabs",this.$(".chat-header").after(e),this.ffzRebuildTabs()}},ffzRebuildTabs:function(){if(!t.has_bttv&&t.settings.group_tabs){var e=this._ffz_tabs||this.get("element").querySelector("#ffz-group-tabs");if(e){e.innerHTML="";var s=document.createElement("a"),n=this;s.className="button glyph-only tooltip",s.title="Chat Room Management",s.innerHTML=o.ROOMS,s.addEventListener("click",function(){var e=n.get("controller");e&&e.set("showList",!e.get("showList"))}),e.appendChild(s),s=document.createElement("a"),s.className="button glyph-only tooltip invite",s.title="Invite a User",s.innerHTML=o.INVITE,s.addEventListener("click",function(){var e=n.get("controller");e&&e.set("showInviteUser",e.get("currentRoom.canInvite")&&!e.get("showInviteUser"))}),s.classList.toggle("hidden",!this.get("controller.currentRoom.canInvite")),n._ffz_invite=s,e.appendChild(s);var i,a=this.get("controller.currentChannelRoom");a&&(i=this.ffzBuildTab(n,a,!0),i&&e.appendChild(i));var r=App.__container__.lookup("controller:channel"),c=App.__container__.resolve("model:room");if(target=r&&r.get("hostModeTarget"),target&&c){var l=target.get("id");this._ffz_host!==l&&(this._ffz_host_room&&(this.get("controller.currentRoom")===this._ffz_host_room&&this.get("controller").blurRoom(),this._ffz_host_room.destroy()),this._ffz_host=l,this._ffz_host_room=c.findOne(l))}else this._ffz_host&&(this._ffz_host_room&&(this.get("controller.currentRoom")===this._ffz_host_room&&this.get("controller").blurRoom(),this._ffz_host_room.destroy()),delete this._ffz_host,delete this._ffz_host_room);this._ffz_host_room&&(i=n.ffzBuildTab(n,this._ffz_host_room,!1,!0),i&&e.appendChild(i));for(var h=0;h<t.settings.pinned_rooms.length;h++){var u=t.settings.pinned_rooms[h];if(a&&a.get("id")!==u&&this._ffz_host!==u&&t.rooms[u]&&t.rooms[u].room){var i=n.ffzBuildTab(n,t.rooms[u].room,!1,!1);i&&e.appendChild(i)}}_.each(this.get("controller.connectedPrivateGroupRooms"),function(t){var s=n.ffzBuildTab(n,t);s&&e.appendChild(s)}),this.$(".chat-room").css("top",e.offsetHeight+"px")}}},ffzTabUnread:function(e){if(!t.has_bttv&&t.settings.group_tabs){var s=this._ffz_tabs||this.get("element").querySelector("#ffz-group-tabs"),n=this.get("controller.currentRoom.id");if(s){if(e){var o=s.querySelector('.ffz-chat-tab[data-room="'+e+'"]'),a=t.rooms&&t.rooms[e];if(o&&a){var r=i(e===n?0:a.room.get("unreadCount"));o.querySelector("span").innerHTML=r}return this.$(".chat-room").css("top",s.offsetHeight+"px")}for(var c=s.querySelectorAll(".ffz-chat-tab"),l=0;l<c.length;l++){var o=c[l],e=o.getAttribute("data-room"),a=t.rooms&&t.rooms[e];if(a){var r=i(e===n?0:a.room.get("unreadCount"));o.querySelector("span").innerHTML=r}}this.$(".chat-room").css("top",s.offsetHeight+"px")}}},ffzBuildTab:function(e,t,a,r){var c,l,h=document.createElement("span"),u=t.get("isGroupRoom"),d=t===e.get("controller.currentRoom");return h.setAttribute("data-room",t.id),h.className="ffz-chat-tab tooltip",h.classList.toggle("current-channel",a),h.classList.toggle("host-channel",r),h.classList.toggle("group-chat",u),h.classList.toggle("active",d),c=t.get("tmiRoom.displayName")||(u?t.get("tmiRoom.name"):s.get_capitalization(t.get("id"))),l=i(d?0:t.get("unreadCount")),a?(h.innerHTML=o.CAMERA,h.title="Current Channel"):r?(h.innerHTML=o.EYE,h.title="Hosted Channel"):h.title=u?"Group Chat":"Pinned Channel",h.innerHTML+=n.sanitize(c)+"<span>"+l+"</span>",h.addEventListener("click",function(){e.get("controller").focusRoom(t)}),h},ffzDisableTabs:function(){this._ffz_tabs&&(this._ffz_tabs.parentElement.removeChild(this._ffz_tabs),delete this._ffz_tabs,delete this._ffz_invite),this._ffz_host&&(this._ffz_host_room&&(this.get("controller.currentRoom")===this._ffz_host_room&&this.get("controller").blurRoom(),this._ffz_host_room.destroy()),delete this._ffz_host,delete this._ffz_host_room),this.$(".chat-room").css("top",""),this.$(".chat-header").removeClass("hidden")}})},s.prototype.connect_extra_chat=function(){if(!this.has_bttv){for(var e=0;e<this.settings.pinned_rooms.length;e++)this._join_room(this.settings.pinned_rooms[e],!0);!this.has_bttv&&this._chatv&&this.settings.group_tabs&&this._chatv.ffzRebuildTabs()}},s.prototype._join_room=function(e,t){var s=!1;if(-1===this.settings.pinned_rooms.indexOf(e)&&(this.settings.pinned_rooms.push(e),this.settings.set("pinned_rooms",this.settings.pinned_rooms),s=!0),this.rooms[e]&&this.rooms[e].room)return s;{var n=App.__container__.resolve("model:room");n&&n.findOne(e)}return!t&&!this.has_bttv&&this._chatv&&this.settings.group_tabs&&this._chatv.ffzRebuildTabs(),s},s.prototype._leave_room=function(e,t){var s=!1;if(-1!==this.settings.pinned_rooms.indexOf(e)&&(this.settings.pinned_rooms.removeObject(e),this.settings.set("pinned_rooms",this.settings.pinned_rooms),s=!0),!this.rooms[e]||!this.rooms[e].room)return s;var n=App.__container__.lookup("controller:chat"),o=this.rooms[e].room;return!n||n.get("currentChannelRoom.id")===e||this._chatv&&this._chatv._ffz_host===e?s:(n.get("currentRoom.id")===e&&n.blurRoom(),o.destroy(),!t&&!this.has_bttv&&this._chatv&&this.settings.group_tabs&&this._chatv.ffzRebuildTabs(),s)},s.chat_commands.join=function(e,t){if(!t||!t.length||t.length>1)return"Join Usage: /join <channel>";var s=t[0].toLowerCase();return"#"===s.charAt(0)&&(s=s.substr(1)),this._join_room(s)?"Joining "+s+". You will always connect to this channel's chat unless you later /part from it.":"You have already joined "+s+'. Please use "/part '+s+'" to leave it.'},s.chat_commands.part=function(e,t){if(!t||!t.length||t.length>1)return"Part Usage: /part <channel>";var s=t[0].toLowerCase();return"#"===s.charAt(0)&&(s=s.substr(1)),this._leave_room(s)?"Leaving "+s+".":this.rooms[s]?"You do not have "+s+" pinned and you cannot leave the current channel or hosted channels via /part.":"You are not in "+s+"."}},{"../constants":3,"../utils":29}],7:[function(t){var s=e.FrankerFaceZ,n=t("../utils"),o="[\\s`~<>!-#%-\\x2A,-/:;\\x3F@\\x5B-\\x5D_\\x7B}\\u00A1\\u00A7\\u00AB\\u00B6\\u00B7\\u00BB\\u00BF\\u037E\\u0387\\u055A-\\u055F\\u0589\\u058A\\u05BE\\u05C0\\u05C3\\u05C6\\u05F3\\u05F4\\u0609\\u060A\\u060C\\u060D\\u061B\\u061E\\u061F\\u066A-\\u066D\\u06D4\\u0700-\\u070D\\u07F7-\\u07F9\\u0830-\\u083E\\u085E\\u0964\\u0965\\u0970\\u0AF0\\u0DF4\\u0E4F\\u0E5A\\u0E5B\\u0F04-\\u0F12\\u0F14\\u0F3A-\\u0F3D\\u0F85\\u0FD0-\\u0FD4\\u0FD9\\u0FDA\\u104A-\\u104F\\u10FB\\u1360-\\u1368\\u1400\\u166D\\u166E\\u169B\\u169C\\u16EB-\\u16ED\\u1735\\u1736\\u17D4-\\u17D6\\u17D8-\\u17DA\\u1800-\\u180A\\u1944\\u1945\\u1A1E\\u1A1F\\u1AA0-\\u1AA6\\u1AA8-\\u1AAD\\u1B5A-\\u1B60\\u1BFC-\\u1BFF\\u1C3B-\\u1C3F\\u1C7E\\u1C7F\\u1CC0-\\u1CC7\\u1CD3\\u2010-\\u2027\\u2030-\\u2043\\u2045-\\u2051\\u2053-\\u205E\\u207D\\u207E\\u208D\\u208E\\u2329\\u232A\\u2768-\\u2775\\u27C5\\u27C6\\u27E6-\\u27EF\\u2983-\\u2998\\u29D8-\\u29DB\\u29FC\\u29FD\\u2CF9-\\u2CFC\\u2CFE\\u2CFF\\u2D70\\u2E00-\\u2E2E\\u2E30-\\u2E3B\\u3001-\\u3003\\u3008-\\u3011\\u3014-\\u301F\\u3030\\u303D\\u30A0\\u30FB\\uA4FE\\uA4FF\\uA60D-\\uA60F\\uA673\\uA67E\\uA6F2-\\uA6F7\\uA874-\\uA877\\uA8CE\\uA8CF\\uA8F8-\\uA8FA\\uA92E\\uA92F\\uA95F\\uA9C1-\\uA9CD\\uA9DE\\uA9DF\\uAA5C-\\uAA5F\\uAADE\\uAADF\\uAAF0\\uAAF1\\uABEB\\uFD3E\\uFD3F\\uFE10-\\uFE19\\uFE30-\\uFE52\\uFE54-\\uFE61\\uFE63\\uFE68\\uFE6A\\uFE6B\\uFF01-\\uFF03\\uFF05-\\uFF0A\\uFF0C-\\uFF0F\\uFF1A\\uFF1B\\uFF1F\\uFF20\\uFF3B-\\uFF3D\\uFF3F\\uFF5B\\uFF5D\\uFF5F-\\uFF65]",i=new RegExp(o+"*,"+o+"*"),a=function(e){return(e+"").replace(/&/g,"&").replace(/'/g,"'").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")
|
|
},r="http://static-cdn.jtvnw.net/emoticons/v1/",c=function(e){return r+e+"/1.0 1x, "+r+e+"/2.0 2x, "+r+e+"/3.0 4x"},l=function(e){var t=e.set,s=e.set_type,n=e.owner;return void 0===s&&(s="Channel"),t?(("00000turbo"==t||"turbo"==t)&&(t="Twitch Turbo",s=null),"Emoticon: "+e.code+"\n"+(s?s+": ":"")+t+(n?"\nBy: "+n.display_name:"")):e.code},h=function(e){{var t=this._twitch_emotes[e];t?t.set:null}return t?"string"==typeof t?t:t.tooltip?t.tooltip:t.tooltip=l(t):"???"},u=function(e,t,s,n){if(s){t&&(n.code=t),this._twitch_emotes[e]=n;for(var o=h.bind(this)(e),i=document.querySelectorAll('img[emote-id="'+e+'"]'),a=0;a<i.length;a++)i[a].title=o}},d=function(e){var t,s=this._link_data[e];if(!s)return"";if(s.tooltip)return s.tooltip;if("youtube"==s.type)t="<b>YouTube: "+n.sanitize(s.title)+"</b><hr>",t+="Channel: "+n.sanitize(s.channel)+" | "+n.time_to_string(s.duration)+"<br>",t+=n.number_commas(s.views||0)+" Views | 👍 "+n.number_commas(s.likes||0)+" 👎 "+n.number_commas(s.dislikes||0);else if("strawpoll"==s.type){t="<b>Strawpoll: "+n.sanitize(s.title)+"</b><hr><table><tbody>";for(var o in s.items){{var i=s.items[o];Math.floor(i/s.total*100)}t+='<tr><td style="text-align:left">'+n.sanitize(o)+'</td><td style="text-align:right">'+n.number_commas(i)+"</td></tr>"}t+="</tbody></table><hr>Total: "+n.number_commas(s.total);var a=n.parse_date(s.fetched);if(a){var r=Math.floor((a.getTime()-Date.now())/1e3);r>60&&(t+="<br><small>Data was cached "+n.time_to_string(r)+" ago.</small>")}}else if("twitch"==s.type){t="<b>Twitch: "+n.sanitize(s.display_name)+"</b><hr>";var c=n.parse_date(s.since);c&&(t+="Member Since: "+n.date_string(c)+"<br>"),t+="<nobr>Views: "+n.number_commas(s.views)+"</nobr> | <nobr>Followers: "+n.number_commas(s.followers)+"</nobr>"}else if("twitch_vod"==s.type)t="<b>Twitch "+("highlight"==s.broadcast_type?"Highlight":"Broadcast")+": "+n.sanitize(s.title)+"</b><hr>",t+="By: "+n.sanitize(s.display_name)+(s.game?" | Playing: "+n.sanitize(s.game):" | Not Playing")+"<br>",t+="Views: "+n.number_commas(s.views)+" | "+n.time_to_string(s.length);else if("twitter"==s.type)t="<b>Tweet By: "+n.sanitize(s.user)+"</b><hr>",t+=n.sanitize(s.tweet);else if("reputation"==s.type){if(t='<span style="word-wrap: break-word">'+n.sanitize(s.full.toLowerCase())+"</span>",s.trust<50||s.safety<50||s.tags&&s.tags.length>0){t+="<hr>";var l=!1;(s.trust<50||s.safety<50)&&(s.unsafe=!0,t+="<b>Potentially Unsafe Link</b><br>",t+="Trust: "+s.trust+"% | Child Safety: "+s.safety+"%",l=!0),s.tags&&s.tags.length>0&&(t+=(l?"<br>":"")+"Tags: "+s.tags.join(", ")),t+="<br>Data Source: WOT"}}else s.full&&(t='<span style="word-wrap: break-word">'+n.sanitize(s.full.toLowerCase())+"</span>");return t||(t='<span style="word-wrap: break-word">'+n.sanitize(e.toLowerCase())+"</span>"),s.tooltip=t,t},f=function(e,t,s){if(t){this._link_data[e]=s,s.unsafe=!1;var n,o=d.bind(this)(e),i="/"==e.charAt(e.length-1)?e.substr(0,e.length-1):null;if(n=document.querySelectorAll(i?'span.message a[href="'+e+'"], span.message a[href="'+i+'"], span.message a[data-url="'+e+'"], span.message a[data-url="'+i+'"]':'span.message a[href="'+e+'"], span.message a[data-url="'+e+'"]'),this.settings.link_info)for(var a=0;a<n.length;a++)s.unsafe&&n[a].classList.add("unsafe-link"),n[a].classList.contains("deleted-link")||(n[a].title=o)}};s.settings_info.banned_words={type:"button",value:[],category:"Chat",no_bttv:!0,name:"Banned Words",help:"Set a list of words that will be locally removed from chat messages.",method:function(){var e=this.settings.banned_words.join(", "),t=prompt("Banned Words\n\nPlease enter a comma-separated list of words that you would like to be removed from chat messages.",e);if(null!==t&&void 0!==t){t=t.trim().split(i);for(var s=[],n=0;n<t.length;n++)t[n]&&s.push(t[n]);1==s.length&&"disable"==s[0]&&(s=[]),this.settings.set("banned_words",s)}}},s.settings_info.keywords={type:"button",value:[],category:"Chat",no_bttv:!0,name:"Highlight Keywords",help:"Set additional keywords that will be highlighted in chat.",method:function(){var e=this.settings.keywords.join(", "),t=prompt("Highlight Keywords\n\nPlease enter a comma-separated list of words that you would like to be highlighted in chat.",e);if(null!==t&&void 0!==t){t=t.trim().split(i);for(var s=[],n=0;n<t.length;n++)t[n]&&s.push(t[n]);1==s.length&&"disable"==s[0]&&(s=[]),this.settings.set("keywords",s)}}},s.settings_info.fix_color={type:"boolean",value:!0,category:"Chat",no_bttv:!0,name:"Adjust Username Colors",help:"Ensure that username colors contrast with the background enough to be readable.",on_update:function(e){this.has_bttv||document.body.classList.toggle("ffz-chat-colors",e)}},s.settings_info.link_info={type:"boolean",value:!0,category:"Chat",no_bttv:!0,name:"Link Tooltips <span>Beta</span>",help:"Check links against known bad websites, unshorten URLs, and show YouTube info."},s.settings_info.chat_rows={type:"boolean",value:!1,category:"Chat",no_bttv:!0,name:"Chat Line Backgrounds",help:"Display alternating background colors for lines in chat.",on_update:function(e){this.has_bttv||document.body.classList.toggle("ffz-chat-background",e)}},s.prototype.setup_line=function(){document.body.classList.toggle("ffz-chat-colors",!this.has_bttv&&this.settings.fix_color),document.body.classList.toggle("ffz-chat-background",!this.has_bttv&&this.settings.chat_rows),this._colors={},this._last_row={};var e=this._fix_color_style=document.createElement("style");e.id="ffz-style-username-colors",e.type="text/css",document.head.appendChild(e),this._twitch_emotes={},this._link_data={},this.log("Hooking the Ember Whisper controller.");var t=App.__container__.resolve("component:whisper-line");t&&this._modify_line(t),this.log("Hooking the Ember Line controller.");var n=App.__container__.resolve("component:message-line");n&&this._modify_line(n);var o=this.get_user();o&&o.name&&(s.capitalization[o.login]=[o.name,Date.now()])},s.prototype._modify_line=function(e){var t=this;e.reopen({tokenizedMessage:function(){var e=this.get("msgObject.cachedTokens");if(e)return e;e=this._super();try{var n=performance.now(),o=t.get_user(),i=o&&this.get("msgObject.from")===o.login;e=t._remove_banned(e),e=t._emoticonize(this,e);var a=this.get("msgObject.tags.display-name");a&&a.length&&(s.capitalization[this.get("msgObject.from")]=[a.trim(),Date.now()]),i||(e=t.tokenize_mentions(e));for(var r=0;r<e.length;r++){var c=e[r];if(!_.isString(c)&&c.mentionedUser&&!c.own){this.set("msgObject.ffz_has_mention",!0);break}}var l=performance.now();l-n>5&&t.log("Tokenizing Message Took Too Long - "+(l-n)+"ms",e,!1,!0)}catch(h){try{t.error("LineController tokenizedMessage: "+h)}catch(h){}}return this.set("msgObject.cachedTokens",e),e}.property("msgObject.message","isChannelLinksDisabled","currentUserNick","msgObject.from","msgObject.tags.emotes"),ffzUpdated:Ember.observer("msgObject.ffz_deleted","msgObject.ffz_old_messages",function(){this.rerender()}),didInsertElement:function(){this._super();try{var e=performance.now(),s=this.get("element"),o=this.get("msgObject.from"),i=this.get("msgObject.room")||App.__container__.lookup("controller:chat").get("currentRoom.id"),a=this.get("msgObject.color"),r=this.get("msgObject.ffz_alternate");a&&t._handle_color(a),void 0===r&&(r=t._last_row[i]=t._last_row.hasOwnProperty(i)?!t._last_row[i]:!1,this.set("msgObject.ffz_alternate",r)),s.classList.toggle("ffz-alternate",r),s.classList.toggle("ffz-deleted",t.settings.prevent_clear&&this.get("msgObject.ffz_deleted")),s.setAttribute("data-room",i),s.setAttribute("data-sender",o),s.setAttribute("data-deleted",this.get("msgObject.deleted")||!1);var l=this.get("msgObject.ffz_old_messages");if(l&&l.length){var h=document.createElement("div");h.className="button primary float-right",h.innerHTML="Show "+n.number_commas(l.length)+" Old",h.addEventListener("click",t._show_deleted.bind(t,i)),s.classList.add("clearfix"),s.classList.add("ffz-has-deleted"),this.$(".message").append(h)}t.render_badge(this),this.get("msgObject.ffz_has_mention")&&s.classList.add("ffz-mentioned");for(var d=s.querySelectorAll("a.deleted-link"),_=0;_<d.length;_++){var m=d[_];m.addEventListener("click",function(e){if(!this.classList.contains("deleted-link"))return!0;var s=this.getAttribute("data-url"),n=s;this.classList.remove("deleted-link"),this.removeAttribute("data-url"),this.removeAttribute("title"),this.removeAttribute("original-title"),s.indexOf("@")>-1&&(-1===s.indexOf("/")||s.indexOf("@")<s.indexOf("/"))?s="mailto:"+s:s.match(/^https?:\/\//)||(s="http://"+s),this.href=s,this.target="_new",this.textContent=n;var o=t._link_data[n];o&&"boolean"!=typeof o&&(this.title=o.tooltip,o.unsafe&&this.classList.add("unsafe-link")),e.preventDefault()}),jQuery(m).tipsy({html:!0})}if(t.settings.link_info){for(var p=s.querySelectorAll("span.message a"),_=0;_<p.length;_++){var m=p[_],g=m.href,v=!1;m.classList.contains("deleted-link")&&(g=m.getAttribute("data-url"),v=!0);var b=t._link_data[g];b?(v||"boolean"==typeof b||(m.title=b.tooltip),b.unsafe&&m.classList.add("unsafe-link")):/^mailto:/.test(g)||(t._link_data[g]=!0,t.ws_send("get_link",g,f.bind(t,g)))}jQuery(p).tipsy({html:!0})}for(var y=s.querySelectorAll("img.emoticon"),_=0;_<y.length;_++){var w=y[_],z=(w.alt,/\/emoticons\/v1\/(\d+)\/1\.0/.exec(w.src)),k=z?parseInt(z[1]):null;if(null!==k){w.setAttribute("srcset",c(k)),w.setAttribute("emote-id",k);var C=t._twitch_emotes[k];C?"string"!=typeof C&&(w.title=C.tooltip):(t._twitch_emotes[k]=w.alt,t.ws_send("twitch_emote",k,u.bind(t,k,w.alt)))}else if(w.getAttribute("data-ffz-emote")){var F=JSON.parse(decodeURIComponent(w.getAttribute("data-ffz-emote"))),k=F&&F[0]||null,E=F&&F[1]||null,T=t.emote_sets[E],x=T?T.emoticons[k]:null;x&&x.srcSet&&w.setAttribute("srcset",x.srcSet),T&&t.feature_friday&&T.id==t.feature_friday.set&&(set_name=t.feature_friday.title+" - "+t.feature_friday.display_name),w.title=t._emote_tooltip(x)}}jQuery(y).tipsy();var A=performance.now()-e;A>5&&t.log("Line Took Too Long - "+A+"ms",s.innerHTML,!1,!0)}catch(L){try{t.error("LineView didInsertElement: "+L)}catch(L){}}}})},s.prototype._handle_color=function(e){if(e&&!this._colors[e]){this._colors[e]=!0;var t=parseInt(e.substr(1),16),s=[t>>16,t>>8&255,255&t],o=n.get_luminance(s),i="",a='span[style="color:'+e+'"]',r=!1;if(o>.3){r=!0;for(var c=127,l=s;c--&&(l=n.darken(l),!(n.get_luminance(l)<=.3)););i+=".ffz-chat-colors .ember-chat-container:not(.dark) .chat-line "+a+", .ffz-chat-colors .chat-container:not(.dark) .chat-line "+a+" { color: "+n.rgb_to_css(l)+" !important; }\n"}else i+=".ffz-chat-colors .ember-chat-container:not(.dark) .chat-line "+a+", .ffz-chat-colors .chat-container:not(.dark) .chat-line "+a+" { color: "+e+" !important; }\n";if(.15>o){r=!0;for(var c=127,l=s;c--&&(l=n.brighten(l),!(n.get_luminance(l)>=.15)););i+=".ffz-chat-colors .theatre .chat-container .chat-line "+a+", .ffz-chat-colors .chat-container.dark .chat-line "+a+", .ffz-chat-colors .ember-chat-container.dark .chat-line "+a+" { color: "+n.rgb_to_css(l)+" !important; }\n"}else i+=".ffz-chat-colors .theatre .chat-container .chat-line "+a+", .ffz-chat-colors .chat-container.dark .chat-line "+a+", .ffz-chat-colors .ember-chat-container.dark .chat-line "+a+" { color: "+e+" !important; }\n";r&&(this._fix_color_style.innerHTML+=i)}},s.capitalization={},s._cap_fetching=0,s.get_capitalization=function(t,n){if(e.BetterTTV&&BetterTTV.chat&&BetterTTV.chat.helpers.lookupDisplayName)return BetterTTV.chat.helpers.lookupDisplayName(t);if(!t)return t;if(t=t.toLowerCase(),"jtv"==t||"twitchnotify"==t)return t;var o=s.capitalization[t];return o&&Date.now()-o[1]<36e5?o[0]:(s._cap_fetching<25&&(s._cap_fetching++,s.get().ws_send("get_display_name",t,function(e,o){var i=e?o:t;s.capitalization[t]=[i,Date.now()],s._cap_fetching--,"function"==typeof n&&n(i)})),o?o[0]:t)},s.prototype._remove_banned=function(e){var t=this.settings.banned_words;if(!t||!t.length)return e;"string"==typeof e&&(e=[e]);for(var n=s._words_to_regex(t),o=[],i=0;i<e.length;i++){var r=e[i];o.push(_.isString(r)?r.replace(n,"$1***"):r.emoticonSrc&&n.test(r.altText)?r.altText.replace(n,"$1***"):r.isLink&&n.test(r.href)?{mentionedUser:'</span><a class="deleted-link" title="'+a(r.href.replace(n,"$1***"))+'" data-url="'+a(r.href)+'" href="#"><banned link></a><span class="mentioning">',own:!0}:r)}return o},s.prototype._emoticonize=function(e,t){var s=e.get("msgObject.room"),n=e.get("msgObject.from");return this.tokenize_emotes(n,s,t)}},{"../utils":29}],8:[function(t){var s=e.FrankerFaceZ,n=t("../utils"),o={ESC:27,P:80,B:66,T:84,U:85},i=[["5m",300],["10m",600],["1hr",3600],["12hr",43200],["24hr",86400]],a='<svg class="svg-messages" height="16px" version="1.1" viewBox="0 0 18 18" width="16px" x="0px" y="0px"><path clip-rule="evenodd" d="M1,15V3h16v12H1z M15.354,5.354l-0.707-0.707L9,10.293L3.354,4.646L2.646,5.354L6.293,9l-3.646,3.646l0.707,0.707L7,9.707l1.646,1.646h0.707L11,9.707l3.646,3.646l0.707-0.707L11.707,9L15.354,5.354z" fill-rule="evenodd"></path></svg>',r='<svg class="svg-unban" height="16px" version="1.1" viewBox="0 0 16 16" width="16px" x="0px" y="0px"><path fill-rule="evenodd" clip-rule="evenodd" fill="#888888" d="M6.5,12.75L2,8.25l2-2l2.5,2.5l5.5-5.5l2,2L6.5,12.75z"/></svg>';s.settings_info.enhanced_moderation={type:"boolean",value:!1,no_bttv:!0,category:"Chat",name:"Enhanced Moderation",help:"Use /p, /t, /u and /b in chat to moderate chat, or use hotkeys with moderation cards."},s.prototype.setup_mod_card=function(){this.log("Hooking the Ember Moderation Card view.");var t=App.__container__.resolve("component:moderation-card"),s=this;t.reopen({didInsertElement:function(){this._super(),e._card=this;try{if(s.has_bttv||!s.settings.enhanced_moderation)return;var t=this.get("element"),c=this.get("controller");if(t.classList.add("ffz-moderation-card"),c.get("cardInfo.isModeratorOrHigher")){t.classList.add("ffz-is-mod"),t.setAttribute("tabindex",1),t.addEventListener("keyup",function(e){var t=e.keyCode||e.which,s=c.get("cardInfo.user.id"),n=App.__container__.lookup("controller:chat").get("currentRoom");if(t==o.P)n.send("/timeout "+s+" 1");else if(t==o.B)n.send("/ban "+s);else if(t==o.T)n.send("/timeout "+s+" 600");else if(t==o.U)n.send("/unban "+s);else if(t!=o.ESC)return;c.send("hideModOverlay")});var l=document.createElement("div");l.className="interface clearfix";var h=function(e){var t=c.get("cardInfo.user.id"),s=App.__container__.lookup("controller:chat").get("currentRoom");s.send(-1===e?"/unban "+t:"/timeout "+t+" "+e)},u=function(e,t){var s=document.createElement("button");return s.className="button",s.innerHTML=e,s.title="Timeout User for "+n.number_commas(t)+" Second"+(1!=t?"s":""),600===t?s.title="(T)"+s.title.substr(1):1===t&&(s.title="(P)urge - "+s.title),jQuery(s).tipsy(),s.addEventListener("click",h.bind(this,t)),s};l.appendChild(u("Purge",1));var d=document.createElement("span");d.className="right",l.appendChild(d);for(var f=0;f<i.length;f++)d.appendChild(u(i[f][0],i[f][1]));t.appendChild(l);var _=document.createElement("button");_.className="unban button glyph-only light",_.innerHTML=r,_.title="(U)nban User",jQuery(_).tipsy(),_.addEventListener("click",h.bind(this,-1));var m=t.querySelector("button.ban");m.setAttribute("title","(B)an User"),jQuery(m).after(_),this.$("button.timeout").remove()}var p=t.querySelector("button.mod");if(p){var g=c.get("cardInfo.isChannelOwner"),v=ffz.get_user();can_op=g||v&&v.is_admin||v&&v.is_staff,can_op||p.parentElement.removeChild(p)}var b=t.querySelector(".interface > button");b&&b.classList.contains("message-button")&&(b.innerHTML=a,b.classList.add("glyph-only"),b.classList.add("message"),b.title="Message User",jQuery(b).tipsy()),this.$().draggable({start:function(){t.focus()}}),t.focus()}catch(y){try{s.error("ModerationCardView didInsertElement: "+y)}catch(y){}}}})},s.chat_commands.purge=s.chat_commands.p=function(e,t){if(!t||!t.length)return"Purge Usage: /p username [more usernames separated by spaces]";if(t.length>10)return"Please only purge up to 10 users at once.";for(var s=0;s<t.length;s++){var n=t[s];n&&e.room.send("/timeout "+n+" 1")}},s.chat_commands.p.enabled=function(){return this.settings.enhanced_moderation},s.chat_commands.t=function(e,t){return t&&t.length?void e.room.send("/timeout "+t.join(" ")):"Timeout Usage: /t username [duration]"},s.chat_commands.t.enabled=function(){return this.settings.enhanced_moderation},s.chat_commands.b=function(e,t){if(!t||!t.length)return"Ban Usage: /b username [more usernames separated by spaces]";if(t.length>10)return"Please only ban up to 10 users at once.";for(var s=0;s<t.length;s++){var n=t[s];n&&e.room.send("/ban "+n)}},s.chat_commands.b.enabled=function(){return this.settings.enhanced_moderation},s.chat_commands.u=function(e,t){if(!t||!t.length)return"Unban Usage: /u username [more usernames separated by spaces]";if(t.length>10)return"Please only unban up to 10 users at once.";for(var s=0;s<t.length;s++){var n=t[s];n&&e.room.send("/unban "+n)}},s.chat_commands.u.enabled=function(){return this.settings.enhanced_moderation}},{"../utils":29}],9:[function(t){var s=e.FrankerFaceZ,n=t("../constants"),o=t("../utils"),i=function(e){return e.moderator_badge?'.chat-line[data-room="'+e.id+'"] .badges .moderator:not(.ffz-badge-replacement) { background-image:url("'+e.moderator_badge+'") !important; }':""};s.prototype.setup_room=function(){this.rooms={},this.log("Creating room style element.");var e=this._room_style=document.createElement("style");e.id="ffz-room-css",document.head.appendChild(e),this.log("Hooking the Ember Room model.");var t=App.__container__.lookup("controller:room");if(t){var s=t._actions.banUser;t._actions.banUser=function(e){s.bind(this)(e),this.get("model").clearMessages(e.user)}}var n=App.__container__.resolve("model:room");this._modify_room(n);var o=n.instances;for(var i in o)if(o.hasOwnProperty(i)){var a=o[i];this.add_room(a.id,a),this._modify_room(a),a.ffzPatchTMI()}},s.chat_commands={},s.ffz_commands={},s.prototype.room_message=function(e,t){var s=t.split("\n");if(this.has_bttv)for(var n=0;n<s.length;n++)BetterTTV.chat.handlers.onPrivmsg(e.id,{style:"admin",date:new Date,from:"jtv",message:s[n]});else for(var n=0;n<s.length;n++)e.room.addMessage({style:"ffz admin",date:new Date,from:"FFZ",message:s[n]})},s.prototype.run_command=function(e,t){var n=this.rooms[t];if(!n||!n.room)return!1;if(e){var o,i=e.split(" "),a=i.shift().substr(1).toLowerCase(),r=s.chat_commands[a];if(!r)return!1;if(r.hasOwnProperty("enabled")){var c=r.enabled;if("function"==typeof c)try{c=r.enabled.bind(this)(n,i)}catch(l){this.error('command "'+a+'" enabled: '+l),c=!1}if(!c)return!1}this.log("Received Command: "+a,i,!0);try{o=r.bind(this)(n,i)}catch(l){this.error('command "'+a+'" runner: '+l),o="There was an error running the command."}return o&&this.room_message(n,o),!0}},s.prototype.run_ffz_command=function(e,t){var n=this.rooms[t];if(n&&n.room){if(!e){var o=document.querySelector("a.ffz-ui-toggle");if(o)return o.click();e="help"}var i=e.split(" "),a=i.shift().toLowerCase();this.log("Received Command: "+a,i,!0);var r,c=s.ffz_commands[a];if(c)try{r=c.bind(this)(n,i)}catch(l){this.log("Error Running Command - "+a+": "+l,n),r="There was an error running the command."}else r='There is no "'+a+'" command.';r&&this.room_message(n,r)}},s.ffz_commands.help=function(e,t){if(t&&t.length){var n=s.ffz_commands[t[0].toLowerCase()];return n?n.help?n.help:'No help is available for the command "'+t[0]+'".':'There is no "'+t[0]+'" command.'}var o=[];for(var i in s.ffz_commands)s.ffz_commands.hasOwnProperty(i)&&o.push(i);return"The available commands are: "+o.join(", ")},s.ffz_commands.help.help="Usage: /ffz help [command]\nList available commands, or show help for a specific command.",s.prototype.add_room=function(e,t){if(this.rooms[e])return this.log("Tried to add existing room: "+e);this.log("Adding Room: "+e);var s=this.rooms[e]={id:e,room:t,menu_sets:[],sets:[],css:null,needs_history:!1};this.ws_send("sub",e),!this.has_bttv&&this.settings.chat_history&&t&&(t.get("messages.length")||0)<10&&(this.ws_send("chat_history",[e,25],this._load_history.bind(this,e))||(s.needs_history=!0)),this.load_room(e)},s.prototype.remove_room=function(e){var t=this.rooms[e];if(t&&(this.log("Removing Room: "+e),(t.css||t.moderator_badge)&&o.update_css(this._room_style,e,null),this.ws_send("unsub",e),delete this.rooms[e],"_"!==e.charAt(0))){var s=this.emote_sets[t.set];s&&(s.users.removeObject(e),this.global_sets.contains(t.set)||s.users.length||this.unload_set(t.set))}},s.prototype._load_history=function(e,t,s){var n=this.rooms[e];if(n&&n.room){if(!t)return this.log("Error retrieving chat history for: "+e);if(this.log("Received "+s.length+" old messages for: "+e),s.length)return this._insert_history(e,s)}},s.prototype._show_deleted=function(e){var t=this.rooms[e];if(t&&t.room){var s=t.room.get("messages.0.ffz_old_messages");s&&s.length&&(t.room.set("messages.0.ffz_old_messages",void 0),this._insert_history(e,s))}},s.prototype._insert_history=function(e,t){var s=this.rooms[e];if(s&&s.room){var n=s.room,i=n.get("messages"),a=n.tmiSession||TMI._sessions&&TMI._sessions[0],r=(n.tmiRoom,0),c=t[t.length-1],l=new Date,h="string"==typeof c.date?o.parse_date(c.date):c.date,u=(l-h)/1e3,d=u>300,f=t.length,_=n.get("messages.0.ffz_alternate")||!1;d&&(_=!_);for(var f=t.length;f--;){var m=t[f];if("string"==typeof m.date&&(m.date=o.parse_date(m.date)),m.ffz_alternate=_=!_,m.room||(m.room=e),m.color||(m.color=m.tags&&m.tags.color?m.tags.color:a&&m.from?a.getColor(m.from.toLowerCase()):"#755000"),!m.labels||!m.labels.length){var p=m.labels=[];if(m.tags)if(m.tags.turbo&&p.push("turbo"),m.tags.subscriber&&p.push("subscriber"),m.from===e)p.push("owner");else{var g=m.tags["user-type"];("mod"===g||"staff"===g||"admin"===g||"global_mod"===g)&&p.push(g)}}if(m.style||("jtv"===m.from?m.style="admin":"twitchnotify"===m.from&&(m.style="notification")),m.cachedTokens&&m.cachedTokens.length||this.tokenize_chat_line(m,!0),n.shouldShowMessage(m)){if(!(i.length<n.get("messageBufferSize")))break;if(m.ffz_old_messages){var v=n.get("messageBufferSize")-(i.length+1);m.ffz_old_messages.length>v&&(m.ffz_old_messages=m.ffz_old_messages.slice(m.ffz_old_messages.length-v))}i.unshiftObject(m),r+=1}}if(d){var m={ffz_alternate:!_,color:"#755000",date:new Date,from:"frankerfacez_admin",style:"admin",message:"(Last message is "+o.human_time(u)+" old.)",room:e};if(this.tokenize_chat_line(m),n.shouldShowMessage(m))for(i.insertAt(r,m);i.length>n.get("messageBufferSize");)i.removeAt(0)}}},s.prototype.load_room=function(e,t,s){var o=this;jQuery.getJSON(n.API_SERVER+"v1/room/"+e).done(function(s){if(s.sets)for(var n in s.sets)s.sets.hasOwnProperty(n)&&o._load_set_json(n,void 0,s.sets[n]);o._load_room_json(e,t,s)}).fail(function(n){return 404==n.status?"function"==typeof t&&t(!1):(s=(s||0)+1,10>s?o.load_room(e,t,s):"function"==typeof t&&t(!1))})},s.prototype._load_room_json=function(e,t,s){return s&&s.room?(s=s.room,this.rooms[e]&&(s.room=this.rooms[e].room),s.needs_history=this.rooms[e]&&this.rooms[e].needs_history||!1,this.rooms[e]=s,(s.css||s.moderator_badge)&&o.update_css(this._room_style,e,i(s)+(s.css||"")),this.emote_sets.hasOwnProperty(s.set)||this.load_set(s.set),this.update_ui_link(),void(t&&t(!0,s))):"function"==typeof t&&t(!1)},s.prototype._modify_room=function(t){var s=this;t.reopen({init:function(){this._super();try{s.add_room(this.id,this),this.set("ffz_chatters",{})}catch(e){s.error("add_room: "+e)}},willDestroy:function(){this._super();try{s.remove_room(this.id)}catch(e){s.error("remove_room: "+e)}},clearMessages:function(e){var t=this;if(e)this.get("messages").forEach(function(n,o){n.from===e&&(t.set("messages."+o+".ffz_deleted",!0),s.settings.prevent_clear||t.set("messages."+o+".deleted",!0))});else if(s.settings.prevent_clear)this.addTmiMessage("A moderator's attempt to clear chat was ignored.");else{var n=t.get("messages");t.set("messages",[]),t.addMessage({style:"admin",message:i18n("Chat was cleared by a moderator"),ffz_old_messages:n})}},pushMessage:function(e){if(this.shouldShowMessage(e)){var t,s,n,o=this.get("messageBufferSize");for(this.get("messages").pushObject(e),t=this.get("messages.length"),s=t-o,n=0;s>n;n++)this.get("messages").removeAt(0);"admin"===e.style||"whisper"===e.style&&!this.ffz_whisper_room||this.incrementProperty("unreadCount",1)}},addMessage:function(e){try{if(e){var t="whisper"===e.style;if(s.settings.group_tabs&&s.settings.whisper_room&&(t&&!this.ffz_whisper_room||!t&&this.ffz_whisper_room))return;t||(e.room=this.get("id")),s.tokenize_chat_line(e)}}catch(n){s.error("Room addMessage: "+n)}return this._super(e)},setHostMode:function(e){var t=App.__container__.lookup("controller:chat");if(t&&t.get("currentChannelRoom")===this)return this._super(e)},send:function(e){if(!(s.settings.group_tabs&&s.settings.whisper_room&&this.ffz_whisper_room)){try{var t=e.split(" ",1)[0].toLowerCase();if("/ffz"===t)return this.set("messageToSend",""),void s.run_ffz_command(e.substr(5),this.get("id"));if("/"===t.charAt(0)&&s.run_command(e,this.get("id")))return void this.set("messageToSend","")}catch(n){s.error("send: "+n)}return this._super(e)}},ffzUpdateUnread:function(){if(s.settings.group_tabs){var e=App.__container__.lookup("controller:chat");e&&e.get("currentRoom")===this?this.resetUnreadCount():s._chatv&&s._chatv.ffzTabUnread(this.get("id"))}}.observes("unreadCount"),ffzInitChatterCount:function(){if(this.tmiRoom){var e=this;this.tmiRoom.list().done(function(t){var s={};t=t.data.chatters;for(var n=0;n<t.admins.length;n++)s[t.admins[n]]=!0;for(var n=0;n<t.global_mods.length;n++)s[t.global_mods[n]]=!0;for(var n=0;n<t.moderators.length;n++)s[t.moderators[n]]=!0;for(var n=0;n<t.staff.length;n++)s[t.staff[n]]=!0;for(var n=0;n<t.viewers.length;n++)s[t.viewers[n]]=!0;e.set("ffz_chatters",s),e.ffzUpdateChatters()})}},ffzUpdateChatters:function(t,n){var o=this.get("ffz_chatters")||{};t&&(o[t]=!0),n&&o[n]&&delete o[n],s.settings.chatter_count&&(s._cindex&&s._cindex.ffzUpdateChatters(),e.parent&&e.parent.postMessage&&e.parent.postMessage({from_ffz:!0,command:"chatter_count",message:Object.keys(this.get("ffz_chatters")||{}).length},"http://www.twitch.tv/"))},ffzPatchTMI:function(){if(!this.get("ffz_is_patched")&&this.get("tmiRoom")){s.settings.chatter_count&&this.ffzInitChatterCount();var e=this.get("tmiRoom"),t=this;e.ffz_notice_patched||(e.ffz_notice_patched=!0,e._roomConn.off("notice",e._onNotice,e),e._roomConn.on("notice",function(e){var t=e.target||e.params&&e.params[0]||this.ircChannel;t==this.ircChannel&&this._trigger("notice",{msgId:e.tags["msg-id"],message:e.message})},e));var n=e._roomConn._connection;if(!n.ffz_cap_patched){n.ffz_cap_patched=!0,n._send("CAP REQ :twitch.tv/membership"),n.on("opened",function(){this._send("CAP REQ :twitch.tv/membership")},n);var o=n._handleTmiPrivmsg.bind(n);n._handleTmiPrivmsg=function(e){return e.message&&"SPECIALUSER"===e.message.split(" ",1)[0]?void 0:o(e)}}if(e._roomConn._connection.off("message",e._roomConn._onIrcMessage,e._roomConn),e._roomConn._onIrcMessage=function(e){if(e.target==this.ircChannel)switch(e.command){case"JOIN":this._session&&this._session.nickname===e.sender?this._onIrcJoin(e):s.settings.chatter_count&&t.ffzUpdateChatters(e.sender);break;case"PART":this._session&&this._session.nickname===e.sender?(this._resetActiveState(),this._connection._exitedRoomConn(),this._trigger("exited")):s.settings.chatter_count&&t.ffzUpdateChatters(null,e.sender)}},e._roomConn._connection.on("message",e._roomConn._onIrcMessage,e._roomConn),!e.session.ffz_patched){e.session.ffz_patched=!0;{e.session._updateUserState.bind(e.session)}e.session._updateUserState=function(e,t){try{t.color&&this._onUserColorChanged(e,t.color),t["display-name"]&&this._onUserDisplayNameChanged(e,t["display-name"]),t.turbo&&this._onUserSpecialAdded(e,"turbo"),("staff"===t.user_type||"admin"===t.user_type||"global_mod"===t.user_type)&&this._onUserSpecialAdded(e,t["user-type"])}catch(n){s.error("SessionManager _updateUserState: "+n)}}}this.set("ffz_is_patched",!0)}}.observes("tmiRoom")})}},{"../constants":3,"../utils":29}],10:[function(){var t=e.FrankerFaceZ;t.prototype.setup_viewers=function(){this.log("Hooking the Ember Viewers controller.");var e=App.__container__.resolve("controller:viewers");this._modify_viewers(e)},t.prototype._modify_viewers=function(e){var s=this;e.reopen({lines:function(){var e=this._super();try{var n=[],o={},i=null,a=App.__container__.lookup("controller:channel"),r=this.get("parentController.model.id"),c=a&&a.get("id");if(c){var l=a.get("display_name");l&&(t.capitalization[c]=[l,Date.now()])}r!=c&&(c=null);for(var h=0;h<e.length;h++){var u=e[h];if(u.category)i=u.category,n.push(i),o[i]=[];else{var d=u.chatter.toLowerCase();if(!d)continue;d==c?(n.unshift("Broadcaster"),o.Broadcaster=[d]):o.hasOwnProperty(i)&&o[i].push(d)}}e=[];for(var h=0;h<n.length;h++){var f=n[h],_=o[f];if(_&&_.length)for(e.push({category:f}),e.push({chatter:""}),_.sort();_.length;){var d=_.shift();d=t.get_capitalization(d),e.push({chatter:d})}}}catch(m){s.error("ViewersController lines: "+m)}return e}.property("content.chatters")})}},{}],11:[function(t){var s=e.FrankerFaceZ,n=t("./constants"),o=t("./utils"),i=function(e){var t=e.margins,s="";return t||(t=(e.height-18)/-2+"px 0"),(e.urls[2]||e.urls[4])&&(s='url("'+e.urls[1]+'") 1x',e.urls[2]&&(s+=', url("'+e.urls[2]+'") 2x'),e.urls[4]&&(s+=', url("'+e.urls[4]+'") 4x'),s="-webkit-image-set("+s+"); image-set("+s+");"),".ffz-emote-"+e.id+' { background-image: url("'+e.urls[1]+'"); height: '+e.height+"px; width: "+e.width+"px; margin: "+t+(s?"; "+s:"")+(e.css?"; "+e.css:"")+"}\n"},a=function(e){return e.margins||e.css?i(e)+'img[src="'+e.urls[1]+'"] { '+(e.margins?"margin: "+e.margins+";":"")+(e.css||"")+" }\n":i(e)},r=a;s.prototype.setup_emoticons=function(){this.log("Preparing emoticon system."),this.emote_sets={},this.global_sets=[],this.default_sets=[],this._last_emote_id=0,this.emote_usage={},this.log("Creating emoticon style element.");var e=this._emote_style=document.createElement("style");e.id="ffz-emoticon-css",document.head.appendChild(e),this.log("Loading global emote sets."),this.load_global_sets(),this.log("Watching Twitch emoticon parser to ensure it loads."),this._twitch_emote_check=setTimeout(this.check_twitch_emotes.bind(this),1e4)},s.prototype.add_usage=function(e,t,s){var n=this.emote_usage[t]=this.emote_usage[t]||{};n[e]=(n[e]||0)+(s||1),this._emote_report_scheduled||(this._emote_report_scheduled=setTimeout(this._report_emotes.bind(this),3e4))},s.prototype._report_emotes=function(){this._emote_report_scheduled&&delete this._emote_report_scheduled;var e=this.emote_usage;this.emote_usage={},this.ws_send("emoticon_uses",[e],function(){},!0)},s.prototype.check_twitch_emotes=function(){this._twitch_emote_check&&(clearTimeout(this._twitch_emote_check),delete this._twitch_emote_check);var e;if(this.rooms)for(var t in this.rooms)if(this.rooms.hasOwnProperty(t)){e=this.rooms[t];break}if(!e||!e.room||!e.room.tmiSession)return void(this._twitch_emote_check=setTimeout(this.check_twitch_emotes.bind(this),1e4));var s=e.room.tmiSession._emotesParser,n=Object.keys(s.emoticonRegexToIds).length;if(!(n>0)){var o=s.emoticonSetIds;s.emoticonSetIds="",s.updateEmoticons(o),this._twitch_emote_check=setTimeout(this.check_twitch_emotes.bind(this),1e4)}},s.prototype.getEmotes=function(e,t){var s=this.users&&this.users[e],n=this.rooms&&this.rooms[t];return _.union(s&&s.sets||[],n&&n.set&&[n.set]||[],this.default_sets)},s.ws_commands.reload_set=function(e){this.emote_sets.hasOwnProperty(e)&&this.load_set(e)},s.ws_commands.load_set=function(e){this.load_set(e)},s.prototype._emote_tooltip=function(e){if(!e)return null;if(e._tooltip)return e._tooltip;var t=this.emote_sets[e.set_id],s=e.owner,n=t&&t.title||"Global";return e._tooltip="Emoticon: "+(e.hidden?"???":e.name)+"\nFFZ "+n+(s?"\nBy: "+s.display_name:""),e._tooltip},s.prototype.load_global_sets=function(e,t){var s=this;jQuery.getJSON(n.API_SERVER+"v1/set/global").done(function(e){s.default_sets=e.default_sets;
|
|
var t=s.global_sets=[],n=e.sets||{};for(var o in n)if(n.hasOwnProperty(o)){var i=n[o];t.push(o),s._load_set_json(o,void 0,i)}}).fail(function(n){return 404==n.status?"function"==typeof e&&e(!1):(t=t||0,t++,50>t?s.load_global_sets(e,t):"function"==typeof e&&e(!1))})},s.prototype.load_set=function(e,t,s){var o=this;jQuery.getJSON(n.API_SERVER+"v1/set/"+e).done(function(s){o._load_set_json(e,t,s&&s.set)}).fail(function(n){return 404==n.status?"function"==typeof t&&t(!1):(s=s||0,s++,10>s?o.load_set(e,t,s):"function"==typeof t&&t(!1))})},s.prototype.unload_set=function(e){var t=this.emote_sets[e];t&&(this.log("Unloading emoticons for set: "+e),o.update_css(this._emote_style,e,null),delete this.emote_sets[e])},s.prototype._load_set_json=function(e,t,s){if(!s)return"function"==typeof t&&t(!1);this.emote_sets[e]=s,s.users=[],s.count=0;var n="",i=s.emoticons;s.emoticons={};for(var a=0;a<i.length;a++){var c=i[a];c.klass="ffz-emote-"+c.id,c.set_id=e,c.srcSet=c.urls[1]+" 1x",c.urls[2]&&(c.srcSet+=", "+c.urls[2]+" 2x"),c.urls[4]&&(c.srcSet+=", "+c.urls[4]+" 4x"),c.regex="!"===c.name[c.name.length-1]?new RegExp("(^|\\W|\\b)("+c.name+")(?=\\W|$)","g"):new RegExp("(^|\\W|\\b)("+c.name+")\\b","g"),n+=r(c),s.count++,s.emoticons[c.id]=c}o.update_css(this._emote_style,e,n+(s.css||"")),this.log("Updated emoticons for set #"+e+": "+s.title,s),this._cindex&&this._cindex.ffzFixTitle(),this.update_ui_link(),t&&t(!0,s)}},{"./constants":3,"./utils":29}],12:[function(){var t=e.FrankerFaceZ;t.prototype.find_bttv=function(t,s){return this.has_bttv=!1,e.BTTVLOADED?this.setup_bttv(s||0):void(s>=6e4?this.log("BetterTTV was not detected after 60 seconds."):setTimeout(this.find_bttv.bind(this,t,(s||0)+t),t))},t.prototype.setup_bttv=function(e){this.log("BetterTTV was detected after "+e+"ms. Hooking."),this.has_bttv=!0,document.body.classList.remove("ffz-dark"),this._dark_style&&(this._dark_style.parentElement.removeChild(this._dark_style),delete this._dark_style),this.settings.group_tabs&&this._chatv&&this._chatv.ffzDisableTabs(),document.body.classList.remove("ffz-chat-colors"),document.body.classList.remove("ffz-chat-background"),this.is_dashboard&&this._update_subscribers();var t=BetterTTV.chat.helpers.sendMessage,s=this;BetterTTV.chat.helpers.sendMessage=function(e){var n=e.split(" ",1)[0].toLowerCase();return"/ffz"!==n?t(e):void s.run_ffz_command(e.substr(5),BetterTTV.chat.store.currentRoom)};var n,o=BetterTTV.chat.handlers.onPrivmsg;BetterTTV.chat.handlers.onPrivmsg=function(e,t){n=e;var s=o(e,t);return n=null,s};var i=BetterTTV.chat.templates.privmsg;BetterTTV.chat.templates.privmsg=function(e,t,o,a,r){try{return s.bttv_badges(r),'<div class="chat-line'+(e?" highlight":"")+(t?" action":"")+(o?" admin":"")+'" data-sender="'+(r.sender||"").toLowerCase()+'" data-room="'+n+'">'+BetterTTV.chat.templates.timestamp(r.time)+" "+(a?BetterTTV.chat.templates.modicons():"")+" "+BetterTTV.chat.templates.badges(r.badges)+BetterTTV.chat.templates.from(r.nickname,r.color)+BetterTTV.chat.templates.message(r.sender,r.message,r.emotes,t?r.color:!1)+"</div>"}catch(c){return s.log("Error: ",c),i(e,t,o,a,r)}};var a,r=BetterTTV.chat.templates.message;BetterTTV.chat.templates.message=function(e,t,n,o){try{o=o||!1;var i=encodeURIComponent(t);if("jtv"!==e){a=e;var c=BetterTTV.chat.templates.emoticonize(t,n);a=null;for(var l=0;l<c.length;l++)c[l]="string"==typeof c[l]?BetterTTV.chat.templates.bttvMessageTokenize(e,c[l]):c[l][0];t=c.join(" ")}return'<span class="message" '+(o?'style="color: '+o+'" ':"")+'data-raw="'+i+'" data-emotes="'+(n?encodeURIComponent(JSON.stringify(n)):"false")+'">'+t+"</span>"}catch(h){return s.log("Error: ",h),r(e,t,n,o)}};var c=BetterTTV.chat.templates.emoticonize;BetterTTV.chat.templates.emoticonize=function(e,t){var o=c(e,t),i=n||BetterTTV.getChannel(),r=i&&i.toLowerCase(),l=a&&a.toLowerCase(),h=s.getEmotes(l,r),t=[],u=s.get_user(),d=u&&u.login===l;return _.each(h,function(e){var n=s.emote_sets[e];n&&_.each(n.emoticons,function(e){_.any(o,function(t){return _.isString(t)&&t.match(e.regex)})&&t.push(e)})}),t.length?(_.each(t,function(e){var t=s._emote_tooltip(e),n=['<img class="emoticon" srcset="'+(e.srcSet||"")+'" src="'+e.urls[1]+'" alt="'+t+'" title="'+t+'" />'],i=o;if(o=[],!i||!i.length)return o;for(var a=0;a<i.length;a++){var c=i[a];if("string"==typeof c)for(var l=c.split(e.regex);l.length;){var h=l.shift();l.length?(h+=l.shift(),h&&o.push(h),l.shift(),o.push(n),d&&r&&s.add_usage(r,e.id)):o.push(h)}else o.push(c)}}),o):o},this.update_ui_link()}},{}],13:[function(){var t=e.FrankerFaceZ;t.prototype.find_emote_menu=function(t,s){return this.has_emote_menu=!1,e.emoteMenu&&emoteMenu.registerEmoteGetter?this.setup_emote_menu(s||0):void(s>=6e4?this.log("Emote Menu for Twitch was not detected after 60 seconds."):setTimeout(this.find_emote_menu.bind(this,t,(s||0)+t),t))},t.prototype.setup_emote_menu=function(e){this.log("Emote Menu for Twitch was detected after "+e+"ms. Registering emote enumerator."),emoteMenu.registerEmoteGetter("FrankerFaceZ",this._emote_menu_enumerator.bind(this))},t.prototype._emote_menu_enumerator=function(){for(var e=this.get_user(),s=e?e.login:null,n=App.__container__.lookup("controller:chat"),o=n?n.get("currentRoom.id"):null,i=this.getEmotes(s,o),a=[],r=0;r<i.length;r++){var c=this.emote_sets[i[r]];if(c&&c.emoticons)for(var l in c.emoticons)if(c.emoticons.hasOwnProperty(l)){var h=c.emoticons[l];if(!h.hidden){var u=c.title,d=c.icon||null;u=u?"FrankerFaceZ: "+u:"global"==c.id?"FrankerFaceZ Global Emotes":"globalevent"==c.id?"FrankerFaceZ Event Emotes":this.feature_friday&&c.id==this.feature_friday.set?"FrankerFaceZ "+this.feature_friday.title+": "+this.feature_friday.display_name:"FrankerFaceZ Set: "+t.get_capitalization(c.id),a.push({text:h.name,url:h.urls[1],hidden:!1,channel:u,badge:d})}}}return a}},{}],14:[function(t){var s=e.FrankerFaceZ=function(){s.instance=this,this._log_data=[],this.initialize()};s.get=function(){return s.instance};var n=s.version_info={major:3,minor:4,revision:2,toString:function(){return[n.major,n.minor,n.revision].join(".")+(n.extra||"")}};s.prototype.log=function(e,t,s,n){e="FFZ: "+e+(s?" -- "+JSON.stringify(t):""),this._log_data.push(e+(!s&&n?" -- "+JSON.stringify(t):"")),void 0!==t&&console.groupCollapsed&&console.dir?(console.groupCollapsed(e),-1!==navigator.userAgent.indexOf("Firefox/")?console.log(t):console.dir(t),console.groupEnd(e)):console.log(e)},s.prototype.error=function(e,t,s){e="FFZ Error: "+e+(s?" -- "+JSON.stringify(t):""),this._log_data.push(e),void 0!==t&&console.groupCollapsed&&console.dir?(console.groupCollapsed(e),-1!==navigator.userAgent.indexOf("Firefox/")?console.log(t):console.dir(t),console.groupEnd(e)):console.assert(!1,e)},s.prototype.paste_logs=function(){this._pastebin(this._log_data.join("\n"),function(e){return e?void console.log("FFZ: Your FrankerFaceZ log has been pasted to: "+e):console.log("FFZ Error: Unable to upload log to pastebin.")})},s.prototype._pastebin=function(e,t){jQuery.ajax({url:"http://putco.de/",type:"PUT",data:e,context:this}).success(function(e){t.bind(this)(e.trim()+".log")}).fail(function(){t.bind(this)(null)})},s.prototype.get_user=function(){if(e.PP&&PP.login)return PP;if(e.App){var t=App.__container__.lookup("controller:login");return t?t.get("userData"):void 0}},t("./ui/menu"),t("./settings"),t("./socket"),t("./emoticons"),t("./badges"),t("./tokenize"),t("./ember/channel"),t("./ember/room"),t("./ember/line"),t("./ember/chatview"),t("./ember/viewers"),t("./ember/moderation-card"),t("./debug"),t("./ext/betterttv"),t("./ext/emote_menu"),t("./featurefriday"),t("./ui/styles"),t("./ui/dark"),t("./ui/notifications"),t("./ui/viewer_count"),t("./ui/sub_count"),t("./ui/menu_button"),t("./ui/races"),t("./ui/my_emotes"),t("./ui/about_page"),t("./commands"),s.prototype.initialize=function(t,s){if(/^\/(?:$|user\/|p\/|settings|m\/|messages?\/)/.test(location.pathname))return void this.setup_normal(s);if(/\/[^\/]+\/dashboard/.test(location.pathname)&&!/bookmarks$/.test(location.pathname))return void this.setup_dashboard(s);var n=void 0!=e.App&&void 0!=App.__container__&&void 0!=App.__container__.resolve("model:room");return n?void this.setup_ember(s):(t=t||10,void(s>=6e4?this.log('Twitch application not detected in "'+location.toString()+'". Aborting.'):setTimeout(this.initialize.bind(this,t,(s||0)+t),t)))},s.prototype.setup_normal=function(t){var n=e.performance&&performance.now?performance.now():Date.now();this.log("Found non-Ember Twitch after "+(t||0)+' ms in "'+location+'". Initializing FrankerFaceZ version '+s.version_info),this.users={},this.load_settings(),this.setup_dark(),this.ws_create(),this.setup_emoticons(),this.setup_badges(),this.setup_notifications(),this.setup_css(),this.setup_menu(),this.find_bttv(10);var o=e.performance&&performance.now?performance.now():Date.now(),i=o-n;this.log("Initialization complete in "+i+"ms")},s.prototype.is_dashboard=!1,s.prototype.setup_dashboard=function(t){var n=e.performance&&performance.now?performance.now():Date.now();this.log("Found Twitch Dashboard after "+(t||0)+' ms in "'+location+'". Initializing FrankerFaceZ version '+s.version_info),this.users={},this.is_dashboard=!0,this.load_settings(),this.setup_dark(),this.ws_create(),this.setup_emoticons(),this.setup_badges(),this.setup_notifications(),this.setup_css(),this._update_subscribers(),this.setup_message_event(),this.find_bttv(10);var o=e.performance&&performance.now?performance.now():Date.now(),i=o-n;this.log("Initialization complete in "+i+"ms")},s.prototype.setup_ember=function(t){var n=e.performance&&performance.now?performance.now():Date.now();this.log("Found Twitch application after "+(t||0)+' ms in "'+location+'". Initializing FrankerFaceZ version '+s.version_info),this.users={},this.load_settings(),this.setup_dark(),this.ws_create(),this.setup_emoticons(),this.setup_badges(),this.setup_channel(),this.setup_room(),this.setup_line(),this.setup_chatview(),this.setup_viewers(),this.setup_mod_card(),this.setup_notifications(),this.setup_css(),this.setup_menu(),this.setup_my_emotes(),this.setup_races(),this.connect_extra_chat(),this.find_bttv(10),this.find_emote_menu(10),this.check_ff();var o=e.performance&&performance.now?performance.now():Date.now(),i=o-n;this.log("Initialization complete in "+i+"ms")},s.prototype.setup_message_event=function(){this.log("Listening for Window Messages."),e.addEventListener("message",this._on_window_message.bind(this),!1)},s.prototype._on_window_message=function(e){if(e.data&&e.data.from_ffz){var t=e.data;this.log("Window Message",t)}}},{"./badges":1,"./commands":2,"./debug":4,"./ember/channel":5,"./ember/chatview":6,"./ember/line":7,"./ember/moderation-card":8,"./ember/room":9,"./ember/viewers":10,"./emoticons":11,"./ext/betterttv":12,"./ext/emote_menu":13,"./featurefriday":15,"./settings":16,"./socket":17,"./tokenize":18,"./ui/about_page":19,"./ui/dark":20,"./ui/menu":21,"./ui/menu_button":22,"./ui/my_emotes":23,"./ui/notifications":24,"./ui/races":25,"./ui/styles":26,"./ui/sub_count":27,"./ui/viewer_count":28}],15:[function(t){var s=e.FrankerFaceZ,n=t("./constants");s.prototype.feature_friday=null,s.prototype.check_ff=function(e){e||this.log("Checking for Feature Friday data..."),jQuery.ajax(n.SERVER+"script/event.json",{cache:!1,dataType:"json",context:this}).done(function(e){return this._load_ff(e)}).fail(function(t){return 404==t.status?this._load_ff(null):(e=e||0,e++,10>e?setTimeout(this.check_ff.bind(this,e),250):this._load_ff(null))})},s.ws_commands.reload_ff=function(){this.check_ff()},s.prototype._feature_friday_ui=function(e,t,s){if(this.feature_friday&&this.feature_friday.channel!=e){this._emotes_for_sets(t,s,[this.feature_friday.set],this.feature_friday.title,this.feature_friday.icon,"FrankerFaceZ");var n=App.__container__.lookup("controller:channel");if(!n||n.get("id")!=this.feature_friday.channel){var o=this.feature_friday,i=document.createElement("div"),a=document.createElement("a");i.className="chat-menu-content",i.style.textAlign="center";var r=o.display_name+(o.live?" is live now!":"");a.className="button primary",a.classList.toggle("live",o.live),a.classList.toggle("blue",this.has_bttv&&BetterTTV.settings.get("showBlueButtons")),a.href="http://www.twitch.tv/"+o.channel,a.title=r,a.target="_new",a.innerHTML="<span>"+r+"</span>",i.appendChild(a),t.appendChild(i)}}},s.prototype._load_ff=function(e){this.feature_friday&&(this.global_sets.removeObject(this.feature_friday.set),this.default_sets.removeObject(this.feature_friday.set),this.feature_friday=null,this.update_ui_link()),e&&e.set&&e.channel&&(this.feature_friday={set:e.set,channel:e.channel,live:!1,title:e.title||"Feature Friday",display_name:s.get_capitalization(e.channel,this._update_ff_name.bind(this))},this.global_sets.push(e.set),this.default_sets.push(e.set),this.load_set(e.set),this._update_ff_live())},s.prototype._update_ff_live=function(){if(this.feature_friday){var e=this;Twitch.api.get("streams/"+this.feature_friday.channel).done(function(t){e.feature_friday.live=null!=t.stream,e.update_ui_link()}).always(function(){e.feature_friday.timer=setTimeout(e._update_ff_live.bind(e),12e4)})}},s.prototype._update_ff_name=function(e){this.feature_friday&&(this.feature_friday.display_name=e)}},{"./constants":3}],16:[function(t){var s=e.FrankerFaceZ,n=t("./constants");make_ls=function(e){return"ffz_setting_"+e},toggle_setting=function(e,t){var s=!this.settings.get(t);this.settings.set(t,s),e.classList.toggle("active",s)},s.settings_info={},s.prototype.load_settings=function(){this.log("Loading settings."),this.settings={};for(var t in s.settings_info)if(s.settings_info.hasOwnProperty(t)){var n=s.settings_info[t],o=n.storage_key||make_ls(t),i=n.hasOwnProperty("value")?n.value:void 0;if(localStorage.hasOwnProperty(o))try{i=JSON.parse(localStorage.getItem(o))}catch(a){this.log('Error loading value for "'+t+'": '+a)}this.settings[t]=i}this.settings.get=this._setting_get.bind(this),this.settings.set=this._setting_set.bind(this),this.settings.del=this._setting_del.bind(this),e.addEventListener("storage",this._setting_update.bind(this),!1)},s.settings_info.replace_twitch_menu={type:"boolean",value:!1,name:"Replace Twitch Emoticon Menu <span>Beta</span>",help:"Completely replace the default Twitch emoticon menu.",on_update:function(e){document.body.classList.toggle("ffz-menu-replace",e)}},s.menu_pages.settings={render:function(e,t){var n={},o=[];for(var i in s.settings_info)if(s.settings_info.hasOwnProperty(i)){var a=s.settings_info[i],r=a.category||"Miscellaneous",c=n[r];if(void 0!==a.visible&&null!==a.visible){var l=a.visible;if("function"==typeof a.visible&&(l=a.visible.bind(this)()),!l)continue}c||(o.push(r),c=n[r]=[]),c.push([i,a])}o.sort(function(e,t){var e=e.toLowerCase(),t=t.toLowerCase();return"debugging"===e&&(e="zzz"+e),"debugging"===t&&(t="zzz"+t),t>e?-1:e>t?1:0});for(var h=0;h<o.length;h++){var u=o[h],d=n[u],f=document.createElement("div"),_=document.createElement("div");_.className="heading",f.className="chat-menu-content",_.innerHTML=u,f.appendChild(_),d.sort(function(e,t){var e=e[1],t=t[1],s=e.type,n=t.type,o=e.name.toLowerCase(),i=t.name.toLowerCase();return n>s?-1:s>n?1:i>o?-1:o>i?1:0});for(var m=0;m<d.length;m++){var i=d[m][0],a=d[m][1],p=document.createElement("p"),g=this.settings.get(i);if(p.className="clearfix",this.has_bttv&&a.no_bttv){var v=document.createElement("span"),b=document.createElement("span");v.className="switch-label",v.innerHTML=a.name,b=document.createElement("span"),b.className="help",b.innerHTML="Disabled due to incompatibility with BetterTTV.",p.classList.add("disabled"),p.appendChild(v),p.appendChild(b)}else{if("boolean"==a.type){var y=document.createElement("a"),v=document.createElement("span");y.className="switch",y.classList.toggle("active",g),y.innerHTML="<span></span>",v.className="switch-label",v.innerHTML=a.name,p.appendChild(y),p.appendChild(v),y.addEventListener("click",toggle_setting.bind(this,y,i))}else{p.classList.add("option");var w=document.createElement("a");w.innerHTML=a.name,w.href="#",p.appendChild(w),w.addEventListener("click",a.method.bind(this))}if(a.help){var b=document.createElement("span");b.className="help",b.innerHTML=a.help,p.appendChild(b)}}f.appendChild(p)}t.appendChild(f)}},name:"Settings",icon:n.GEAR,sort_order:99999,wide:!0},s.prototype._setting_update=function(t){if(t||(t=e.event),t.key&&"ffz_setting_"===t.key.substr(0,12)){var n=t.key,o=n.substr(12),i=void 0,a=s.settings_info[o];if(!a){for(o in s.settings_info)if(s.settings_info.hasOwnProperty(o)&&(a=s.settings_info[o],a.storage_key==n))break;if(a.storage_key!=n)return}this.log("Updated Setting: "+o);try{i=JSON.parse(t.newValue)}catch(r){this.log('Error loading new value for "'+o+'": '+r),i=a.value||void 0}if(this.settings[o]=i,a.on_update)try{a.on_update.bind(this)(i,!1)}catch(r){this.log('Error running updater for setting "'+o+'": '+r)}}},s.prototype._setting_get=function(e){return this.settings[e]},s.prototype._setting_set=function(e,t){var n=s.settings_info[e],o=n.storage_key||make_ls(e),i=JSON.stringify(t);if(this.settings[e]=t,localStorage.setItem(o,i),this.log('Changed Setting "'+e+'" to: '+i),n.on_update)try{n.on_update.bind(this)(t,!0)}catch(a){this.log('Error running updater for setting "'+e+'": '+a)}},s.prototype._setting_del=function(e){var t=s.settings_info[e],n=t.storage_key||make_ls(e),o=void 0;if(localStorage.hasOwnProperty(n)&&localStorage.removeItem(n),delete this.settings[e],t&&(o=this.settings[e]=t.hasOwnProperty("value")?t.value:void 0),t.on_update)try{t.on_update.bind(this)(o,!0)}catch(i){this.log('Error running updater for setting "'+e+'": '+i)}}},{"./constants":3}],17:[function(){var t=e.FrankerFaceZ;t.prototype._ws_open=!1,t.prototype._ws_delay=0,t.ws_commands={},t.ws_on_close=[],t.prototype.ws_create=function(){var s,n=this;this._ws_last_req=0,this._ws_callbacks={},this._ws_pending=this._ws_pending||[];try{s=this._ws_sock=new WebSocket("ws://catbag.frankerfacez.com/")}catch(o){return this._ws_exists=!1,this.log("Error Creating WebSocket: "+o)}this._ws_exists=!0,s.onopen=function(){n._ws_open=!0,n._ws_delay=0,n.log("Socket connected.");var s=e.RequestFileSystem||e.webkitRequestFileSystem;s?s(e.TEMPORARY,100,n.ws_send.bind(n,"hello",["ffz_"+t.version_info,localStorage.ffzClientId],n._ws_on_hello.bind(n)),n.log.bind(n,"Operating in Incognito Mode.")):n.ws_send("hello",["ffz_"+t.version_info,localStorage.ffzClientId],n._ws_on_hello.bind(n));var o=n.get_user();if(o&&n.ws_send("setuser",o.login),n.is_dashboard){var i=location.pathname.match(/\/([^\/]+)/);i&&n.ws_send("sub",i[1])}for(var a in n.rooms)n.rooms.hasOwnProperty(a)&&n.rooms[a]&&(n.ws_send("sub",a),n.rooms[a].needs_history&&(n.rooms[a].needs_history=!1,!n.has_bttv&&n.settings.chat_history&&n.ws_send("chat_history",[a,25],n._load_history.bind(n,a))));var r=n._ws_pending;n._ws_pending=[];for(var c=0;c<r.length;c++){var l=r[c];n.ws_send(l[0],l[1],l[2])}},s.onclose=function(e){n.log("Socket closed. (Code: "+e.code+", Reason: "+e.reason+")"),n._ws_open=!1;for(var s=0;s<t.ws_on_close.length;s++)try{t.ws_on_close[s].bind(n)()}catch(o){n.log("Error on Socket Close Callback: "+o)}n._ws_delay<6e4?n._ws_delay+=1e3*(Math.floor(10*Math.random())+5):n._ws_delay=1e3*(Math.floor(60*Math.random())+30),setTimeout(n.ws_create.bind(n),n._ws_delay)},s.onmessage=function(e){var s,o,i=e.data.indexOf(" "),a=e.data.substr(i+1),r=parseInt(e.data.slice(0,i));if(i=a.indexOf(" "),-1===i&&(i=a.length),s=a.slice(0,i),a=a.substr(i+1),a&&(o=JSON.parse(a)),-1===r){var c=t.ws_commands[s];c?c.bind(n)(o):n.log("Invalid command: "+s,o,!1,!0)}else{var l="True"===s,h=n._ws_callbacks.hasOwnProperty(r);if(h)try{n._ws_callbacks[r](l,o)}catch(u){n.error("Callback for "+r+": "+u)}else n.log("Socket Reply to "+r+" - "+(l?"SUCCESS":"FAIL"),o,!1,!0)}}},t.prototype.ws_send=function(e,t,s,n){if(!this._ws_open){if(n){var o=this._ws_pending=this._ws_pending||[];return o.push([e,t,s]),!0}return!1}var i=++this._ws_last_req;return t=void 0!==t?" "+JSON.stringify(t):"",s&&(this._ws_callbacks[i]=s),this._ws_sock.send(i+" "+e+t),i},t.prototype._ws_on_hello=function(e,s){if(!e)return this.log("Error Saying Hello: "+s);localStorage.ffzClientId=s,this.log("Client ID: "+s);var n={},o=n.settings={};for(var i in t.settings_info)o[i]=this.settings[i];o.keywords=this.settings.keywords.length,o.banned_words=this.settings.banned_words.length,n.bttv=this.has_bttv||!!document.head.querySelector('script[src*="betterttv"]'),n["user-agent"]=navigator.userAgent,n.screen=[screen.width,screen.height],n.language=navigator.language,n.platform=navigator.platform,this.ws_send("survey",[n])},t.ws_commands.do_authorize=function(e){var s;for(var n in this.rooms)if(this.rooms.hasOwnProperty(n)){var o=this.rooms[n];if(o&&o.room&&!o.room.get("roomProperties.eventchat")&&!o.room.get("isGroupRoom")&&o.room.tmiRoom){var i=o.room.tmiRoom._getConnection();if(i.isConnected){s=i;break}}}s?s._send("PRIVMSG #frankerfacezauthorizer :AUTH "+e):setTimeout(t.ws_commands.do_authorize.bind(this,e),5e3)}},{}],18:[function(t){{var s,n=e.FrankerFaceZ,o=t("./utils"),i="http://static-cdn.jtvnw.net/emoticons/v1/",a=function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},r="[\\s`~<>!-#%-\\x2A,-/:;\\x3F@\\x5B-\\x5D_\\x7B}\\u00A1\\u00A7\\u00AB\\u00B6\\u00B7\\u00BB\\u00BF\\u037E\\u0387\\u055A-\\u055F\\u0589\\u058A\\u05BE\\u05C0\\u05C3\\u05C6\\u05F3\\u05F4\\u0609\\u060A\\u060C\\u060D\\u061B\\u061E\\u061F\\u066A-\\u066D\\u06D4\\u0700-\\u070D\\u07F7-\\u07F9\\u0830-\\u083E\\u085E\\u0964\\u0965\\u0970\\u0AF0\\u0DF4\\u0E4F\\u0E5A\\u0E5B\\u0F04-\\u0F12\\u0F14\\u0F3A-\\u0F3D\\u0F85\\u0FD0-\\u0FD4\\u0FD9\\u0FDA\\u104A-\\u104F\\u10FB\\u1360-\\u1368\\u1400\\u166D\\u166E\\u169B\\u169C\\u16EB-\\u16ED\\u1735\\u1736\\u17D4-\\u17D6\\u17D8-\\u17DA\\u1800-\\u180A\\u1944\\u1945\\u1A1E\\u1A1F\\u1AA0-\\u1AA6\\u1AA8-\\u1AAD\\u1B5A-\\u1B60\\u1BFC-\\u1BFF\\u1C3B-\\u1C3F\\u1C7E\\u1C7F\\u1CC0-\\u1CC7\\u1CD3\\u2010-\\u2027\\u2030-\\u2043\\u2045-\\u2051\\u2053-\\u205E\\u207D\\u207E\\u208D\\u208E\\u2329\\u232A\\u2768-\\u2775\\u27C5\\u27C6\\u27E6-\\u27EF\\u2983-\\u2998\\u29D8-\\u29DB\\u29FC\\u29FD\\u2CF9-\\u2CFC\\u2CFE\\u2CFF\\u2D70\\u2E00-\\u2E2E\\u2E30-\\u2E3B\\u3001-\\u3003\\u3008-\\u3011\\u3014-\\u301F\\u3030\\u303D\\u30A0\\u30FB\\uA4FE\\uA4FF\\uA60D-\\uA60F\\uA673\\uA67E\\uA6F2-\\uA6F7\\uA874-\\uA877\\uA8CE\\uA8CF\\uA8F8-\\uA8FA\\uA92E\\uA92F\\uA95F\\uA9C1-\\uA9CD\\uA9DE\\uA9DF\\uAA5C-\\uAA5F\\uAADE\\uAADF\\uAAF0\\uAAF1\\uABEB\\uFD3E\\uFD3F\\uFE10-\\uFE19\\uFE30-\\uFE52\\uFE54-\\uFE61\\uFE63\\uFE68\\uFE6A\\uFE6B\\uFF01-\\uFF03\\uFF05-\\uFF0A\\uFF0C-\\uFF0F\\uFF1A\\uFF1B\\uFF1F\\uFF20\\uFF3B-\\uFF3D\\uFF3F\\uFF5B\\uFF5D\\uFF5F-\\uFF65]";new RegExp(r+"*,"+r+"*")}try{s=e.require&&e.require("ember-twitch-chat/helpers/chat-line-helpers")}catch(c){}n.prototype.tokenize_chat_line=function(t,o){if(t.cachedTokens)return t.cachedTokens;var i=t.message,a=this.get_user(),r=t.room,c=a&&t.from===a.login,l=t.tags&&t.tags.emotes,h=[i];h=s.linkifyMessage(h),a&&a.login&&(h=s.mentionizeMessage(h,a.login,c)),h=s.emoticonizeMessage(h,l),h=this._remove_banned(h),h=this.tokenize_emotes(t.from,r,h,c);var u=t.tags&&t.tags["display-name"];if(u&&u.length&&(n.capitalization[t.from]=[u.trim(),Date.now()]),!c){h=this.tokenize_mentions(h);for(var d=0;d<h.length;d++){var f=h[d];if(!_.isString(f)&&f.mentionedUser&&!f.own&&"whisper"!==t.style){if(t.ffz_has_mention=!0,r&&!this.has_bttv&&this.settings.group_tabs&&this._chatv&&this._chatv._ffz_tabs){var m=this._chatv._ffz_tabs.querySelector('.ffz-chat-tab[data-room="'+r+'"]');m&&!m.classList.contains("active")&&m.classList.add("tab-mentioned")}if(this._chatv&&this.settings.highlight_notifications&&!document.hasFocus()&&!o){var p,g=this.rooms[r]&&this.rooms[r].room;p=g&&g.get("isGroupRoom")?g.get("tmiRoom.displayName"):n.get_capitalization(r),u=u||Twitch.display.capitalize(t.from),i="action"===t.style?"* "+u+" "+i:u+": "+i;this.show_notification(i,"Twitch Chat Mention in "+p,r,6e4,function(){e.focus();var t=App.__container__.lookup("controller:chat");g&&t&&t.focusRoom(g)})}break}}}return t.cachedTokens=h,h},n.prototype.tokenize_line=function(e,t,n,o){if("string"==typeof n&&(n=[n]),s&&s.linkifyMessage&&(n=s.linkifyMessage(n)),s&&s.mentionizeMessage){var i=this.get_user();i&&i.login&&(n=s.mentionizeMessage(n,i.login,e===i.login))}return o||(n=this.tokenize_emotes(e,t,n)),n},n.prototype.render_tokens=function(e,t){return _.map(e,function(e){if(e.emoticonSrc)return'<img class="emoticon tooltip" src="'+e.emoticonSrc+'" alt="'+e.altText+'" title="'+e.altText+'">';if(e.isLink){if(!t&&void 0!==t)return e.href;var s=e.href;if(s.indexOf("@")>-1&&(-1===s.indexOf("/")||s.indexOf("@")<s.indexOf("/")))return'<a href="mailto:'+s+'">'+s+"</a>";var n=(s.match(/^https?:\/\//)?"":"http://")+s;return'<a href="'+n+'" target="_blank">'+s+"</a>"}return e.mentionedUser?'<span class="'+(e.own?"mentioning":"mentioned")+'">'+e.mentionedUser+"</span>":o.sanitize(e.deletedLink?e.text:e)}).join("")},n.prototype.tokenize_title_emotes=function(e){var t=this,s=App.__container__.lookup("controller:channel"),n=s&&s.get("product.emoticons"),o=[];return _.isString(e)&&(e=[e]),_.each(_.union(t.__twitch_global_emotes||[],n),function(t){if(t&&"inactive"!==t.state){var s=new RegExp("\\b"+t.regex+"\\b");_.any(e,function(e){return _.isString(e)&&e.match(s)})&&o.push(t)}}),(void 0===t.__twitch_global_emotes||null===t.__twitch_global_emotes)&&(t.__twitch_global_emotes=!1,Twitch.api.get("chat/emoticon_images",{emotesets:"0,42"}).done(function(e){if(!e||!e.emoticon_sets||!e.emoticon_sets[0])return void(t.__twitch_global_emotes=[]);var s=t.__twitch_global_emotes=[];e=e.emoticon_sets[0];for(var n=0;n<e.length;n++){var o=e[n];s.push({regex:o.code,url:i+o.id+"/1.0"})}t._cindex&&t._cindex.ffzFixTitle()}).fail(function(){setTimeout(function(){t.__twitch_global_emotes=null},5e3)})),o.length?("string"==typeof e&&(e=[e]),_.each(o,function(t){var s={isEmoticon:!0,srcSet:t.url+" 1x",emoticonSrc:t.url,altText:t.regex},n=new RegExp("\\b"+t.regex+"\\b");e=_.compact(_.flatten(_.map(e,function(e){if(_.isObject(e))return e;var t=e.split(n),o=[];return t.forEach(function(e,n){o.push(e),n!==t.length-1&&o.push(s)}),o})))}),e):e},n.prototype.tokenize_emotes=function(e,t,s,n){var o=this,i=this.getEmotes(e,t),a=[];return _.each(i,function(e){var t=o.emote_sets[e];t&&_.each(t.emoticons,function(e){_.any(s,function(t){return _.isString(t)&&t.match(e.regex)})&&a.push(e)})}),a.length?("string"==typeof s&&(s=[s]),_.each(a,function(e){var i={srcSet:e.srcSet,emoticonSrc:e.urls[1]+'" data-ffz-emote="'+encodeURIComponent(JSON.stringify([e.id,e.set_id])),altText:e.hidden?"???":e.name};s=_.compact(_.flatten(_.map(s,function(s){if(_.isObject(s))return s;for(var a=s.split(e.regex),r=[];a.length;){var c=a.shift();a.length?(c+=a.shift(),c&&r.push(c),a.shift(),r.push(i),n&&t&&o.add_usage(t,e.id)):r.push(c)}return r})))}),s):s},n._regex_cache={},n._get_regex=function(e){return n._regex_cache[e]=n._regex_cache[e]||RegExp("\\b"+a(e)+"\\b","ig")},n._words_to_regex=function(e){var t=n._regex_cache[e];if(!t){for(var s="",o=0;o<e.length;o++)e[o]&&(s+=(s?"|":"")+a(e[o]));t=n._regex_cache[e]=new RegExp("(^|.*?"+r+")("+s+")(?=$|"+r+")","ig")}return t},n.prototype.tokenize_mentions=function(e){var t=this.settings.keywords;if(!t||!t.length)return e;"string"==typeof e&&(e=[e]);for(var s=n._words_to_regex(t),o=[],i=0;i<e.length;i++){var a=e[i];_.isString(a)&&a.match(s)?(a=a.replace(s,function(e,t,s){return o.push(t),o.push({mentionedUser:s,own:!1}),""}),a&&o.push(a)):o.push(a)}return o}},{"./utils":29}],19:[function(t){var s=e.FrankerFaceZ,n=t("../constants");s.menu_pages.about={name:"About",icon:n.HEART,sort_order:1e5,render:function(e,t){var n=this.rooms[e.get("context.currentRoom.id")],o=!1,i=this;if(n&&n.set){var a=this.emote_sets[n.set];a&&a.count>0&&(o=!0)}var r=document.createElement("div"),c="";c+="<h1>FrankerFaceZ</h1>",c+='<div class="ffz-about-subheading">new ways to woof</div>',r.className="chat-menu-content center",r.innerHTML=c,t.appendChild(r);var l=0,h=r.querySelector("h1");h&&h.addEventListener("click",function(){if(h.style.cursor="pointer",l++,l>=3){l=0;var e=document.querySelector(".app-main")||document.querySelector(".ember-chat-container");e&&e.classList.toggle("ffz-flip")}setTimeout(function(){l=0,h.style.cursor=""},2e3)});var u=document.createElement("div"),d=document.createElement("a"),f="To use custom emoticons in "+(o?"this channel":"tons of channels")+", get FrankerFaceZ from http://www.frankerfacez.com";d.className="button primary",d.innerHTML="Advertise in Chat",d.addEventListener("click",this._add_emote.bind(this,e,f)),u.appendChild(d);var _=document.createElement("a");_.className="button ffz-donate",_.href="https://www.frankerfacez.com/donate",_.target="_new",_.innerHTML="Donate",u.appendChild(_),u.className="chat-menu-content center",t.appendChild(u);var m=document.createElement("div");c='<table class="ffz-about-table">',c+='<tr><th colspan="4">Developers</th></tr>',c+='<tr><td>Dan Salvato</td><td><a class="twitch" href="http://www.twitch.tv/dansalvato" title="Twitch" target="_new"> </a></td><td><a class="twitter" href="https://twitter.com/dansalvato1" title="Twitter" target="_new"> </a></td><td><a class="youtube" href="https://www.youtube.com/user/dansalvato1" title="YouTube" target="_new"> </a></td></tr>',c+='<tr><td>Stendec</td><td><a class="twitch" href="http://www.twitch.tv/sirstendec" title="Twitch" target="_new"> </a></td><td><a class="twitter" href="https://twitter.com/SirStendec" title="Twitter" target="_new"> </a></td><td><a class="youtube" href="https://www.youtube.com/channel/UCnxuvmK1DCPCXSJ-mXIh4KQ" title="YouTube" target="_new"> </a></td></tr>',c+='<tr class="debug"><td>Version '+s.version_info+'</td><td colspan="3"><a href="#" id="ffz-debug-logs">Logs</a></td></tr>',m.className="chat-menu-content center",m.innerHTML=c;var p=!1;m.querySelector("#ffz-debug-logs").addEventListener("click",function(){p||(p=!0,i._pastebin(i._log_data.join("\n"),function(e){p=!1,e?prompt("Your FrankerFaceZ logs have been uploaded to the URL:",e):alert("There was an error uploading the FrankerFaceZ logs.")}))}),t.appendChild(m)}}},{"../constants":3}],20:[function(t){var s=e.FrankerFaceZ,n=t("../constants");s.settings_info.twitch_chat_dark={type:"boolean",value:!1,visible:!1},s.settings_info.dark_twitch={type:"boolean",value:!1,no_bttv:!0,name:"Dark Twitch",help:"Apply a dark background to channels and other related pages for easier viewing.",on_update:function(t){if(!this.has_bttv){document.body.classList.toggle("ffz-dark",t);var s=e.App?App.__container__.lookup("controller:settings").get("model"):void 0;t?(this._load_dark_css(),s&&this.settings.set("twitch_chat_dark",s.get("darkMode")),s&&s.set("darkMode",!0)):s&&s.set("darkMode",this.settings.twitch_chat_dark)}}},s.prototype.setup_dark=function(){this.has_bttv||(document.body.classList.toggle("ffz-dark",this.settings.dark_twitch),this.settings.dark_twitch&&(e.App&&App.__container__.lookup("controller:settings").set("model.darkMode",!0),this._load_dark_css()))},s.prototype._load_dark_css=function(){if(!this._dark_style){this.log("Injecting FrankerFaceZ Dark Twitch CSS.");var e=this._dark_style=document.createElement("link");e.id="ffz-dark-css",e.setAttribute("rel","stylesheet"),e.setAttribute("href",n.SERVER+"script/dark.css?_="+Date.now()),document.head.appendChild(e)}}},{"../constants":3}],21:[function(t){var s=e.FrankerFaceZ,n=t("../constants"),o=t("../utils"),i="http://static-cdn.jtvnw.net/emoticons/v1/";s.prototype.setup_menu=function(){this.log("Installing mouse-up event to auto-close menus.");var e=this;jQuery(document).mouseup(function(t){var s,n=e._popup;n&&(n=jQuery(n),s=n.parent(),s.is(t.target)||0!==s.has(t.target).length||(n.remove(),delete e._popup,e._popup_kill&&e._popup_kill(),delete e._popup_kill))}),document.body.classList.toggle("ffz-menu-replace",this.settings.replace_twitch_menu)},s.menu_pages={},s.prototype.build_ui_popup=function(e){var t=this._popup;if(t)return t.parentElement.removeChild(t),delete this._popup,this._popup_kill&&this._popup_kill(),void delete this._popup_kill;
|
|
var o=document.createElement("div"),i=document.createElement("div"),a=document.createElement("ul"),r=this.has_bttv?BetterTTV.settings.get("darkenedMode"):!1;o.className="emoticon-selector chat-menu ffz-ui-popup",i.className="emoticon-selector-box dropmenu",o.appendChild(i),o.classList.toggle("dark",r);var c=document.createElement("div");c.className="ffz-ui-menu-page",i.appendChild(c),a.className="menu clearfix",i.appendChild(a);var l=document.createElement("li");l.className="title",l.innerHTML="<span>"+(n.DEBUG?"[DEV] ":"")+"FrankerFaceZ</span>",a.appendChild(l);var h=[];for(var u in s.menu_pages)if(s.menu_pages.hasOwnProperty(u)){var d=s.menu_pages[u];try{if(!d||d.hasOwnProperty("visible")&&(!d.visible||"function"==typeof d.visible&&!d.visible.bind(this)(e)))continue}catch(f){this.error("menu_pages "+u+" visible: "+f);continue}h.push([d.sort_order||0,u,d])}h.sort(function(e,t){if(e[0]<t[0])return 1;if(e[0]>t[0])return-1;var s=e[1].toLowerCase(),n=t[1].toLowerCase();return n>s?1:s>n?-1:0});for(var _=0;_<h.length;_++){var u=h[_][1],d=h[_][2],m=document.createElement("li"),p=document.createElement("a");m.className="item",m.id="ffz-menu-page-"+u,p.title=d.name,p.innerHTML=d.icon,jQuery(p).tipsy(),p.addEventListener("click",this._ui_change_page.bind(this,e,i,a,c,u)),m.appendChild(p),a.appendChild(m)}this._ui_change_page(e,i,a,c,this._last_page||"channel"),this._popup=o,c.style.maxHeight=Math.max(200,e.$().height()-172)+"px",e.$(".chat-interface").append(o)},s.prototype._ui_change_page=function(e,t,n,o,i){this._last_page=i,o.innerHTML="",o.setAttribute("data-page",i);var a=document.querySelector(".app-main")||document.querySelector(".ember-chat-container");t.style.maxWidth=!s.menu_pages[i].wide||"function"==typeof s.menu_pages[i].wide&&!s.menu_pages[i].wide.bind(this)()?"":(a.offsetWidth<640?a.offsetWidth-40:600)+"px";for(var r=n.querySelectorAll("li.active"),c=0;c<r.length;c++)r[c].classList.remove("active");var l=n.querySelector("#ffz-menu-page-"+i);l?l.classList.add("active"):this.log("No matching page: "+i),s.menu_pages[i].render.bind(this)(e,o)},s.menu_pages.channel={render:function(e,t){var s=e.get("controller.currentRoom.id"),n=this.rooms[s],a=!1;if(this.settings.replace_twitch_menu){var r=n.room.get("product");if(r&&!r.get("error")){a=!0;var c=App.__container__.resolve("model:ticket").find("user",{channel:s}),l=c?c.get("content"):!1,h=n.room.get("badgeSet.subscriber.image"),u=document.createElement("div"),d=document.createElement("div"),f=0;l=l&&l.length>0,u.className="emoticon-grid",d.className="heading",h&&(d.style.backgroundImage='url("'+h+'")'),d.innerHTML='<span class="right">Twitch</span>Subscriber Emoticons',u.appendChild(d);for(var _=r.get("emoticons"),m=0;m<_.length;m++){var p=_[m];if("active"===p.state){var g=document.createElement("span"),v=l||!p.subscriber_only,b='image-set(url("'+i+p.id+'/1.0") 1x, url("'+i+p.id+'/2.0") 2x, url("'+i+p.id+'/3.0") 4x)';g.className="emoticon tooltip"+(v?"":" locked"),g.style.backgroundImage='url("'+i+p.id+'/1.0")',g.style.backgroundImage="-webkit-"+b,g.style.backgroundImage="-moz-"+b,g.style.backgroundImage="-ms-"+b,g.style.backgroundImage=b,g.style.width=p.width+"px",g.style.height=p.height+"px",g.title=p.regex,v&&g.addEventListener("click",this._add_emote.bind(this,e,p.regex)),u.appendChild(g),f++}}if(f>0&&t.appendChild(u),l){var y=c.get("content");if(y=y.length>0?y[y.length-1]:void 0,y&&y.purchase_profile&&!y.purchase_profile.will_renew){var w=o.parse_date(y.access_end||"");z=document.createElement("div"),k=document.createElement("div"),C=document.createElement("span"),end_time=w?Math.floor((w.getTime()-Date.now())/1e3):null,z.className="subscribe-message",k.className="non-subscriber-message",z.appendChild(k),C.className="unlock-text",C.innerHTML="Subscription expires in "+o.time_to_string(end_time,!0,!0),k.appendChild(C),t.appendChild(z)}}else{var z=document.createElement("div"),k=document.createElement("div"),C=document.createElement("span"),F=document.createElement("a");z.className="subscribe-message",k.className="non-subscriber-message",z.appendChild(k),C.className="unlock-text",C.innerHTML="Subscribe to unlock Emoticons",k.appendChild(C),F.className="action subscribe-button button primary",F.href=r.get("product_url"),F.innerHTML='<span class="subscribe-text">Subscribe</span><span class="subscribe-price">'+r.get("price")+"</span>",k.appendChild(F),t.appendChild(z)}}}this._emotes_for_sets(t,e,n&&n.set&&[n.set]||[],this.feature_friday||a?"Channel Emoticons":null,"http://cdn.frankerfacez.com/script/devicon.png","FrankerFaceZ"),this._feature_friday_ui(s,t,e)},name:"Channel",icon:n.ZREKNARF},s.prototype._emotes_for_sets=function(e,t,s,n,o,i){var a=document.createElement("div"),r=0;if(a.className="emoticon-grid",null!=n){var c=document.createElement("div");if(c.className="heading",i){var l=document.createElement("span");l.className="right",l.appendChild(document.createTextNode(i)),c.appendChild(l)}c.appendChild(document.createTextNode(n)),o&&(c.style.backgroundImage='url("'+o+'")'),a.appendChild(c)}for(var h=[],u=0;u<s.length;u++){var d=this.emote_sets[s[u]];if(d&&d.emoticons)for(var f in d.emoticons)d.emoticons.hasOwnProperty(f)&&!d.emoticons[f].hidden&&h.push(d.emoticons[f])}h.sort(function(e,t){var s=e.name.toLowerCase(),n=t.name.toLowerCase();return n>s?-1:s>n?1:0});for(var u=0;u<h.length;u++){var _=h[u],m=null;(_.urls[2]||_.urls[4])&&(m='url("'+_.urls[1]+'") 1x',_.urls[2]&&(m+=', url("'+_.urls[2]+'") 2x'),_.urls[4]&&(m+=', url("'+_.urls[4]+'") 4x')),r++;var l=document.createElement("span");if(l.className="emoticon tooltip",l.style.backgroundImage='url("'+_.urls[1]+'")',m){var p="image-set("+m+")";l.style.backgroundImage="-webkit-"+p,l.style.backgroundImage="-moz-"+p,l.style.backgroundImage="-ms-"+p,l.style.backgroundImage=p}l.style.width=_.width+"px",l.style.height=_.height+"px",l.title=this._emote_tooltip(_),l.addEventListener("click",this._add_emote.bind(this,t,_.name)),a.appendChild(l)}r||(a.innerHTML+="This channel has no emoticons.",a.className="emoticon-grid ffz-no-emotes center"),e.appendChild(a)},s.prototype._add_emote=function(e,t){var s,n,o;this.has_bttv?(s=e.get("element").querySelector("textarea"),n=s.value):(o=e.get("controller.currentRoom"),n=o.get("messageToSend")||""),n+=(n&&" "!==n.substr(-1)?" ":"")+(t.name||t),s?s.value=n:o.set("messageToSend",n)}},{"../constants":3,"../utils":29}],22:[function(t){var s=e.FrankerFaceZ,n=t("../constants");s.prototype.build_ui_link=function(e){var t=document.createElement("a");return t.className="ffz-ui-toggle",t.innerHTML=n.CHAT_BUTTON,t.addEventListener("click",this.build_ui_popup.bind(this,e)),this.update_ui_link(t),t},s.prototype.update_ui_link=function(t){var s=e.App&&App.__container__.lookup("controller:chat");if(t=t||document.querySelector("a.ffz-ui-toggle"),t&&s){var n=s.get("currentRoom.id"),o=this.rooms[n],i=!1,a=this.has_bttv?BetterTTV.settings.get("darkenedMode"):!1,r=this.has_bttv?BetterTTV.settings.get("showBlueButtons"):!1,c=this.feature_friday&&this.feature_friday.live;if(o&&o.set){var l=this.emote_sets[o.set];l&&l.count>0&&(i=!0)}t.classList.toggle("no-emotes",!i),t.classList.toggle("live",c),t.classList.toggle("dark",a),t.classList.toggle("blue",r)}}},{"../constants":3}],23:[function(t){var s=e.FrankerFaceZ,n=t("../constants"),o=t("../utils"),i="http://static-cdn.jtvnw.net/emoticons/v1/",a={"#-?[\\\\/]":"#-/",":-?(?:7|L)":":-7","\\<\\;\\]":"<]","\\:-?(S|s)":":-S","\\:-?\\\\":":-\\","\\:\\>\\;":":>","B-?\\)":"B-)","\\:-?[z|Z|\\|]":":-Z","\\:-?\\)":":-)","\\:-?\\(":":-(","\\:-?(p|P)":":-P","\\;-?(p|P)":";-P","\\<\\;3":"<3","\\:-?[\\\\/]":":-/","\\;-?\\)":";-)","R-?\\)":"R-)","[o|O](_|\\.)[o|O]":"O.o","\\:-?D":":-D","\\:-?(o|O)":":-O","\\>\\;\\(":">(","Gr(a|e)yFace":"GrayFace"};s.settings_info.global_emotes_in_menu={type:"boolean",value:!1,name:"Display Global Emotes in My Emotes",help:"Display the global Twitch emotes in the My Emoticons menu."},s.prototype.setup_my_emotes=function(){if(this._twitch_set_to_channel={},this._twitch_badges={},localStorage.ffzTwitchSets)try{this._twitch_set_to_channel=JSON.parse(localStorage.ffzTwitchSets),this._twitch_badges=JSON.parse(localStorage.ffzTwitchBadges)}catch(e){}this._twitch_set_to_channel[0]="global",this._twitch_set_to_channel[33]="tfaces",this._twitch_set_to_channel[42]="tfaces",this._twitch_badges.global="//cdn.frankerfacez.com/script/twitch_logo.png",this._twitch_badges.tfaces=this._twitch_badges.turbo="//cdn.frankerfacez.com/script/turbo_badge.png"},s.menu_pages.my_emotes={name:"My Emoticons",icon:n.EMOTE,visible:function(e){var t=this.get_user(),s=e.get("controller.currentRoom.tmiSession"),n=t&&this.users[t.login]&&this.users[t.login].sets||[],o=(s&&s.getEmotes()||{emoticon_sets:{}}).emoticon_sets;return n.length||o&&Object.keys(o).length},render:function(e,t){var n=e.get("controller.currentRoom.tmiSession"),o=(n&&n.getEmotes()||{emoticon_sets:{}}).emoticon_sets,i=[];for(var a in o)o.hasOwnProperty(a)&&!this._twitch_set_to_channel.hasOwnProperty(a)&&i.push(a);if(!i.length)return s.menu_pages.my_emotes.draw_menu.bind(this)(e,t,o);var r=this,c=function(){if(i.length){i=[];var n={};for(var a in o)r._twitch_set_to_channel[a]&&(n[a]=o[a]);return s.menu_pages.my_emotes.draw_menu.bind(r)(e,t,n)}};this.ws_send("twitch_sets",i,function(n,a){if(i.length){if(i=[],n){for(var l in a)a.hasOwnProperty(l)&&(r._twitch_set_to_channel[l]=a[l]);return localStorage.ffzTwitchSets=JSON.stringify(r._twitch_set_to_channel),s.menu_pages.my_emotes.draw_menu.bind(r)(e,t,o)}c()}}),setTimeout(c,2e3)},draw_twitch_set:function(e,t,n){var r,c=document.createElement("div"),l=document.createElement("div"),h=this._twitch_set_to_channel[t];if(r="global"===h?"Global Emoticons":"turbo"===h?"Twitch Turbo":s.get_capitalization(h,function(e){c.innerHTML='<span class="right">Twitch</span>'+o.sanitize(e)}),c.className="heading",c.innerHTML='<span class="right">Twitch</span>'+o.sanitize(r),this._twitch_badges[h])c.style.backgroundImage='url("'+this._twitch_badges[h]+'")';else{var u=this;Twitch.api.get("chat/"+h+"/badges",null,{version:3}).done(function(e){e.subscriber&&e.subscriber.image&&(u._twitch_badges[h]=e.subscriber.image,localStorage.ffzTwitchBadges=JSON.stringify(u._twitch_badges),c.style.backgroundImage='url("'+e.subscriber.image+'")')})}l.className="emoticon-grid",l.appendChild(c);for(var d=0;d<n.length;d++){var f=n[d],_=a[f.code]||f.code,m=document.createElement("span"),p='image-set(url("'+i+f.id+'/1.0") 1x, url("'+i+f.id+'/2.0") 2x, url("'+i+f.id+'/3.0") 4x)';m.className="emoticon tooltip",m.style.backgroundImage='url("'+i+f.id+'/1.0")',m.style.backgroundImage="-webkit-"+p,m.style.backgroundImage="-moz-"+p,m.style.backgroundImage="-ms-"+p,m.style.backgroudnImage=p,m.title=_,m.addEventListener("click",this._add_emote.bind(this,e,_)),l.appendChild(m)}return l},draw_ffz_set:function(e,t){var s=document.createElement("div"),n=document.createElement("div"),o=[];s.className="heading",s.innerHTML='<span class="right">FrankerFaceZ</span>'+t.title,s.style.backgroundImage='url("'+(t.icon||"//cdn.frankerfacez.com/script/devicon.png")+'")',n.className="emoticon-grid",n.appendChild(s);for(var i in t.emoticons)t.emoticons.hasOwnProperty(i)&&!t.emoticons[i].hidden&&o.push(t.emoticons[i]);o.sort(function(e,t){var s=e.name.toLowerCase(),n=t.name.toLowerCase();return n>s?-1:s>n?1:e.id<t.id?-1:e.id>t.id?1:0});for(var a=0;a<o.length;a++){var r=o[a],c=document.createElement("span"),l='image-set(url("'+r.urls[1]+'") 1x';r.urls[2]&&(l+=', url("'+r.urls[2]+'") 2x'),r.urls[4]&&(l+=', url("'+r.urls[4]+'") 4x'),l+=")",c.className="emoticon tooltip",c.style.backgroundImage='url("'+r.urls[1]+'")',c.style.backgroundImage="-webkit-"+l,c.style.backgroundImage="-moz-"+l,c.style.backgroundImage="-ms-"+l,c.style.backgroudnImage=l,r.height&&(c.style.height=r.height+"px"),r.width&&(c.style.width=r.width+"px"),c.title=this._emote_tooltip(r),c.addEventListener("click",this._add_emote.bind(this,e,r.name)),n.appendChild(c)}return n},draw_menu:function(e,t,n){if("my_emotes"===t.getAttribute("data-page")){t.innerHTML="";try{var o=this.get_user(),i=this.getEmotes(o&&o.login,null),a=[];for(var r in n)if(n.hasOwnProperty(r)&&(this.settings.global_emotes_in_menu||"0"!==r)){var c=n[r];c.length&&a.push([this._twitch_set_to_channel[r],s.menu_pages.my_emotes.draw_twitch_set.bind(this)(e,r,c)])}for(var l=0;l<i.length;l++){var r=i[l],c=this.emote_sets[r];c&&c.count&&(this.settings.global_emotes_in_menu||-1===this.default_sets.indexOf(r))&&a.push([c.title.toLowerCase(),s.menu_pages.my_emotes.draw_ffz_set.bind(this)(e,c)])}a.sort(function(e,t){var s=e[0],n=t[0];return"turbo"===s||"tfaces"===s?s="zza|"+s:("global"===s||"global emoticons"===s)&&(s="zzz|"+s),"turbo"===n||"tfaces"===n?n="zza|"+n:("global"===n||"global emoticons"===n)&&(n="zzz|"+n),n>s?-1:s>n?1:0});for(var l=0;l<a.length;l++)t.appendChild(a[l][1])}catch(h){this.error("my_emotes draw_menu: "+h),t.innerHTML="";var u=document.createElement("div"),d=document.createElement("div"),f=document.createElement("p");d.className="heading",d.innerHTML="Error Loading Menu",u.appendChild(d),f.className="clearfix",f.textContent=h,u.appendChild(f),u.className="chat-menu-content",t.appendChild(u)}}}}},{"../constants":3,"../utils":29}],24:[function(){var t=e.FrankerFaceZ;t.prototype.setup_notifications=function(){this.log("Adding event handler for window focus."),e.addEventListener("focus",this.clear_notifications.bind(this))},t.settings_info.highlight_notifications={type:"boolean",value:!1,category:"Chat",no_bttv:!0,name:"Highlight Notifications",help:"Display notifications when a highlighted word appears in chat in an unfocused tab.",on_update:function(e,t){if(e&&t){if("denied"===Notification.permission)return this.log("Notifications have been denied by the user."),void this.settings.set("highlight_notifications",!1);if("granted"!==Notification.permission){var s=this;Notification.requestPermission(function(e){"denied"===e&&(s.log("Notifications have been denied by the user."),s.settings.set("highlight_notifications",!1))})}}}},t.ws_commands.message=function(e){this.show_message(e)},t._notifications={},t._last_notification=0,t.prototype.clear_notifications=function(){for(var e in t._notifications){var s=t._notifications[e];if(s)try{s.close()}catch(n){}}t._notifications={},t._last_notification=0},t.prototype.show_notification=function(e,s,n,o,i,a){var r=Notification.permission;if("denied "===r)return!1;if("granted"===r){s=s||"FrankerFaceZ",o=o||1e4;var c={lang:"en-US",dir:"ltr",body:e,tag:n||"FrankerFaceZ",icon:"http://cdn.frankerfacez.com/icon32.png"},l=this,h=new Notification(s,c),u=t._last_notification++;return t._notifications[u]=h,h.addEventListener("click",function(){delete t._notifications[u],i&&i.bind(l)()}),h.addEventListener("close",function(){delete t._notifications[u],a&&a.bind(l)()}),void("number"==typeof o&&h.addEventListener("show",function(){setTimeout(function(){delete t._notifications[u],h.close()},o)}))}var l=this;Notification.requestPermission(function(){l.show_notification(e,s,n)})},t.prototype.show_message=function(t){e.noty({text:t,theme:"ffzTheme",layout:"bottomCenter",closeWith:["button"]}).show()}},{}],25:[function(t){var s=e.FrankerFaceZ,n=t("../utils");s.prototype.setup_races=function(){this.log("Initializing race support."),this.srl_races={}},s.settings_info.srl_races={type:"boolean",value:!0,category:"Channel Metadata",name:"SRL Race Information",help:'Display information about <a href="http://www.speedrunslive.com/" target="_new">SpeedRunsLive</a> races under channels.',on_update:function(){this.rebuild_race_ui()}},s.ws_on_close.push(function(){var t=e.App&&App.__container__.lookup("controller:channel"),s=t&&t.get("id"),n=!1;if(t){for(var o in this.srl_races)delete this.srl_races[o],o==s&&(n=!0);n&&this.rebuild_race_ui()}}),s.ws_commands.srl_race=function(e){for(var t=App.__container__.lookup("controller:channel"),s=t.get("id"),n=!1,o=0;o<e[0].length;o++){var i=e[0][o];this.srl_races[i]=e[1],i==s&&(n=!0)}if(e[1]){var a=e[1],r=a.twitch_entrants={};for(var c in a.entrants)a.entrants.hasOwnProperty(c)&&(a.entrants[c].channel&&(r[a.entrants[c].channel]=c),a.entrants[c].name=c)}n&&this.rebuild_race_ui()},s.prototype.rebuild_race_ui=function(){var e=App.__container__.lookup("controller:channel"),t=e.get("id"),s=this.srl_races[t],n=this.settings.srl_races,o=document.querySelector(".stats-and-actions .channel-actions"),i=o.querySelector("#ffz-ui-race");if(!s||!n)return i&&i.parentElement.removeChild(i),void(this._popup&&"ffz-race-popup"==this._popup.id&&(delete this._popup,this._popup_kill&&this._popup_kill(),delete this._popup_kill));if(i)return this._update_race(!0);i=document.createElement("span"),i.setAttribute("data-channel",t),i.id="ffz-ui-race";var a=document.createElement("span");a.className="button drop action",a.title="SpeedRunsLive Race",a.innerHTML='<span class="logo"><span>',a.addEventListener("click",this.build_race_popup.bind(this)),i.appendChild(a),o.appendChild(i),this._update_race(!0)},s.prototype._race_kill=function(){this._race_timer&&(clearTimeout(this._race_timer),delete this._race_timer),delete this._race_game,delete this._race_goal},s.prototype.build_race_popup=function(){var e=this._popup;if(!e||(e.parentElement.removeChild(e),delete this._popup,this._popup_kill&&this._popup_kill(),delete this._popup_kill,"ffz-race-popup"!=e.id)){var t=document.querySelector("#ffz-ui-race");if(t){var n=t.querySelector(".button"),o=n.offsetLeft+n.offsetWidth,i=t.getAttribute("data-channel"),a=this.srl_races[i],e=document.createElement("div"),r="";e.id="ffz-race-popup",e.className=(o>=300?"right":"left")+" share dropmenu",this._popup_kill=this._race_kill.bind(this),this._popup=e;var c="http://kadgar.net/live",l=!1;for(var h in a.entrants){var u=a.entrants[h].state;a.entrants.hasOwnProperty(h)&&a.entrants[h].channel&&("racing"==u||"entered"==u)&&(c+="/"+a.entrants[h].channel,l=!0)}var d=document.querySelector(".app-main.theatre")?document.body.clientHeight-300:t.parentElement.offsetTop-175,f=App.__container__.lookup("controller:channel"),_=f?f.get("display_name"):s.get_capitalization(i),m=encodeURIComponent("I'm watching "+_+" race "+a.goal+" in "+a.game+" on SpeedRunsLive!");r='<div class="heading"><div></div><span></span></div>',r+='<div class="table" style="max-height:'+d+'px"><table><thead><tr><th>#</th><th>Entrant</th><th> </th><th>Time</th></tr></thead>',r+="<tbody></tbody></table></div>",r+='<div class="divider"></div>',r+='<iframe class="twitter_share_button" style="width:130px; height:25px" src="https://platform.twitter.com/widgets/tweet_button.html?text='+m+"%20Watch%20at&via=Twitch&url=http://www.twitch.tv/"+i+'"></iframe>',r+='<p class="right"><a target="_new" href="http://www.speedrunslive.com/race/?id='+a.id+'">SRL</a>',l&&(r+=' <a target="_new" href="'+c+'">Multitwitch</a>'),r+="</p>",e.innerHTML=r,t.appendChild(e),this._update_race(!0)}}},s.prototype._update_race=function(e){this._race_timer&&e&&(clearTimeout(this._race_timer),delete this._race_timer);var t=document.querySelector("#ffz-ui-race");if(t){var s=t.getAttribute("data-channel"),o=this.srl_races[s];if(!o)return t.parentElement.removeChild(t),this._popup_kill&&this._popup_kill(),void(this._popup&&(delete this._popup,delete this._popup_kill));var i=o.twitch_entrants[s],a=o.entrants[i],r=t.querySelector("#ffz-race-popup"),c=Date.now()/1e3,l=Math.floor(c-o.time);if(t.querySelector(".logo").innerHTML=n.placement(a),r){var h=r.querySelector("tbody"),u=r.querySelector(".heading span"),d=r.querySelector(".heading div");h.innerHTML="";var f=[],_=!0;for(var m in o.entrants)o.entrants.hasOwnProperty(m)&&("racing"==o.entrants[m].state&&(_=!1),f.push(o.entrants[m]));f.sort(function(e,t){var s=e.place||9999,n=t.place||9999,o=e.time||l,i=t.time||l;return("forfeit"==e.state||"dq"==e.state)&&(s=1e4),("forfeit"==t.state||"dq"==t.state)&&(n=1e4),n>s?-1:s>n?1:e.name<t.name?-1:e.name>t.name?1:i>o?-1:o>i?1:void 0});for(var p=0;p<f.length;p++){var m=f[p],g='<a target="_new" href="http://www.speedrunslive.com/profiles/#!/'+n.sanitize(m.name)+'">'+m.display_name+"</a>",v=m.channel?'<a target="_new" class="twitch" href="http://www.twitch.tv/'+n.sanitize(m.channel)+'"></a>':"",b=m.hitbox?'<a target="_new" class="hitbox" href="http://www.hitbox.tv/'+n.sanitize(m.hitbox)+'"></a>':"",y=l?n.time_to_string(m.time||l):"",w=n.place_string(m.place),z=m.comment?n.sanitize(m.comment):"";h.innerHTML+="<tr"+(z?' title="'+z+'"':"")+' class="'+m.state+'"><td>'+w+"</td><td>"+g+"</td><td>"+v+b+'</td><td class="time">'+("forfeit"==m.state?"Forfeit":y)+"</td></tr>"}if(this._race_game!=o.game||this._race_goal!=o.goal){this._race_game=o.game,this._race_goal=o.goal;var k=n.sanitize(o.game),C=n.sanitize(o.goal);d.innerHTML='<h2 title="'+k+'">'+k+"</h2><b>Goal: </b>"+C}l?_?u.innerHTML="Done":(u.innerHTML=n.time_to_string(l),this._race_timer=setTimeout(this._update_race.bind(this),1e3)):u.innerHTML="Entry Open"}}}},{"../utils":29}],26:[function(t){var s=e.FrankerFaceZ,n=t("../constants");s.prototype.setup_css=function(){this.log("Injecting main FrankerFaceZ CSS.");var e=this._main_style=document.createElement("link");e.id="ffz-ui-css",e.setAttribute("rel","stylesheet"),e.setAttribute("href",n.SERVER+"script/style.css?_="+Date.now()),document.head.appendChild(e),jQuery.noty.themes.ffzTheme={name:"ffzTheme",style:function(){this.$bar.removeClass().addClass("noty_bar").addClass("ffz-noty").addClass(this.options.type)},callback:{onShow:function(){},onClose:function(){}}}}},{"../constants":3}],27:[function(t){var s=e.FrankerFaceZ,n=t("../constants"),o=t("../utils");s.prototype._update_subscribers=function(){this._update_subscribers_timer&&(clearTimeout(this._update_subscribers_timer),delete this._update_subscribers_timer);var e=this.get_user(),t=this,s=this.is_dashboard?location.pathname.match(/\/([^\/]+)/):void 0,i=this.is_dashboard&&s&&s[1];if(this.has_bttv||!i||i!==e.login){var a=document.querySelector("#ffz-sub-display");return void(a&&a.parentElement.removeChild(a))}this._update_subscribers_timer=setTimeout(this._update_subscribers.bind(this),6e4),jQuery.ajax({url:"/broadcast/dashboard/partnership"}).done(function(e){try{var s,a=document.createElement("span");a.innerHTML=e,s=a.querySelector("#dash_main");var r=s&&s.textContent.match(/([\d,\.]+) total active subscribers/),c=r&&r[1];if(!c){var l=document.querySelector("#ffz-sub-display");return l&&l.parentElement.removeChild(l),void(t._update_subscribers_timer&&(clearTimeout(t._update_subscribers_timer),delete t._update_subscribers_timer))}var l=document.querySelector("#ffz-sub-display span");if(!l){var h=document.querySelector(t.is_dashboard?"#stats":"#channel .stats-and-actions .channel-stats");if(!h)return;var u=document.createElement("span");u.className="ffz stat",u.id="ffz-sub-display",u.title="Active Channel Subscribers",u.innerHTML=n.STAR+" ",l=document.createElement("span"),u.appendChild(l),Twitch.api.get("chat/"+i+"/badges",null,{version:3}).done(function(e){e.subscriber&&e.subscriber.image&&(u.innerHTML="",u.appendChild(l),u.style.backgroundImage='url("'+e.subscriber.image+'")',u.style.backgroundRepeat="no-repeat",u.style.paddingLeft="23px",u.style.backgroundPosition="0 50%")}),h.appendChild(u),jQuery(u).tipsy(t.is_dashboard?{gravity:"s"}:void 0)}l.innerHTML=o.number_commas(parseInt(c))}catch(d){t.error("_update_subscribers: "+d)}}).fail(function(){var e=document.querySelector("#ffz-sub-display");e&&e.parentElement.removeChild(e)})}},{"../constants":3,"../utils":29}],28:[function(t){var s=e.FrankerFaceZ,n=t("../constants"),o=t("../utils");s.ws_commands.viewers=function(t){var s=t[0],i=t[1],a=e.App&&App.__container__.lookup("controller:channel"),r=this.is_dashboard?location.pathname.match(/\/([^\/]+)/):void 0,c=this.is_dashboard?r&&r[1]:a&&a.get&&a.get("id");if(!this.is_dashboard){var l=this.rooms&&this.rooms[s];return void(l&&(l.ffz_chatters=i,this._cindex&&this._cindex.ffzUpdateChatters()))}if(this.settings.chatter_count&&c===s){var h=document.querySelector("#ffz-ffzchatter-display"),u=n.ZREKNARF+" "+o.number_commas(i);if(h)h.innerHTML=u;else{var d=document.querySelector("#stats");if(!d)return;h=document.createElement("span"),h.id="ffz-ffzchatter-display",h.className="ffz stat",h.title="Chatters with FrankerFaceZ",h.innerHTML=u,d.appendChild(h),jQuery(h).tipsy(this.is_dashboard?{gravity:"s"}:void 0)}}}},{"../constants":3,"../utils":29}],29:[function(t,s){var n=(e.FrankerFaceZ,t("./constants"),{}),o=document.createElement("span"),i=function(e,t,s){return s=s||"s",t=t||"",1===e?t:s},a=function(e){return 1==e?"1st":2==e?"2nd":3==e?"3rd":null==e?"---":e+"th"},r=function(e,t){t=0===t?0:t||1,t=Math.round(255*-(t/100));var s=Math.max(0,Math.min(255,e[0]-t)),n=Math.max(0,Math.min(255,e[1]-t)),o=Math.max(0,Math.min(255,e[2]-t));return[s,n,o]},c=function(e){return"rgb("+e[0]+", "+e[1]+", "+e[2]+")"},l=function(e,t){return t=0===t?0:t||1,r(e,-t)},h=function(e){e=[e[0]/255,e[1]/255,e[2]/255];for(var t=0;t<e.length;t++)e[t]=e[t]<=.03928?e[t]/12.92:Math.pow((e[t]+.055)/1.055,2.4);return.2126*e[0]+.7152*e[1]+.0722*e[2]},u=/^(\d{4}|\+\d{6})(?:-?(\d{2})(?:-?(\d{2})(?:T(\d{2})(?::?(\d{2})(?::?(\d{2})(?:(?:\.|,)(\d{1,}))?)?)?(Z|([\-+])(\d{2})(?::?(\d{2}))?)?)?)?)?$/,d=function(e){var t=e.match(u);if(!t)return null;t[7]=t[7]&&t[7].length?t[7].substr(0,3):0;var s=Date.UTC(t[1],t[2]-1,t[3],t[4],t[5],t[6],t[7]);if(t[9]){var n=6e4*("-"==t[9]?1:-1)*(60*t[10]+1*t[11]);s+=n}return new Date(s)};s.exports={update_css:function(e,t,s){var n=e.innerHTML,o="/*BEGIN "+t+"*/",i="/*END "+t+"*/",a=n.indexOf(o),r=n.indexOf(i),c=-1!==a&&-1!==r&&r>a;(c||s)&&(c&&(n=n.substr(0,a)+n.substr(r+i.length)),s&&(n+=o+s+i),e.innerHTML=n)},get_luminance:h,brighten:r,darken:l,rgb_to_css:c,parse_date:d,number_commas:function(e){var t=e.toString().split(".");return t[0]=t[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),t.join(".")},place_string:a,placement:function(e){return"forfeit"==e.state?"Forfeit":"dq"==e.state?"DQed":e.place?a(e.place):""},sanitize:function(e){var t=n[e];return t||(o.textContent=e,t=n[e]=o.innerHTML,o.innerHTML=""),t},date_string:function(e){return e.getFullYear()+"-"+(e.getMonth()+1)+"-"+e.getDate()},pluralize:i,human_time:function(e){e=Math.floor(e);var t=Math.floor(e/31536e3);if(t)return t+" year"+i(t);var s=Math.floor((e%=31536e3)/86400);if(s)return s+" day"+i(s);var n=Math.floor((e%=86400)/3600);if(n)return n+" hour"+i(n);var o=Math.floor((e%=3600)/60);if(o)return o+" minute"+i(o);var a=e%60;return a?a+" second"+i(a):"less than a second"},time_to_string:function(e,t,s){var n=e%60,o=Math.floor(e/60),i=Math.floor(o/60),a="";if(o%=60,t){if(a=Math.floor(i/24),i%=24,s&&a>0)return a+" days";a=a>0?a+" days, ":""}return a+(10>i?"0":"")+i+":"+(10>o?"0":"")+o+":"+(10>n?"0":"")+n}}},{"./constants":3}]},{},[14]),e.ffz=new FrankerFaceZ}(window); |