1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-06-28 15:27:43 +00:00
FrankerFaceZ/script.min.js

1 line
No EOL
27 KiB
JavaScript

!function(e){!function t(e,o,s){function n(i,a){if(!o[i]){if(!e[i]){var c="function"==typeof require&&require;if(!a&&c)return c(i,!0);if(r)return r(i,!0);throw new Error("Cannot find module '"+i+"'")}var l=o[i]={exports:{}};e[i][0].call(l.exports,function(t){var o=e[i][1][t];return n(o?o:t)},l,l.exports,t,e,o,s)}return o[i].exports}for(var r="function"==typeof require&&require,i=0;i<s.length;i++)n(s[i]);return n}({1:[function(t){var o=e.FrankerFaceZ,s=t("./constants"),n=t("./utils");o.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()};var r=function(e){return".badges .ffz-badge-"+e.id+" { background-color: "+e.color+'; background-image: url("'+e.image+'"); '+(e.extra_css||"")+"}"};o.prototype.bttv_badges=function(e){var t=e.sender,o=this.users[t],s=[],n=-1;if(o&&o.badges){for(var r=0;r<e.badges.length;r++){var i=e.badges[r];if("subscriber"==i.type||"turbo"==i.type){n=r;break}}for(var a in o.badges)if(o.badges.hasOwnProperty(a)){var i=o.badges[a],c=this.badges[i.id]||{},l=i.title||c.title,d="",u=BetterTTV.settings.get("alphaTags");i.image&&(d+='background-image: url(\\"'+i.image+'\\"); '),i.color&&!u&&(d+="background-color: "+i.color+"; "),i.extra_css&&(d+=i.extra_css),d&&(l+='" style="'+d),s.push([(-1==n?1:-1)*a,{type:"ffz-badge-"+i.id+(u?" alpha":""),name:"",description:l}])}if(s.sort(function(e,t){return e[0]-t[0]}),-1==n)for(;s.length;)e.badges.push(s.shift()[1]);else for(;s.length;)e.badges.insertAt(n,s.shift()[1])}},o.prototype.render_badge=function(e){var t=e.get("context.model.from"),o=(e.get("context.parentController.content.id"),e.$(".badges")),s=this.users[t];if(s&&s.badges){var n=o.find(".badge").filter(function(){var e=this.title.toLowerCase();return"subscriber"==e||"turbo"==e}).first(),r=[],i=!!n.length;for(var a in s.badges)if(s.badges.hasOwnProperty(a)){var c=s.badges[a],l=this.badges[c.id]||{},d=document.createElement("div");d.className="badge float-left tooltip ffz-badge-"+c.id,d.setAttribute("title",c.title||l.title),c.image&&(d.style.backgroundImage='url("'+c.image+'")'),c.color&&(d.style.backgroundColor=c.color),c.extra_css&&(d.style.cssText+=c.extra_css),r.push([(i?1:-1)*a,d])}if(r.sort(function(e,t){return e[0]-t[0]}),i)for(;r.length;)n.before(r.shift()[1]);else for(;r.length;)o.append(r.shift()[1])}},o.prototype._legacy_add_donors=function(e){this.badges[1]={id:1,title:"FFZ Donor",color:"#755000",image:"http://cdn.frankerfacez.com/channel/global/donoricon.png"},n.update_css(this._badge_style,1,r(this.badges[1])),this.badges[0]={id:0,title:"FFZ Developer",color:"#FAAF19",image:"http://sir.stendec.me/devicon.png"},n.update_css(this._badge_style,0,r(this.badges[0])),this.users.sirstendec={badges:{0:{id:0}}},jQuery.ajax(s.SERVER+"script/donors.txt",{cache:!1,context:this}).done(function(e){this._legacy_parse_donors(e)}).fail(function(t){return 404!=t.status?(e=(e||0)+1,10>e?this._legacy_add_donors(e):void 0):void 0})},o.prototype._legacy_parse_donors=function(e){var t=0;if(null!=e)for(var o=e.trim().split(/\W+/),s=0;s<o.length;s++){var r=o[s],i=this.users[r]=this.users[r]||{},a=i.badges=i.badges||{};a[0]||(a[0]={id:1},t+=1)}this.log("Added donor badge to "+n.number_commas(t)+" users.")}},{"./constants":3,"./utils":18}],2:[function(){var t=e.FrankerFaceZ,o=/(\sdata-sender="[^"]*"(?=>))/;t.prototype.find_bttv=function(t,o){return this.has_bttv=!1,e.BTTVLOADED?this.setup_bttv():void(o>=6e4?this.log("BetterTTV was not detected after 60 seconds."):setTimeout(this.find_bttv.bind(this,t,(o||0)+t),t))},t.prototype.setup_bttv=function(){this.log("BetterTTV was detected. Hooking."),this.has_bttv=!0;var e=BetterTTV.chat.helpers.sendMessage,t=this;BetterTTV.chat.helpers.sendMessage=function(o){var s=o.split(" ",1)[0].toLowerCase();return"/ffz"!==s?e(o):void t.run_command(o.substr(5),BetterTTV.chat.store.currentRoom)};var s,n=BetterTTV.chat.handlers.privmsg;BetterTTV.chat.handlers.privmsg=function(e,t){s=e;var o=n(e,t);return s=null,o};var r=BetterTTV.chat.templates.privmsg;BetterTTV.chat.templates.privmsg=function(e,n,i,a,c){t.bttv_badges(c);var l=r(e,n,i,a,c);return l.replace(o,'$1 data-room="'+s+'"')};var i,a=BetterTTV.chat.templates.message;BetterTTV.chat.templates.message=function(e,t,o,s){i=e;var n=a(e,t,o,s);return i=null,n};var c=BetterTTV.chat.templates.emoticonize;BetterTTV.chat.templates.emoticonize=function(e,o){var n=c(e,o),r=t.users[i],a=t.rooms[s],l=_.union(r&&r.sets||[],a&&a.sets||[],t.global_sets),o=[];return _.each(l,function(e){var s=t.emote_sets[e];s&&_.each(s.emotes,function(e){_.any(n,function(t){return _.isString(t)&&t.match(e.regex)})&&o.push(e)})}),o.length?(_.each(o,function(e){var t=['<img class="emoticon" src="'+e.url+'" alt="'+e.title+'" />'],o=n;if(n=[],!o||!o.length)return n;for(var s=0;s<o.length;s++){var r=o[s];if("string"==typeof r){var i=r.split(e.regex);i.forEach(function(e,o){e&&e.length&&n.push(e),o!==i.length-1&&n.push(t)})}else n.push(r)}}),n):n},this.update_ui_link()}},{}],3:[function(e,t){var o='<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"/>',s="true"==localStorage.ffzDebugMode&&document.body.classList.contains("ffz-dev");t.exports={DEBUG:s,SERVER:s?"//localhost:8000/":"//cdn.frankerfacez.com/",SVGPATH:o,ZREKNARF:'<svg style="padding:1.75px 0" class="svg-glyph_views" width="16px" viewBox="0 0 249 195" version="1.1" height="12.5px">'+o+"</svg>",CHAT_BUTTON:'<svg class="svg-emoticons ffz-svg" height="18px" width="24px" viewBox="0 0 249 195" version="1.1">'+o+"</svg>"}},{}],4:[function(){var t=e.FrankerFaceZ;t.chat_commands.developer_mode=function(e,t){var o,t=t&&t.length?t[0].toLowerCase():null;return"y"==t||"yes"==t||"true"==t||"on"==t?o=!0:("n"==t||"no"==t||"false"==t||"off"==t)&&(o=!1),void 0===o?"Developer Mode is currently "+("true"==localStorage.ffzDebugMode?"enabled.":"disabled."):(localStorage.ffzDebugMode=o,"Developer Mode is now "+(o?"enabled":"disabled")+". Please refresh your browser.")},t.chat_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(){var t=e.FrankerFaceZ;t.prototype.setup_chatview=function(){this.log("Hooking the Ember Chat view.");var e=App.__container__.resolve("view:chat");this._modify_cview(e),e.create().destroy();for(var t in Ember.View.views)if(Ember.View.views.hasOwnProperty(t)){var o=Ember.View.views[t];o instanceof e&&(this.log("Adding UI link manually to Chat view.",o),o.$(".textarea-contain").append(this.build_ui_link(o)))}},t.prototype._modify_cview=function(e){var t=this;e.reopen({didInsertElement:function(){this._super(),this.$()&&this.$(".textarea-contain").append(t.build_ui_link(this))},willClearRender:function(){this._super(),this.$(".ffz-ui-toggle").remove()},ffzUpdateLink:Ember.observer("controller.currentRoom",function(){t.update_ui_link()})})}},{}],6:[function(){var t=e.FrankerFaceZ;t.prototype.setup_line=function(){this.log("Hooking the Ember Line controller.");var e=App.__container__.resolve("controller:line"),t=this;e.reopen({tokenizedMessage:function(){return t._emoticonize(this,this._super())}.property("model.message","isModeratorOrHigher","controllers.emoticons.emoticons.[]")}),this.log("Hooking the Ember Line view.");var e=App.__container__.resolve("view:line");e.reopen({didInsertElement:function(){this._super();var e=this.get("element"),o=this.get("context.model.from");e.setAttribute("data-room",this.get("context.parentController.content.id")),e.setAttribute("data-sender",o),t.render_badge(this),t.capitalize(this,o)}})},t.capitalization={},t._cap_fetching=0,t.get_capitalization=function(e,o){e=e.toLowerCase();var s=t.capitalization[e];return s&&Date.now()-s[1]<36e5?s[0]:(t._cap_fetching<5&&(t._cap_fetching++,Twitch.api.get("users/"+e).always(function(s){var n=s.display_name||e;t.capitalization[e]=[n,Date.now()],t._cap_fetching--,o&&o(n)})),s?s[0]:e)},t.prototype.capitalize=function(e,o){var s=t.get_capitalization(o,this.capitalize.bind(this,e));s&&e.$(".from").text(s)},t.prototype._emoticonize=function(e,t){var o=e.get("parentController.model.id"),s=e.get("model.from"),n=this.users[s],r=this.rooms[o],i=this,a=_.union(n&&n.sets||[],r&&r.sets||[],i.global_sets),c=[];return _.each(a,function(e){var o=i.emote_sets[e];o&&_.each(o.emotes,function(e){_.any(t,function(t){return _.isString(t)&&t.match(e.regex)})&&c.push(e)})}),c.length?("string"==typeof t&&(t=[t]),_.each(c,function(e){var o={isEmoticon:!0,cls:e.klass,emoticonSrc:e.url,altText:e.name};t=_.compact(_.flatten(_.map(t,function(t){if(_.isObject(t))return t;var s=t.split(e.regex),n=[];return s.forEach(function(e,t){n.push(e),t!==s.length-1&&n.push(o)}),n})))}),t):t}},{}],7:[function(t){var o=e.FrankerFaceZ,s=/\.([\w\-_]+)\s*?\{content:\s*?"([^"]+)";\s*?background-image:\s*?url\("([^"]+)"\);\s*?height:\s*?(\d+)px;\s*?width:\s*?(\d+)px;\s*?margin:([^;}]+);?([^}]*)\}/gm,n=/[^\n}]*\.badges\s+\.moderator\s*{\s*background-image:\s*url\(\s*['"]([^'"]+)['"][^}]+(?:}|$)/,r=/^_([^_]+)_\d+$/,i=t("../constants"),a=t("../utils"),c=function(e){return e.moderator_badge?'.chat-line[data-room="'+e.id+'"] .badges .moderator { background-image:url("'+e.moderator_badge+'") !important; }':""};o.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__.resolve("model:room");this._modify_room(t);var o=t.instances;for(var s in o)if(o.hasOwnProperty(s)){var n=o[s];this.add_room(n.id,n),this._modify_room(n)}},o.chat_commands={},o.prototype.room_message=function(e,t){var o=t.split("\n");if(this.has_bttv)for(var s=0;s<o.length;s++)BetterTTV.chat.handlers.onPrivmsg(e.id,{style:"admin",date:new Date,from:"jtv",message:o[s]});else for(var s=0;s<o.length;s++)e.room.addMessage({style:"ffz admin",date:new Date,from:"FFZ",message:o[s]})},o.prototype.run_command=function(e,t){var s=this.rooms[t];if(s&&s.room){e||(e="help");var n=e.split(" "),r=n.shift().toLowerCase();this.log("Received Command: "+r,n,!0);var i,a=o.chat_commands[r];if(a)try{i=a.bind(this)(s,n)}catch(c){this.log("Error Running Command - "+r+": "+c,s),i="There was an error running the command."}else i='There is no "'+r+'" command.';i&&this.room_message(s,i)}},o.chat_commands.help=function(e,t){if(t&&t.length){var s=o.chat_commands[t[0].toLowerCase()];return s?s.help?s.help:'No help is available for the command "'+t[0]+'".':'There is no "'+t[0]+'" command.'}var n=[];for(var r in o.chat_commands)o.chat_commands.hasOwnProperty(r)&&n.push(r);return"The available commands are: "+n.join(", ")},o.chat_commands.help.help="Usage: /ffz help [command]\nList available commands, or show help for a specific command.",o.prototype.add_room=function(e,t){return this.rooms[e]?this.log("Tried to add existing room: "+e):(this.log("Adding Room: "+e),this.rooms[e]={id:e,room:t,menu_sets:[],sets:[],css:null},this.ws_send("sub",e),void this._legacy_add_room(e))},o.prototype.remove_room=function(e){var t=this.rooms[e];if(t){this.log("Removing Room: "+e),(t.css||t.moderator_badge)&&a.update_css(this._room_style,e,null),this.ws_send("unsub",e),delete this.rooms[e];for(var o=0;o<t.sets.length;o++){var s=t.sets[o],n=this.emote_sets[s];n&&(n.users.removeObject(e),n.global||n.users.length||this.unload_set(s))}}},o.prototype.load_room=function(e,t){return this._legacy_load_room(e,t)},o.prototype._load_room_json=function(e,t,o){this.rooms[e]&&(o.room=this.rooms[e].room),this.rooms[e]=o,(o.css||o.moderator_badge)&&a.update_css(this._room_style,e,c(o)+(o.css||""));for(var s=0;s<o.sets.length;s++){var n=o.sets[s];this.emote_sets.hasOwnProperty(n)||this.load_set(n)}this.update_ui_link(),t&&t(!0,o)},o.prototype._modify_room=function(e){var t=this;e.reopen({init:function(){this._super(),t.add_room(this.id,this)},willDestroy:function(){this._super(),t.remove_room(this.id)},send:function(e){var o=e.split(" ",1)[0].toLowerCase();return"/ffz"!==o?this._super(e):(this.set("messageToSend",""),void t.run_command(e.substr(5),this.get("id")))}})},o.prototype._legacy_add_room=function(e,t,o){jQuery.ajax(i.SERVER+"channel/"+e+".css",{cache:!1,context:this}).done(function(o){this._legacy_load_room_css(e,t,o)}).fail(function(s){return 404==s.status?this._legacy_load_room_css(e,t,null):(o=o||0,o++,10>o?this._legacy_add_room(e,t,o):void 0)})},o.prototype._legacy_load_room_css=function(e,t,o){var i=e,a=i.match(r);a&&a[1]&&(i=a[1]);var c={id:e,menu_sets:[i],sets:[i],moderator_badge:null,css:null};return o&&(o=o.replace(s,"").trim()),o&&(o=o.replace(n,function(e,t){return c.moderator_badge||"modicon.png"!==t.substr(-11)?e:(c.moderator_badge=t,"")})),c.css=o||null,this._load_room_json(e,t,c)}},{"../constants":3,"../utils":18}],8:[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 o=this;e.reopen({lines:function(){var e=this._super(),s=[],n={},r=null,i=App.__container__.lookup("controller:channel"),a=this.get("parentController.model.id"),c=i&&i.get("id");if(c){var l=i.get("display_name");l&&(t.capitalization[c]=[l,Date.now()])}a!=c&&(c=null);for(var d=0;d<e.length;d++){var u=e[d];if(u.category)r=u.category,s.push(r),n[r]=[];else{var h=u.chatter.toLowerCase();if(!h)continue;h==c?(s.unshift("Broadcaster"),n.Broadcaster=[h]):n.hasOwnProperty(r)&&n[r].push(h)}}e=[];for(var d=0;d<s.length;d++){var m=s[d],p=n[m];if(p&&p.length)for(e.push({category:m}),e.push({chatter:""}),p.sort();p.length;){var h=p.shift();h=o.has_bttv?BetterTTV.chat.helpers.lookupDisplayName(h):t.get_capitalization(h),e.push({chatter:h})}}return e}.property("content.chatters")})}},{}],9:[function(t){var o=e.FrankerFaceZ,s=/\.([\w\-_]+)\s*?\{content:\s*?"([^"]+)";\s*?background-image:\s*?url\("([^"]+)"\);\s*?height:\s*?(\d+)px;\s*?width:\s*?(\d+)px;\s*?margin:([^;}]+);?([^}]*)\}/gm,n=t("./constants"),r=t("./utils"),i=function(e,t,o){t&&(o.global=!0,this.global_sets.push(e))},a=function(e,t){var o=e.split(/ +/);return 2!=o.length?e:(o[0]=parseFloat(o[0]),o[1]=parseFloat(o[1]),o[0]==(t-18)/-2&&0==o[1]?null:e)};o.prototype.setup_emoticons=function(){this.log("Preparing emoticon system."),this.emote_sets={},this.global_sets=[],this._last_emote_id=0,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 set."),this.load_set("global",i.bind(this,"global"))},o.ws_commands.reload_set=function(e){this.load_set(e)},o.prototype.load_set=function(e,t){return this._legacy_load_set(e,t)},o.prototype.unload_set=function(e){var t=this.emote_sets[e];if(t){this.log("Unloading emoticons for set: "+e),r.update_css(this._emote_style,e,null),delete this.emote_sets[e];for(var o=0;o<t.users.length;o++){var s=this.rooms[t.users[o]];s&&s.sets.removeObject(e)}}};var c=function(e){var t=e.margins;return t||(t=(e.height-18)/-2+"px 0"),".ffz-emote-"+e.id+' { background-image: url("'+e.url+'"); height: '+e.height+"px; width: "+e.width+"px; margin: "+t+(e.extra_css?"; "+e.extra_css:"")+"}\n"},l=function(e){return e.margins||e.extra_css?c(e)+'img[src="'+e.url+'"] { '+(e.margins?"margin: "+e.margins+";":"")+(e.extra_css||"")+" }\n":c(e)},d=l;o.prototype._load_set_json=function(e,t,o){this.emote_sets[e]=o,o.users=[],o.global=!1,o.count=0;var s="";for(var n in o.emotes)if(o.emotes.hasOwnProperty(n)){var i=o.emotes[n];i.klass="ffz-emote-"+i.id,i.regex="!"===i.name[i.name.length-1]?new RegExp("\\b"+i.name+"(?=\\W|$)","g"):new RegExp("\\b"+i.name+"\\b","g"),s+=d(i),o.count++}r.update_css(this._emote_style,e,s+(o.extra_css||"")),this.log("Updated emoticons for set: "+e,o),this.update_ui_link(),t&&t(!0,o)},o.prototype._legacy_load_set=function(e,t,o){jQuery.ajax(n.SERVER+"channel/"+e+".css",{cache:!1,context:this}).done(function(o){this._legacy_load_css(e,t,o)}).fail(function(s){return 404==s.status?t&&t(!1):(o=o||0,o++,10>o?this._legacy_load_set(e,t,o):t&&t(!1))})},o.prototype._legacy_load_css=function(e,t,o){var n={},r={id:e,emotes:n,extra_css:null},i=this;o.replace(s,function(e,t,o,s,r,c,l,d){r=parseInt(r),c=parseInt(c),l=a(l,r);var u="."===s.substr(s.lastIndexOf("/")+1,1),h=++i._last_emote_id,m={id:h,hidden:u,name:o,height:r,width:c,url:s,margins:l,extra_css:d};return n[h]=m,""}),this._load_set_json(e,t,r)}},{"./constants":3,"./utils":18}],10:[function(t){t("./shims");var o=e.FrankerFaceZ=function(){o.instance=this,this.initialize()};o.get=function(){return o.instance};var s=o.version_info={major:3,minor:0,revision:0,toString:function(){return[s.major,s.minor,s.revision].join(".")+(s.extra||"")}};o.prototype.log=function(e,t,o){e="FFZ: "+e+(o?" -- "+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)},o.prototype.get_user=function(){if(e.PP&&PP.login)return PP;if(e.App){var t=App.__container__.lookup("controller:navigation");return t?t.get("userData"):void 0}},t("./socket"),t("./emoticons"),t("./badges"),t("./ember/room"),t("./ember/line"),t("./ember/chatview"),t("./ember/viewers"),t("./debug"),t("./betterttv"),t("./ui/styles"),t("./ui/notifications"),t("./ui/viewer_count"),t("./ui/menu_button"),t("./ui/menu"),o.prototype.initialize=function(t,o){var s=void 0!=e.App&&void 0!=App.__container__&&void 0!=App.__container__.resolve("model:room");return s?void this.setup(o):(t=t||10,void(o>=6e4?this.log('Twitch application not detected in "'+location.toString()+'". Aborting.'):setTimeout(this.initialize.bind(this,t,(o||0)+t),t)))},o.prototype.setup=function(t){var s=e.performance&&performance.now?performance.now():Date.now();this.log("Found Twitch application after "+(t||0)+' ms in "'+location+'". Initializing FrankerFaceZ version '+o.version_info),this.users={};for(var n in localStorage)"ffz_"==n.substr(0,4)&&localStorage.removeItem(n);var r=this.get_user();r&&r.name&&(o.capitalization[r.login]=[r.name,Date.now()]);try{this.ws_create(),this.setup_emoticons(),this.setup_badges(),this.setup_room(),this.setup_line(),this.setup_chatview(),this.setup_viewers(),this.setup_css(),this.setup_menu(),this.find_bttv(10)}catch(i){return void this.log("An error occurred while starting FrankerFaceZ: "+i)}e.console&&console.time&&console.timeEnd("FrankerFaceZ Initialization");var a=e.performance&&performance.now?performance.now():Date.now(),c=a-s;this.log("Initialization complete in "+c+"ms")}},{"./badges":1,"./betterttv":2,"./debug":4,"./ember/chatview":5,"./ember/line":6,"./ember/room":7,"./ember/viewers":8,"./emoticons":9,"./shims":11,"./socket":12,"./ui/menu":13,"./ui/menu_button":14,"./ui/notifications":15,"./ui/styles":16,"./ui/viewer_count":17}],11:[function(){Array.prototype.equals=function(e){if(!e)return!1;if(this.length!=e.length)return!1;for(var t=0,o=this.length;o>t;t++)if(this[t]instanceof Array&&e[t]instanceof Array){if(!this[t].equals(e[t]))return!1}else if(this[t]!=e[t])return!1;return!0}},{}],12:[function(){var t=e.FrankerFaceZ;t.prototype._ws_open=!1,t.prototype._ws_delay=0,t.ws_commands={},t.prototype.ws_create=function(){var e=this;this._ws_last_req=0,this._ws_callbacks={};var o=this._ws_sock=new WebSocket("ws://ffz.stendec.me/");o.onopen=function(){e._ws_open=!0,e._ws_delay=0,e.log("Socket connected.");var t=e.get_user();t&&e.ws_send("setuser",t.login);for(var o in e.rooms)e.ws_send("sub",o)},o.onclose=function(){e.log("Socket closed."),e._ws_open=!1,e._ws_delay<3e4&&(e._ws_delay+=5e3),setTimeout(e.ws_create.bind(e),e._ws_delay)},o.onmessage=function(o){var s,n,r=o.data.indexOf(" "),i=o.data.substr(r+1),a=parseInt(o.data.slice(0,r));if(r=i.indexOf(" "),-1===r&&(r=i.length),s=i.slice(0,r),i=i.substr(r+1),i&&(n=JSON.parse(i)),-1===a){var c=t.ws_commands[s];c?c.bind(e)(n):e.log("Invalid command: "+s,n)}else{var l="True"===s,d=e._ws_callbacks[a];e.log("Socket Reply to "+a+" - "+(l?"SUCCESS":"FAIL"),n),d&&(delete e._ws_callbacks[a],d(l,n))}}},t.prototype.ws_send=function(e,t,o){if(!this._ws_open)return!1;var s=++this._ws_last_req;return t=void 0!==t?" "+JSON.stringify(t):"",o&&(this._ws_callbacks[s]=o),this._ws_sock.send(s+" "+e+t),s}},{}],13:[function(){var t=e.FrankerFaceZ;t.prototype.setup_menu=function(){this.log("Installing mouse-up event to auto-close menus.");var e=this;jQuery(document).mouseup(function(t){var o,s=e._popup;s&&(s=jQuery(s),o=s.parent(),o.is(t.target)||0!==o.has(t.target).length||(s.remove(),delete e._popup))})},t.prototype.build_ui_popup=function(e){var t=this._popup;if(t)return t.parentElement.removeChild(t),void delete this._popup;var o=document.createElement("div"),s=document.createElement("div");o.className="emoticon-selector chat-menu ffz-ui-popup",s.className="emoticon-selector-box dropmenu",o.appendChild(s);var n=e.get("controller.currentRoom.id"),r=this.rooms[n];this.log("Menu for Room: "+n,r);var i=document.createElement("a");i.className="button glyph-only ffz-button",i.title="Advertise for FrankerFaceZ in chat!",i.href="#",i.innerHTML='<svg class="svg-followers" 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>';var a=document.createElement("div");a.className="list-header first",a.appendChild(i),a.appendChild(document.createTextNode("FrankerFaceZ")),s.appendChild(a);var c=this._emotes_for_sets(s,e,r&&r.menu_sets||[]);0===c?i.addEventListener("click",this._add_emote.bind(this,e,"To use custom emoticons in tons of channels, get FrankerFaceZ from http://www.frankerfacez.com")):i.addEventListener("click",this._add_emote.bind(this,e,"To view this channel's emoticons, get FrankerFaceZ from http://www.frankerfacez.com")),this._popup=o,s.style.maxHeight=Math.max(300,e.$().height()-171)+"px",e.$(".chat-interface").append(o)},t.prototype._emotes_for_sets=function(e,t,o,s,n){if(null!=s){var r=document.createElement("div");r.className="list-header",r.appendChild(document.createTextNode(s)),n&&r.appendChild(n),e.appendChild(r)}var i=document.createElement("div"),a=0;i.className="emoticon-grid";for(var c=0;c<o.length;c++){var l=this.emote_sets[o[c]];if(l&&l.emotes)for(var d in l.emotes){var u=l.emotes[d];if(l.emotes.hasOwnProperty(d)&&!u.hidden){a++;var h=document.createElement("span");h.className="emoticon tooltip",h.style.backgroundImage='url("'+u.url+'")',h.style.width=u.width+"px",h.style.height=u.height+"px",h.title=u.name,h.addEventListener("click",this._add_emote.bind(this,t,u.name)),i.appendChild(h)}}}a||(i.innerHTML="This channel has no emoticons.",i.className="chat-menu-content ffz-no-emotes center"),e.appendChild(i)},t.prototype._add_emote=function(e,t){var o=e.get("controller.currentRoom"),s=o.get("messageToSend")||"";s&&" "!==s.substr(-1)&&(s+=" "),o.set("messageToSend",s+(t.name||t))}},{}],14:[function(t){var o=e.FrankerFaceZ,s=t("../constants");o.prototype.build_ui_link=function(e){var t=document.createElement("a");return t.className="ffz-ui-toggle",t.innerHTML=s.CHAT_BUTTON,t.addEventListener("click",this.build_ui_popup.bind(this,e)),this.update_ui_link(t),t},o.prototype.update_ui_link=function(e){var t=App.__container__.lookup("controller:chat");if(e=e||document.querySelector("a.ffz-ui-toggle"),!e||!t)return this.log("No button.");var o=t.get("currentRoom.id"),s=this.rooms[o],n=!1,r=this.has_bttv?BetterTTV.settings.get("darkenedMode"):!1,i=this.has_bttv?BetterTTV.settings.get("showBlueButtons"):!1;if(s&&s.sets.length)for(var a=0;a<s.sets.length;a++){var c=this.emote_sets[s.sets[a]];if(c&&c.count>0){n=!0;break}}e.classList.toggle("no-emotes",!n),e.classList.toggle("dark",r),e.classList.toggle("blue",i)}},{"../constants":3}],15:[function(){var t=e.FrankerFaceZ;t.prototype.show_notification=function(t){e.noty({text:t,theme:"ffzTheme",layout:"bottomCenter",closeWith:["button"]}).show()},t.ws_commands.message=function(e){this.show_notification(e)}},{}],16:[function(t){var o=e.FrankerFaceZ,s=t("../constants");o.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",s.SERVER+"script/style.css"),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}],17:[function(t){var o=e.FrankerFaceZ,s=t("../constants"),n=t("../utils");o.ws_commands.viewers=function(e){var t=e[0],o=e[1],r=App.__container__.lookup("controller:channel"),i=r&&r.get&&r.get("id");if(i===t){var a=document.querySelector(".channel-stats .ffz.stat"),c=s.ZREKNARF+" "+n.number_commas(o);if(a)a.innerHTML=c;else{var l=document.querySelector(".channel-stats");if(!l)return;a=document.createElement("span"),a.className="ffz stat",a.title="Viewers with FrankerFaceZ",a.innerHTML=c,l.appendChild(a),jQuery(a).tipsy()}}}},{"../constants":3,"../utils":18}],18:[function(t,o){e.FrankerFaceZ,t("./constants");o.exports={update_css:function(e,t,o){var s=e.innerHTML,n="/*BEGIN "+t+"*/",r="/*END "+t+"*/",i=s.indexOf(n),a=s.indexOf(r),c=-1!==i&&-1!==a&&a>i;(c||o)&&(c&&(s=s.substr(0,i)+s.substr(a+r.length)),o&&(s+=n+o+r),e.innerHTML=s)},number_commas:function(e){var t=e.toString().split(".");return t[0]=t[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),t.join(".")}}},{"./constants":3}]},{},[10]),e.ffz=new FrankerFaceZ}(window);