1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-06-29 07:45:33 +00:00
FrankerFaceZ/script.min.js

2 lines
35 KiB
JavaScript
Raw Normal View History

!function(e){!function t(e,o,s){function n(r,i){if(!o[r]){if(!e[r]){var l="function"==typeof require&&require;if(!i&&l)return l(r,!0);if(a)return a(r,!0);throw new Error("Cannot find module '"+r+"'")}var c=o[r]={exports:{}};e[r][0].call(c.exports,function(t){var o=e[r][1][t];return n(o?o:t)},c,c.exports,t,e,o,s)}return o[r].exports}for(var a="function"==typeof require&&require,r=0;r<s.length;r++)n(s[r]);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 a=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 a=0;a<e.badges.length;a++){var r=e.badges[a];if("subscriber"==r.type||"turbo"==r.type){n=a;break}}for(var i in o.badges)if(o.badges.hasOwnProperty(i)){var r=o.badges[i],l=this.badges[r.id]||{},c=r.title||l.title,u="",d=BetterTTV.settings.get("alphaTags");r.image&&(u+='background-image: url(\\"'+r.image+'\\"); '),r.color&&!d&&(u+="background-color: "+r.color+"; "),r.extra_css&&(u+=r.extra_css),u&&(c+='" style="'+u),s.push([(-1==n?1:-1)*i,{type:"ffz-badge-"+r.id+(d?" alpha":""),name:"",description:c}])}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(),a=[],r=!!n.length;for(var i in s.badges)if(s.badges.hasOwnProperty(i)){var l=s.badges[i],c=this.badges[l.id]||{},u=document.createElement("div");u.className="badge float-left tooltip ffz-badge-"+l.id,u.setAttribute("title",l.title||c.title),l.image&&(u.style.backgroundImage='url("'+l.image+'")'),l.color&&(u.style.backgroundColor=l.color),l.extra_css&&(u.style.cssText+=l.extra_css),a.push([(r?1:-1)*i,u])}if(a.sort(function(e,t){return e[0]-t[0]}),r)for(;a.length;)n.before(a.shift()[1]);else for(;a.length;)o.append(a.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,a(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,a(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 a=o[s],r=this.users[a]=this.users[a]||{},i=r.badges=r.badges||{};i[0]||(i[0]={id:1},t+=1)}this.log("Added donor badge to "+n.number_commas(t)+" users.")}},{"./constants":4,"./utils":22}],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,this.track("setCustomVariable","3","BetterTTV",BetterTTV.info.versionString());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),BetterTT
for(var l=0;l<o.length;l++){var c=this.emote_sets[o[l]];if(c&&c.emotes)for(var u in c.emotes){var d=c.emotes[u];if(c.emotes.hasOwnProperty(u)&&!d.hidden){i++;var h=document.createElement("span");h.className="emoticon tooltip",h.style.backgroundImage='url("'+d.url+'")',h.style.width=d.width+"px",h.style.height=d.height+"px",h.title=d.name,h.addEventListener("click",this._add_emote.bind(this,t,d.name)),r.appendChild(h)}}}i||(r.innerHTML="This channel has no emoticons.",r.className="chat-menu-content ffz-no-emotes center"),e.appendChild(r)},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))}},{}],18:[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,a=this.has_bttv?BetterTTV.settings.get("darkenedMode"):!1,r=this.has_bttv?BetterTTV.settings.get("showBlueButtons"):!1,i=this.feature_friday&&this.feature_friday.live;if(s&&s.sets.length)for(var l=0;l<s.sets.length;l++){var c=this.emote_sets[s.sets[l]];if(c&&c.count>0){n=!0;break}}e.classList.toggle("no-emotes",!n),e.classList.toggle("live",i),e.classList.toggle("dark",a),e.classList.toggle("blue",r)}},{"../constants":4}],19:[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)}},{}],20:[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":4}],21:[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],a=App.__container__.lookup("controller:channel"),r=a&&a.get&&a.get("id");if(r===t){var i=document.querySelector(".channel-stats .ffz.stat"),l=s.ZREKNARF+" "+n.number_commas(o);if(i)i.innerHTML=l;else{var c=document.querySelector(".channel-stats");if(!c)return;i=document.createElement("span"),i.className="ffz stat",i.title="Viewers with FrankerFaceZ",i.innerHTML=l,c.appendChild(i),jQuery(i).tipsy()}}}},{"../constants":4,"../utils":22}],22:[function(t,o){e.FrankerFaceZ,t("./constants");o.exports={update_css:function(e,t,o){var s=e.innerHTML,n="/*BEGIN "+t+"*/",a="/*END "+t+"*/",r=s.indexOf(n),i=s.indexOf(a),l=-1!==r&&-1!==i&&i>r;(l||o)&&(l&&(s=s.substr(0,r)+s.substr(i+a.length)),o&&(s+=n+o+a),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":4}]},{},[12]),e.ffz=new FrankerFaceZ}(window);