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

2 lines
38 KiB
JavaScript
Raw Normal View History

!function(e){!function t(e,o,n){function s(i,a){if(!o[i]){if(!e[i]){var l="function"==typeof require&&require;if(!a&&l)return l(i,!0);if(r)return r(i,!0);throw new Error("Cannot find module '"+i+"'")}var c=o[i]={exports:{}};e[i][0].call(c.exports,function(t){var o=e[i][1][t];return s(o?o:t)},c,c.exports,t,e,o,n)}return o[i].exports}for(var r="function"==typeof require&&require,i=0;i<n.length;i++)s(n[i]);return s}({1:[function(t){var o=e.FrankerFaceZ,n=t("./constants"),s=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],n=[],s=-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){s=r;break}}for(var a in o.badges)if(o.badges.hasOwnProperty(a)){var i=o.badges[a],l=this.badges[i.id]||{},c=i.title||l.title,u="",d=BetterTTV.settings.get("alphaTags");i.image&&(u+='background-image: url(\\"'+i.image+'\\"); '),i.color&&!d&&(u+="background-color: "+i.color+"; "),i.extra_css&&(u+=i.extra_css),u&&(c+='" style="'+u),n.push([(-1==s?1:-1)*a,{type:"ffz-badge-"+i.id+(d?" alpha":""),name:"",description:c}])}if(n.sort(function(e,t){return e[0]-t[0]}),-1==s)for(;n.length;)e.badges.push(n.shift()[1]);else for(;n.length;)e.badges.insertAt(s,n.shift()[1])}},o.prototype.render_badge=function(e){var t=e.get("context.model.from"),o=(e.get("context.parentController.content.id"),e.$(".badges")),n=this.users[t];if(n&&n.badges){var s=o.find(".badge").filter(function(){var e=this.title.toLowerCase();return"subscriber"==e||"turbo"==e}).first(),r=[],i=!!s.length;for(var a in n.badges)if(n.badges.hasOwnProperty(a)){var l=n.badges[a],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),r.push([(i?1:-1)*a,u])}if(r.sort(function(e,t){return e[0]-t[0]}),i)for(;r.length;)s.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:"//cdn.frankerfacez.com/channel/global/donoricon.png"},s.update_css(this._badge_style,1,r(this.badges[1])),this.badges[0]={id:0,title:"FFZ Developer",color:"#FAAF19",image:"//cdn.frankerfacez.com/channel/global/devicon.png"},s.update_css(this._badge_style,0,r(this.badges[0])),this.users.sirstendec={badges:{0:{id:0}}},jQuery.ajax(n.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+/),n=0;n<o.length;n++){var r=o[n],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 "+s.number_commas(t)+" users.")}},{"./constants":3,"./utils":23}],2:[function(){var t=e.FrankerFaceZ;t.chat_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 o=this.get_user();if(!o||!o.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 s=t.shift();e.room.tmiRoom.sendMessage("/unmod "+s)}return"Sent unmod command for "+n+" users."},t.chat_commands.massunmod.help="Usage: /ffz massunmod <list, of,
},o.chat_commands.analytics.help="Usage: /ffz analytics <on|off>\nEnable or disable FrankerFaceZ analytics. We collect some data about your browser and how you use FrankerFaceZ to help us improve the script. Turn off analytics if you'd rather we not.",o.prototype.track=function(){this._tracking&&e._paq&&_paq.push(Array.prototype.slice.call(arguments))},o.prototype.track_page=function(){if(this._tracking){this._old_url&&this.track("setReferrerUrl",this._old_url),this._old_url=document.location.toString(),this.track("setCustomUrl",this._old_url),this.track("deleteCustomVariable","1","page"),this.track("deleteCustomVariable","3","page");var e=App.__container__.resolve("router:main").router.currentHandlerInfos;if(e&&0!=e.length){var t=e[e.length-1];if("channel.index"==t.name&&t.context){var o=t.context.get("isFollowing.isFollowing");void 0!==o&&null!==o&&this.track("setCustomVariable","1","Following",o?"Yes":"No","page");var n=t.context.get("game");n&&this.track("setCustomVariable","3","Game",n,"page"),this.track("trackPageView",document.title)}}}}},{"./constants":3}],18:[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,n=e._popup;n&&(n=jQuery(n),o=n.parent(),o.is(t.target)||0!==o.has(t.target).length||(n.remove(),delete e._popup))})},t.prototype.build_ui_popup=function(t){var o=this._popup;if(o)return o.parentElement.removeChild(o),void delete this._popup;var n=document.createElement("div"),s=document.createElement("div");n.className="emoticon-selector chat-menu ffz-ui-popup",s.className="emoticon-selector-box dropmenu",n.appendChild(s);var r=t.get("controller.currentRoom.id"),i=this.rooms[r];this.log("Menu for Room: "+r,i),this.track("trackEvent","Menu","Open",r);var a=document.createElement("a");a.className="button glyph-only ffz-button",a.title="Advertise for FrankerFaceZ in chat!",a.href="#",a.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 l=document.createElement("div");l.className="list-header first",l.appendChild(a),l.appendChild(document.createTextNode("FrankerFaceZ")),s.appendChild(l);var c=this._emotes_for_sets(s,t,i&&i.menu_sets||[]);this._ws_exists?0===c?a.addEventListener("click",this._add_emote.bind(this,t,"To use custom emoticons in tons of channels, get FrankerFaceZ from http://www.frankerfacez.com")):a.addEventListener("click",this._add_emote.bind(this,t,"To view this channel's emoticons, get FrankerFaceZ from http://www.frankerfacez.com")):(a.className="button ffz-button primary",a.innerHTML="Server Error",a.title="FFZ Server Error",a.addEventListener("click",alert.bind(e,"The FrankerFaceZ client was unable to create a WebSocket to communicate with the FrankerFaceZ server.\n\nThis is most likely due to your browser's configuration either disabling WebSockets entirely or limiting the number of simultaneous connections. Please ensure that WebSockets have not been disabled."))),this._feature_friday_ui(r,s,t),this._popup=n,s.style.maxHeight=Math.max(300,t.$().height()-171)+"px",t.$(".chat-interface").append(n)},t.prototype._emotes_for_sets=function(e,t,o,n,s){if(null!=n){var r=document.createElement("div");r.className="list-header",r.appendChild(document.createTextNode(n)),s&&r.appendChild(s),e.appendChild(r)}var i=document.createElement("div"),a=0;i.className="emoticon-grid";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){a++;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)),i.appendChild(h)}}}a||(i.innerHTML="This channel has no emoticons.",i.className="chat-menu-content ffz-no-emotes center"),e.appe