Advertisement
Guest User

Untitled

a guest
Apr 1st, 2015
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 32.00 KB | None | 0 0
  1. this._videoType&&this.setTrackingData("video-type",this._videoType);var s;this.swfTrackingInterval=setInterval(function(){if(TMI){var e=TMI.getMessageRate();if(e!==s){s=e;var t={chat_msg_rate:e};r.setTrackingData("minute-watched",_.extend(t,i)),r.setTrackingData("buffer-empty",t)}}},1e3),e.chromecast.initialize(this),this.isReady=!0,this._readyDeferred.resolve(this)},o.prototype.promise=function(e,t){return this._readyDeferred.promise.then(e,t)},o.prototype._onEvents=function(e){var t;for(var n=0;n<e.length;n++){t=e[n];try{this._onEvent(t)}catch(r){console.warn("Error handling FlashPlayer2 event "+t.event+": "+r)}}},o.prototype._onEvent=function(e){switch(e.event){case"playerInit":this._onPlayerInit();break;default:this.trigger(e.event,e.data)}},function(){_.each(r,function(e){o.prototype[e]=function(){if(this.isReady&&this.ref[e])return this.ref[e].apply(this.ref,arguments)}})}(),e.player.FlashPlayer2=o;var u={callbackId:0,register:function(t){e.player.FlashPlayer2.callbacks=e.player.FlashPlayer2.callbacks||{};var n="callback"+this.callbackId++;return e.player.FlashPlayer2.callbacks[n]=t,"Twitch.player.FlashPlayer2.callbacks."+n}}}(Twitch,jQuery),function(e,t){var n=function(e,n){var r=this,i=null;r.player=n,r.$playerEl=n.$el,n.on("adFeedbackShow",function(e){i=e.adId,r.show()}),r.$el=t(e),r.$el.find(".close-btn").click(function(){r.$el.hide()}),r.$el.find("a").each(function(e,s){var o=t(s);o.click(function(e){e.preventDefault(),r.$el.hide(),n.adFeedbackDone({ad_id:i,ad_feedback:o.attr("name")})})})};t.extend(n.prototype,{show:function(){this.$el.show()}}),e.player.AdFeedbackMenu=n}(Twitch,jQuery),function(e,t){var n=function(e){this.googlePromise=t.getScript("//s0.2mdn.net/instream/html5/ima3.js"),this.options=e,this.$clickTracker=t(".js-clicktracker"),this.$player=t(e.player)};n.prototype.showClickTracker=function(){this.$clickTracker.show(),this.$player.attr("controls",!1)},n.prototype.hideClickTracker=function(){this.$clickTracker.hide(),this.$player.attr("controls",!0)},n.prototype.initialize=function(){var e=this;return new RSVP.Promise(function(n,r){e.googlePromise.then(function(){e.adDisplayContainer=new google.ima.AdDisplayContainer(e.options.container,e.options.player,e.$clickTracker[0]),e.adsLoader=new google.ima.AdsLoader(e.adDisplayContainer),e.adsManager=null,e.adsLoader.addEventListener(google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,e.onAdsManagerLoaded,!1,e),e.adsLoader.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR,e.onAdError,!1,e),e.adDisplayContainer.initialize(),n()}).fail(function(){t(e).trigger("error"),r()})})},n.prototype.requestAds=function(e){var n=new google.ima.AdsRequest;n.adTagUrl=e;var r=t(this.options.player).width(),i=t(this.options.player).height();n.linearAdSlotWidth=r,n.linearAdSlotHeight=r,n.nonLinearAdSlotWidth=i,n.nonLinearAdSlotHeight=i,this.adsLoader.requestAds(n)},n.prototype.onAdsManagerLoaded=function(e){console.debug("Ads Manager loaded."),this.adsManager=e.getAdsManager(this.options.player),this.processAdsManager(this.adsManager)},n.prototype.processAdsManager=function(e){e.addEventListener(google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED,this.onContentPauseRequested,!1,this),e.addEventListener(google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,this.onContentResumeRequested,!1,this),e.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR,this.onAdError,!1,this);var t=[google.ima.AdEvent.Type.ALL_ADS_COMPLETED,google.ima.AdEvent.Type.CLICK,google.ima.AdEvent.Type.COMPLETE,google.ima.AdEvent.Type.FIRST_QUARTILE,google.ima.AdEvent.Type.LOADED,google.ima.AdEvent.Type.MIDPOINT,google.ima.AdEvent.Type.PAUSED,google.ima.AdEvent.Type.RESUMED,google.ima.AdEvent.Type.STARTED,google.ima.AdEvent.Type.THIRD_QUARTILE];for(var n=0;n<t.length;n++)e.addEventListener(t[n],this.onAdEvent,!1,this);e.init(1,1,google.ima.ViewMode.NORMAL),e.start()},n.prototype.onContentPauseRequested=function(e){},n.prototype.onContentResumeRequested=function(e){this.hideClickTracker(),t(this).trigger("contentResumeRequested")},n.prototype.onAdEvent=function(e){console.debug("Ad event: "+e.type);switch(e.type){case google.ima.AdEvent.Type.STARTED:this.showClickTracker(),this.options.player.load();break;case google.ima.AdEvent.Type.RESUMED:this.showClickTracker();break;case google.ima.AdEvent.Type.CLICK:this.hideClickTracker();break;case google.ima.AdEvent.Type.ALL_ADS_COMPLETED:this.hideClickTracker()}t(this).trigger(e.type)},n.prototype.onAdError=function(e){console.error("Ad error: "+e.getError().toString()),this.adsManager&&this.adsManager.destroy(),this.hideClickTracker(),t(this).trigger("adError")},e.player.AdsController=n}(Twitch,jQuery),function(e,t){var n={};n.player=null;var r=null,i=null,s=null,o=!1,u=!1,a=function(){if(o&&u&&s)n.player.showChromecast(!0),n.player.setChromecastConnected(!0,s.receiver.friendlyName);else{var e=new chrome.cast.SessionRequest("358E83DC"),t=new chrome.cast.ApiConfig(e,c,h,chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED);chrome.cast.initialize(t,f,l)}},f=function(){o=!0,o&&u&&n.player.showChromecast(!0)},l=function(e){e.code==="session_error"&&d()},c=function(e){s=e,s.addUpdateListener(p),s.media.length!==0&&m("sessionListener",s.media[0]),n.player.setChromecastConnected(!0,s.receiver.friendlyName)},h=function(e){e===chrome.cast.ReceiverAvailability.AVAILABLE?(u=!0,o&&u&&n.player.showChromecast(!0)):(u=!1,n.player.showChromecast(!1))},p=function(e){e||d()},d=function(){s&&s.removeUpdateListener(p),i&&i.removeUpdateListener(g),s=null,i=null,n.player.setChromecastConnected(!1)},v=function(e){s=e,s.addUpdateListener(p),n.player.setChromecastConnected(!0,s.receiver.friendlyName)},m=function(e,t){i=t,i.addUpdateListener(g.bind(this,t))},g=function(e,t){t?s.media.length&&e===s.media[0]&&(e.playerState===chrome.cast.media.PlayerState.PAUSED?(r=e.media.customData.channel,n.player.togglePlayPause(!0)):e.playerState===chrome.cast.media.PlayerState.PLAYING&&n.player.togglePlayPause(!1)):(e.removeUpdateListener(g),e.media.customData.channel.toUpperCase()===window.location.pathname.substring(1).toUpperCase()&&(r&&r===e.media.customData.channel?(r="",n.player.togglePlayPause(!1)):n.player.setChromecastConnected(!1)))};n.initialize=function(t){t.on("videoPlaying",_.once(function(){typeof chrome!="undefined"&&chrome.cast&&chrome.cast.isAvailable&&(n.player=t,a())})),t.on("chromecastSessionRequested",function(){chrome.cast.requestSession(v,l)}),t.on("chromecastMediaSet",function(t){if(s.media.length!==0&&i&&i.media.customData.channel&&i.media.customData.channel.toUpperCase()===t.channel.toUpperCase())return;var n=new chrome.cast.media.MediaInfo(t.url,"application/x-mpegurl");n.streamType=chrome.cast.media.StreamType.LIVE;var r=new chrome.cast.media.GenericMediaMetadata;e.api.get("streams/"+t.channel).then(function(e){if(e.stream){var i=e.stream;i.game&&(r.subtitle=i.game),i.channel&&(i.channel.display_name&&(r.title=i.channel.display_name),i.channel.logo?r.images=[new chrome.cast.Image(i.channel.logo)]:r.images=[new chrome.cast.Image(i.preview.medium)]),n.metadata=r,n.customData={channel:t.channel,analytics:t.analytics};var o=new chrome.cast.media.LoadRequest(n);o.autoplay=!0,s.loadMedia(o,m.bind(this,"loadMedia"),l)}})}),t.on("chromecastVolumeUpdated",function(e){s&&s.setReceiverVolumeLevel(e.volume,null,l)}),t.on("pauseChromecastSession",function(){i&&(r=i.media.customData.channel,i.pause(new chrome.cast.media.PauseRequest,null,null),i=null)})},e.mixin({chromecast:n})}(Twitch,jQuery),function(e,t){var n=function(e,t){this.channel=e,this.stream=t},r=function(t,n){return new RSVP.Promise(function(r,i){e.api.get(t).done(function(e){r(_.reduce(n,function(t,n,r){if(typeof n=="function"){var i=n(e[r]||"");i&&(t[i.key]=i.val)}else _.has(e,r)&&(t[n]=e[r]);return t},{}))}).fail(function(e){r({})})})},i=function(e){return r("/api/channels/"+e,{partner:"partner",name:"channel",broadcaster_software:"broadcaster_software",game:function(e){return{key:"game",val:e||"None"}}})},s=function(e){return r("channels/"+e,{teams:function(e){if(_.isArray(e)&&e.length>0&&_.has(e[0],"name"))return{key:"team",val:e[0].name}}})},o=function(){return r("/api/viewer/info.json",{login:function(e){return{key:"login",val:e}},turbo:function(e){return{key:"turbo",val:!!e}}})},u=function(e){return r("/api/channels/"+e+"/viewer",{chansub:function(e){return{key:"subscriber",val:!!e}}})},a=function(e){return new RSVP.Promise(function(n,r){t.ajax({method:"GET",url:e,cache:!1,success:function(e){var t=e.match(/nname=([^,&]+)[,&]/);if(t.length>1){var r=t[1].split(".");r.length>1&&n({node:t[1],cluster:r[1]})}else console.warn("no match found for clusterPattern."),n({})},error:function(){console.warn("error in fetching stream data"),n({})}})})};n.prototype.load=function(e){var t=[],n=this.channel,r=this.stream;return console.info("pulling Context info"),t.push(i(n)),t.push(s(n)),t.push(o()),t.push(u(n)),t.push(a(r)),RSVP.all(t).then(function(t){var n=e||{};return console.info("Combining properties..."),_.each(t,function(e){_.extend(n,e)}),n},function(e){console.error(e)})},e.player.ContextLoader=n}(Twitch,jQuery),function(e,t){var n=function(t,n){var r=this;this.queue=[],RSVP.EventTarget.mixin(this.queue),this.basicProperties={b:e.storage.get("b",{storage:"sessionStorage"})==="true"},t.load(n).then(function(t){r.basicProperties=t,r.queue.on("eventInQueue",function(t){var n=r.queue.pop();e.tracking.mixpanel.trackEvent(n.event,_.extend({},r.basicProperties,n.properties)),r.queue.length>0&&r.queue.trigger("eventInQueue")}),r.queue.length>0&&r.queue.trigger("eventInQueue")})};n.prototype.handle=function(e,t){t=t||{},this.queue.push({event:e,properties:t}),this.queue.trigger("eventInQueue")},e.player.EventHandler=n}(Twitch,jQuery),function(e,t){var n=function(t,n,r){this.context=new e.player.ContextLoader(t,n),this.handler=new e.player.EventHandler(this.context,r),this.trackingMinutesWatched=!1};n.prototype.trackVideoPlaying=function(e){if(!this.trackingMinutesWatched){var t=1,n=this;this.trackingMinutesWatched=!0,this.sendVideoPlay(),setInterval(function(){e.contentPlayer.paused||(console.info("logging a minute watched "+(new Date).toTimeString()),n.sendMinuteWatched(t++))},6e4)}},n.prototype.sendMinuteWatched=function(t){this.handler.handle("minute-watched",{minutes_logged:t,distinct_id:e.idsForMixpanel.createUniqueId()})},n.prototype.sendVideoPlay=function(){this.handler.handle("video-play")},n.prototype.sendVideoAdOpportunity=function(e,t){this.handler.handle("video_ad_opportunity",{provider:t,roll_type:e})},n.prototype.sendVideoAdImpression=function(e,t){this.handler.handle("video_ad_impression",{provider:t,roll_type:e})},e.player.EventController=n}(Twitch,jQuery),function(e,t){var n=function(e){this.options=e,this.$el=t("#"+e.id),this.el=this.$el[0],this.$contentPlayer=this.$el.find(".js-video_player video"),this.contentPlayer=this.$contentPlayer[0],this.contentPlayer.load(),this.adContainer=this.$el.find(".js-ad_container").show()[0],this.videoPlayerContainer=this.$el.find(".js-video_player")[0],this._onlineStatus="unknown",this.bufferEmpties=0};n.canPlayHLS=function(){var e=navigator.userAgent,t=document.createElement("video");if(e.match(/iPhone|iPod|iPad/))return!0;try{return t&&t.canPlayType&&!!t.canPlayType('application/x-mpegURL; codecs="avc1.42E01E, mp4a.40.2"')}catch(n){return!1}},n.prototype.init=function(r,i){console.info("HTML5Player.init"),r=r||function(){},i=i||function(){};if(this.options.videoId){console.info("HTML5Player.init error"),i("HTML5 player doesn't support archives");return}var s=navigator.userAgent.match(/Android/i);if(!n.canPlayHLS()&&!s){this.$el.find(".js-message").show().text("Unsupported player."),console.info("HTML5Player.init error"),i("Browser doesn't support HLS");return}this.$el.show();var o=this;e.hls.getPlaylist(this.options.channel).then(function(n){o._onlineStatus="online",t(o).triggerHandler("online");var i=o.eventController=new e.player.EventController(o.options.channel,n,{vid_width:o.$contentPlayer.width(),vid_height:o.$contentPlayer.height(),player:o.options.player,video_renderer:"html5",platform:o.options.platform,adblock:e.storage.get("adblock_enabled",{storage:"sessionStorage"})==="true",app_version:"HTML5 0.1",browser:navigator.userAgent,orientation:window.innerHeight>=window.innerWidth?"portrait":"landscape",live:!0,buffer_empty_count:undefined,quality:undefined,fullscreen:undefined}),s=function(e){t.ajax({type:"GET",url:"http://fan.twitch.tv/"+e,cache:!1,data:{channel:o.options.channel,context:"preroll",turbo_token:o.options.turboToken,chansub_token:o.options.channelSubscriptionToken}})};if(o.options.ads===!1){s("ad"),setTimeout(s,3e4,"adcompleted"),o.setSrc(n),console.info("HTML5Player.init success (no ads)"),r();return}var u=new e.player.AdsController({container:o.adContainer,player:o.contentPlayer});t(u).on("start",function(e){s("ad"),i.sendVideoAdImpression("preroll",e.currentTarget.adsLoader.provider)}),t(u).on("contentResumeRequested adError",function(){s("adcompleted"),o.setSrc(n),o.preloadContent(function(){try{o.play()}catch(e){}})}),u.initialize().then(function(){~window.location.href.indexOf("errortest")&&e.deployFlavor!=="production"&&e.deployFlavor!=="beta"?u.requestAds("invalid_ad_url"):~window.location.href.indexOf("twitchtest")?(u.requestAds(e.ads.hls.getAdTagUrl({provider:"test"}),"test"),i.sendVideoAdOpportunity("preroll","test")):(u.requestAds(e.ads.hls.getAdTagUrl({provider:"twitch",platform:"html5",channel:o.options.channel||"",game:o.options.game||"",referrer:document.referrer}),"twitch"),i.sendVideoAdOpportunity("preroll","twitch"))}),console.info("HTML5Player.init success"),r()},function(){o._onlineStatus="offline",t(".js-message").show().text("OFFLINE"),o.$contentPlayer.removeAttr("poster"),console.info("HTML5Player.init success (offline)"),r()})},n.prototype.destroy=function(){},n.prototype.preloadContent=function(e){this.isMobilePlatform()?(this.contentPlayer.addEventListener("loadedmetadata",e,!1),this.contentPlayer.load()):(this.contentPlayer.load(),e())},n.prototype.play=function(){this.contentPlayer.play(),this.eventController.trackVideoPlaying(this)},n.prototype.pause=function(){this.contentPlayer.pause()},n.prototype.isMobilePlatform=function(){return this.contentPlayer.paused&&(navigator.userAgent.match(/(iPod|iPhone|iPad)/)||navigator.userAgent.toLowerCase().indexOf("android")>-1)},n.prototype.getVideoPlayer=function(){return this.contentPlayer},n.prototype.registerVideoEndedCallback=function(e){this.contentPlayer.addEventListener("ended",e,!1)},n.prototype.unregisterVideoEndedCallback=function(e){this.contentPlayer.removeEventListener("ended",e,!1)},n.prototype.onlineStatus=function(){return this._onlineStatus},n.prototype.on=function(e,n){t(this).on(e,n)},n.prototype.off=function(e,n){t(this).off(e,n)},n.prototype.mute=function(){this.$contentPlayer.prop("muted",!0)},n.prototype.unmute=function(){this.$contentPlayer.prop("muted",!1)},n.prototype.setSrc=function(e){this.contentPlayer.src=e},e.player.HTML5Player=n}(Twitch,jQuery),function(e,t){var n={},r={AT:1,BE:1,BG:1,CY:1,CZ:1,DE:1,DK:1,EE:1,FI:1,FR:1,GR:1,GL:1,HU:1,IS:1,IT:1,LT:1,LU:1,NL:1,NO:1,PL:1,PT:1,RO:1,RU:1,SK:1,SI:1,ES:1,SE:1,CH:1,TR:1,LV:1,MT:1,RS:1,AL:1,AD:1,AM:1,AZ:1,BY:1,BA:1,HR:1,GE:1,IL:1,LI:1,MK:1,MD:1,MC:1,ME:1,SM:1,UA:1,UK:1,GB:1,QA:1,IE:1},i="3576121",s="98544404",o=i,u=window.location.toString(),a="Deprecation warning: use the asynchronous Twitch.asyncAds.ready(..)",f=function(){console.debug(a)};n.ready=function(t){var r=new RSVP.Promise(function(t){e.user(function(e){t(_.pick(e,"has_turbo"))},function(){t(!1)})});RSVP.all([r,e.geo]).then(function(e){var r=e[0],i=e[1].geo,s=!r||!r.has_turbo,o=n.integration(i);t(n._readyData={geo:i,enabled:s,integration:o,dfpEnabled:o==="dfp"})})},n.integration=function(e){return e===undefined&&(f(),e=PP.geo),r[e]===1&&(o=s),"dfp"},n.enabled=function(){return n._readyData?n._readyData.enabled:(f(),!PP.turbo&&!PP.activeChannelSubscriber&&(!PP.login||PP.login!==PP.channel))},n.dfpEnabled=function(){return n._readyData?n._readyData.dfpEnabled:(f(),e.ads.enabled()&&e.ads.integration()==="dfp")},n.synchronousLoad=function(){var n=["esl"];return~t.inArray(e.ads.integration(),n)},n.fetchAll=function(){var t=!e.ads.enabled(),n=e.ads._readyData?e.ads._readyData.geo:undefined;e.ads.dfpEnabled()&&googletag.cmd.push(function(){googletag.pubads().refresh()})};var l=[];n.pushGoogleTag=function(r,i,s){l.push(function(){var o=e.ads.dfpSlotPath(n.dfpSlotName()),u=r+"_holder";googletag.pubads().setTargeting("pagetype",n.dfpPageType()),googletag.defineSlot(o,i,u).addService(googletag.pubads()),googletag.cmd.push(function(){googletag.display(r+"_holder")}),s&&t("#"+r+"_holder").hide()})},n.registerGoogleTags=function(){l.forEach(function(e){googletag.cmd.push(e)})},n.slotName=function(e){return"Twitch_"+e};var c={};c.leader=function(n){if(!e.ads.enabled())return;e.ads.dfpEnabled()&&e.ads.pushGoogleTag(n,[[970,66],[728,90]]),e.asyncAds.ready(function(e){t(".ad_leader").addClass(e.integration)})},c.pushdown=function(n){e.ads.dfpEnabled()&&e.ads.pushGoogleTag(n,[[970,418],[970,67],[970,250],[970,150],[980,250]],!0),e.asyncAds.ready(function(e){t(".fp_opa_pushdown").addClass(e.integration)})},c.rectangle=function(n){if(!e.ads.enabled()){t(".advertisement").hide(),t(".ad_contain").hide();return}var r=function(){window.SitePageType==="directory"&&(t(".ad_contain .advertisement").show(),t("#"+n+"_holder .adFrame").css("height","250px"),t(".ad_contain").show())};e.ads.dfpEnabled()&&e.ads.pushGoogleTag(n,[[300,250],[300,600],[250,600]])},c.siteskin=function(t){e.ads.dfpEnabled()&&e.ads.pushGoogleTag(t,[1,1],!0)},n.prepareAd=function(t,n){var r=e.ads.slotName(t);c[n]&&c[n](r)},n.hls={formatGame:function(e){return(e||"").toLowerCase().replace(/[^a-z0-9]+/g,"_")},stripAmpEq:function(e){return e.replace(/[&=]/g,"")},getAdTagUrl:function(t){var n,r;switch(t.provider){case"twitch":return n="http://pubads.g.doubleclick.net/gampad/ads?sz=640x480&ad_rule=0&gdfp_req=1&iu=/{{dfpNetworkCode}}/twitch/channels/{{channel}}&ciu_szs=300x250&url={{referrer}}&correlator={{timestamp}}&env=vp&unviewed_position_start=1&output=xml_vast3&cust_params={{custom}}",r="chan={{channel}}&timebreak=30&game={{game}}&platform={{platform}}&mature=true&pos=pre",Mustache.render(n,{channel:t.channel,referrer:t.referrer,timestamp:(new Date).getTime(),dfpNetworkCode:e.ads.dfpNetworkCode(),custom:escape(Mustache.render(r,{channel:e.ads.hls.stripAmpEq(t.channel),game:e.ads.hls.formatGame(t.game),platform:t.platform?e.ads.hls.stripAmpEq(t.platform):"html5"}))});case"test":return"http://pubads.g.doubleclick.net/gampad/ads?sz=400x300&iu=%2F6062%2Fiab_vast_samples&ciu_szs=300x250%2C728x90&impl=s&gdfp_req=1&env=vp&output=xml_vast3&unviewed_position_start=1&url=[referrer_url]&correlator=[timestamp]&cust_params=iab_vast_samples%3Dlinear"}}},n.dfpPageType=function(){switch(window.SitePageType){case"front_page":return"homepage";case"search":return"search";default:return console.error("TWITCH: Set a DFP page type"),""}},n.dfpSlotPath=function(e){return"/"+n.dfpNetworkCode()+"/twitch/"+e},n.dfpSlotName=function(){switch(window.SitePageType){case"front_page":return"homepage";case"search":return"directory";default:return console.error("TWITCH: Set a DFP page type"),""}},n.dfpNetworkCode=function(){return o},e.mixin({ads:n})}(Twitch,jQuery),function(e,t){var n={};n.mutePlayer=function(){e.player.ready(function(e){e.mute()})},n.unmutePlayer=function(){e.player.ready(function(e){e.unmute()})},e.ads.ext=n}(Twitch,jQuery),function(e,t){window.lrAdImpression||(window.lrAdImpression=function(t){t=t||{},e.ads.lastLiverailAdId=["connectionID="+t.connectionID,"creativeID="+t.creativeID,"id="+t.id].join("&")})}(Twitch,jQuery),function(e,t){var n={enabled:!1};n.ready=e.ads.ready,n.enable=function(){this.enabled=!0},n.megatag=function(){return this._megatagPromise||(this._megatagPromise=new RSVP.Promise(function(e){t.getScript("/javascripts/libs/megatag.js",function(){typeof adnxs!="undefined"&&e(adnxs.megatag)})})),this._megatagPromise},n.metadata={game:"",dfpPageType:"",campaign:""},n.setMetadata=function(t,n){switch(t){case"game":n=(n||"").replace(/[^A-Za-z0-9]+/g,"_"),e.asyncAds.metadata.game=n;break;case"chan":e.asyncAds.metadata.chan=n;break;case"dfpPageType":e.asyncAds.metadata.pagetype=n;break;case"campaign":e.asyncAds.metadata.campaign=n}};var r=_.memoize(function(){return{"dfp-directory-banner":{sizes:[[970,66],[728,90],[970,250]],unitName:"/"+e.ads.dfpNetworkCode()+"/twitch/directory"},"dfp-directory-rectangle":{sizes:[[300,250]],unitName:"/"+e.ads.dfpNetworkCode()+"/twitch/directory"},google_companion_300x60:{sizes:[[300,60]],unitName:"/"+e.ads.dfpNetworkCode()+"/twitch/channels"},google_companion_300x250:{sizes:[[300,250]],unitName:"/"+e.ads.dfpNetworkCode()+"/twitch/channels"},"dfp-channel-adlight":{sizes:[[239,80]],unitName:"/"+e.ads.dfpNetworkCode()+"/twitch/ad_light"}}});n.fetchAds=function(n){var r=e.ads._readyData;if(this.enabled&&r&&r.enabled&&r.dfpEnabled){t("#dfp-directory-banner, .ad_contain").hide();var i=["dfp-directory-banner"];(!n||!n.singleOnly)&&i.push("dfp-directory-rectangle"),e.asyncAds.sra({slots:i}).then(function(e){e[0]&&t("#dfp-directory-banner").show(),e[1]&&t(".ad_contain").show().attr("style","display: block !important")})}},n.resetGoogletag=function(){return window.googletag&&delete window.googletag,window.googletag={cmd:[]},t.getScript("//www.googletagservices.com/tag/js/gpt.js")},n.ensureLiveRail=function(){return t.getScript("http://cdn-static.liverail.com/js/companions.js")},n.prepareCompanionAds=function(t){return new RSVP.Promise(function(i,s){var o=e.ads._readyData;if(n.enabled&&o&&o.enabled){var u=_.after(2,i);n.ensureLiveRail().then(function(){lrCompanionDisplayCallback["300x250"]='Twitch.asyncAds.afterCompanionAdsRendered("liverail");',u()},u),n.resetGoogletag().then(function(){var e=r();googletag.cmd.push(function(){t.slots.forEach(function(t){googletag.defineSlot(e[t].unitName,e[t].sizes,t).addService(googletag.companionAds())}),SiteOptions.dfp_sidebar_channel_ad&&googletag.defineSlot(e["dfp-channel-adlight"].unitName,e["dfp-channel-adlight"].sizes,"dfp-channel-adlight").addService(googletag.pubads()),googletag.pubads().collapseEmptyDivs(),googletag.enableServices()}),u()},u)}else i()})},n.displayAdLight=function(){googletag.pubads().clearTargeting(),googletag.pubads().setTargeting("game",e.asyncAds.metadata.game),googletag.pubads().setTargeting("chan",e.asyncAds.metadata.chan),googletag.pubads().setTargeting("pagetype",e.asyncAds.metadata.pagetype),googletag.pubads().setTargeting("campaign",e.asyncAds.metadata.campaign),googletag.pubads().setTargeting("server",e.deployFlavor),googletag.display("dfp-channel-adlight")},n.afterCompanionAdsRendered=function(e){t(".js-new-channel-ad").length&&(e==="google"?(t(".new_advertisement").hide(),t("#lr_comp_300x250").hide(),t("#google_companion_300x60").hide(),t("#google_companion_300x250").hide(),t("#google_companion_300x250").is(":empty")?t("#google_companion_300x60").show():t("#google_companion_300x250").show()):e==="liverail"&&(t("#google_companion_300x250").hide(),t("#google_companion_300x60").hide()),t(".js-ad-actions").show(),t(".new_advertisement").show(),setTimeout(function(){var e=t(".js-new-channel-ad").outerHeight();t(".js-rightcol-content").css("top",e)}))},n.sra=function(i){var s=function(){this.slots&&this.slots.forEach(function(e){e.el&&e.el.empty()});var e=this,t=this.slots=[];return function(n){return function(){if(t===e.slots)return n.apply(this,arguments)}}},o=function(){if(googletag.debug_log._events)return googletag.debug_log._events;var e=googletag.debug_log.log,t=RSVP.EventTarget.mixin({});return googletag.debug_log.log=function(n,r,i,s,o){return r.getMessageId()===6&&t.trigger("gpt-slot_rendered"),e.apply(this,arguments)},googletag.debug_log._events=t,t},u=function(i){var u=this,a=s();return new RSVP.Promise(function(s,f){n.resetGoogletag().then(a(function(){var n=r();i.slots.forEach(function(e){u.slots.push({id:e,el:t("#"+e)}),googletag.defineSlot(n[e].unitName,n[e].sizes,e).addService(googletag.pubads())}),o().on("gpt-slot_rendered",_.after(i.slots.length,function(){s(_.map(u.slots,function(e){return e.el.css("display")!=="none"}))})),googletag.pubads().clearTargeting(),googletag.pubads().setTargeting("game",e.asyncAds.metadata.game),googletag.pubads().setTargeting("pagetype",e.asyncAds.metadata.pagetype),googletag.pubads().setTargeting("campaign",e.asyncAds.metadata.campaign),googletag.pubads().setTargeting("server",e.deployFlavor),googletag.pubads().enableSingleRequest(),googletag.pubads().collapseEmptyDivs(),googletag.enableServices(),googletag.display(i.slots[0])}),f)})};return u(i)},e.mixin({asyncAds:n})}(Twitch,jQuery),function(e,t){var n={};n.write=function(t,n,r){r=r||{};var t="TwitchCache:"+t;e.storage.setObject(t,{resource:n,expiration:r.milliseconds,time:(new Date).getTime(),version:r.version,restrict:r.restrict},_.pick(r,"storage"))},n.read=function(t,n){n=n||{};var t="TwitchCache:"+t,r=e.storage.getObject(t,_.pick(n,"storage"));return r?r.expiration&&(new Date).getTime()-r.time>r.expiration||n.version!==r.version||!_.isEqual(n.restrict,r.restrict)?(e.storage.del(t,_.pick(n,"storage")),null):r.resource:null},e.mixin({cache:n})}(Twitch,window.Zepto||window.jQuery),function(e,t){var n={};n.infoModal=function(n,r,i,s){s=typeof s!="undefined"?s:{},t(r).overlay(n,function(){t(i).click(function(e){e.preventDefault(),t(this).trigger("overlay.hide")})},e.defaults(s,{width:"420px"}))},e.mixin({dashboard:n})}(Twitch,jQuery),function(e,t){var n=function(e,t){return t-=e.toString().length,t>0?(new Array(t+(/\./.test(e)?2:1))).join("0")+e:e+""},r={capitalize:function(e){return e=e||"",e.charAt(0).toUpperCase()+e.slice(1)},commatize:function(e){return e=e||0,isNaN(e)?e:e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")},getTime:function(e){var t=n(e.getMinutes(),2),r=e.getHours();return r>12?r-=12:r===0&&(r=12),r+":"+t},lengthAsClock:function(e){var t=Math.floor(e%60),r=Math.floor(e%3600/60),i=Math.floor(e/3600);return i?i+":"+n(r,2)+":"+n(t,2):r+":"+n(t,2)},clockAsLength:function(e){var t=e.split(":"),n=parseInt(t[t.length-1],10),r=parseInt(t[t.length-2],10),i=0;return t.length>2&&(i=parseInt(t[t.length-3],10)),n+60*r+3600*i},escape:function(e){return t("<div/>").text(e).html()}};e.mixin({display:r})}(Twitch,jQuery),function(e,t){var n={};n.init=function(t){this.config=e.defaults(t,{forgetDuration:t.forgetDuration,delay:t.delay});var n=Number.POSITIVE_INFINITY,r=parseInt(e.storage.get("requestUserEmail"),10);isNaN(r)||(n=+(new Date)-r),n>this.config.forgetDuration*1e3&&setTimeout(e.emailNotifier.requestUserEmail,this.config.delay*1e3)},n.requestUserEmail=function(){var t={timeout:2e4,escape:!1};e.storage.set("requestUserEmail",+(new Date)),e.api.get("user").done(function(n){var r=URI(window.location.href).path();!n.email&&r!=="/settings"&&(e.tracking.mixpanel.trackEvent("email_notice",{type:"display"}),e.notify('Welcome to Twitch! <a href="/settings?type=email_notice">Please click here to verify your email! </a>',t))})},e.mixin({emailNotifier:n})}(Twitch,jQuery),function(e,t){var n=SiteOptions.current_experiments||{},r={};n=_.object(_.map(n,function(e){return e.name}),_.map(n,function(e){return _.omit(e,"name")})),r.getExperimentGroup=function(t,r){if(!(t in n))return!1;var i=n[t].groups,s=e.url_params().experiments,o=0,u,a;if(_.reduce(_.pluck(i,"weight"),function(e,t){return e+t})!==1)throw new Error("experiment group weights do not sum to 1");if(s&&s[t]&&_.contains(_.pluck(i,"name"),s[t]))return s[t];r=r||e.idsForMixpanel.getOrCreateUniqueId(),u=parseInt(Crypto.SHA1(r+t).slice(0,8),16)/Math.pow(2,32);for(a=0;a<i.length;a++){o+=i[a].weight;if(u<=o)return i[a].name}},r.trackExperimentBranch=function(t,n){var r=this.getExperimentGroup(t,n);r&&e.tracking.spadeAndMixpanel.trackEvent("experiment_branch",{experiment_id:t,experiment_group:r})},e.mixin({experiments:r})}(Twitch,jQuery),function(e){var t,n,r=new RSVP.Promise(function(t,n){e.api.on("ready",function(){e.api.get("/api/viewer/info.json").done(function(n){e.preferredLanguage=n.preferred_language,e.receivedLanguage=n.received_language;var r=cookie.get("language");r===undefined?e.language.setCookieAndReload(e.receivedLanguage):n.login&&r!==n.user_language&&e.language.setByAsyncPut(r),n.eu&&window.euCookieNotification(),t(n)}).fail(function(e){n({status:e.status})})})});e.mixin({geo:r,receivedLanguage:n,preferredLanguage:t})}(Twitch),function(e,t){var n="/api/channels/{{channel}}/access_token",r="http://usher.justin.tv/api/channel/hls/{{channel}}.m3u8?token={{{token}}}&sig={{{sig}}}",i={};i.getPlaylist=function(t){return new RSVP.Promise(function(i,s){if(!t||!t.length)return s();e.api.get(Mustache.render(n,{channel:t})).then(function(e){e.token&&e.sig?i(Mustache.render(r,{channel:t,token:e.token,sig:e.sig})):s()},s)})},e.mixin({hls:i})}(Twitch,jQuery);var CryptoJS=CryptoJS||function(e,t){var n={},r=n.lib={},i=function(){},s=r.Base={extend:function(e){i.prototype=this;var t=new i;return e&&t.mixIn(e),t.hasOwnProperty("init")||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},o=r.WordArray=s.extend({init:function(e,n){e=this.words=e||[],this.sigBytes=n!=t?n:4*e.length},toString:function(e){return(e||a).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;e=e.sigBytes,this.clamp();if(r%4)for(var i=0;i<e;i++)t[r+i>>>2]|=(n[i>>>2]>>>24-8*(i%4)&255)<<24-8*((r+i)%4);else if(65535<n.length)for(i=0;i<e;i+=4)t[r+i>>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-8*(n%4),t.length=e.ceil(n/4)},clone:function(){var e=s.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],r=0;r<t;r+=4)n.push(4294967296*e.random()|0);return new o.init(n,t)}}),u=n.enc={},a=u.Hex={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r<e;r++){var i=t[r>>>2]>>>24-8*(r%4)&255;n.push((i>>>4).toString(16)),n.push((i&15).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r+=2)n[r>>>3]|=parseInt(e.substr(r,2),16)<<24-4*(r%8);return new o.init(n,t/2)}},f=u.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r<e;r++)n.push(String.fromCharCode(t[r>>>2]>>>24-8*(r%4)&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r++)n[r>>>2]|=(e.charCodeAt(r)&255)<<24-8*(r%4);return new o.init(n,t)}},l=u.Utf8={stringify:function(e){try{return decodeURIComponent(escape(f.stringify(e)))}catch(t){throw Error("Malformed UTF-8 data")}},parse:function(e){return f.parse(unescape(encodeURIComponent(e)))}},c=r.BufferedBlockAlgorithm=s.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,s=this.blockSize,u=i/(4*s),u=t?e.ceil(u):e.max((u|0)-this._minBufferSize,0);t=u*s,i=e.min(4*t,i);if(t){for(var a=0;a<t;a+=s)this._doProcessBlock(r,a);a=r.splice(0,t),n.sigBytes-=i}return new o.init(a,i)},clone:function(){var e=s.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});r.Hasher=c.extend({cfg:s.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){c.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,n){return(new e.init(n)).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return(new h.HMAC.init(e,n)).finalize(t)}}});var h=n.algo={};return n}(Math);(function(e){function t(e,t,n,r,i,s,o){return e=e+(t&n|~t&r)+i+o,(e<<s|e>>>32-s)+t}function n(e,t,n,r,i,s,o){return e=e+(t&r|n&~r)+i+o,(e<<s|e>>>32-s)+t}function r(e,t,n,r,i,s,o){return e=e+(t^n^r)+i+o,(e<<s|e>>>32-s)+t}function i(e,t,n,r,i,s,o){return e=e+(n^(t|~r))+i+o,(e<<s|e>>>32-s)+t}for(var s=CryptoJS,o=s.lib,u=o.WordArray,a=o.Hasher,o=s.algo,f=[],l=0;64>l;l++)f[l]=4294967296*e.abs(e.sin(l+1))|0;o=o.MD5=a.extend({_doReset:function(){this._hash=new u.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,s){for(var o=0;16>o;o++){var u=s+o,a=e[u];e[u]=(a<<8|a>>>24)&16711935|(a<<24|a>>>8)&4278255360}var o=this._hash.words,u=e[s+0],a=e[s+1],l=e[s+2],c=e[s+3],h=e[s+4],d=e[s+5],v=e[s+6],g=e[s+7],y=e[s+8],b=e[s+9],w=e[s+10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement