Created
September 16, 2015 10:32
-
-
Save KustoSan/d763cbb7fbf25b164ab0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function TwitchHtml5VideoPlayer() { | |
// Remove old stuff | |
SiteOptions.video_experiments = ''; | |
// Does injection stuff | |
var inject = function() { | |
setTimeout(function() { | |
// Window the stuff | |
if (!window.Ember || !window.App || App.__container__.lookup("controller:application").get("currentRouteName") !== "channel.index") { | |
return; | |
} | |
// Player Stuff | |
var twitchPlayer = $('div#player div div object'); | |
if (twitchPlayer.is('object')) { | |
twitchPlayer.replaceWith('<div class="player" id="video-playback">'); | |
player = new Twitch.video.Player("video-playback","branding=false&showInfo=false&channel=" + window.location.pathname.substr(1)); | |
} | |
}, 5000); | |
}; | |
inject(); | |
// History stuff | |
(function(history){ | |
var pushState = history.pushState; | |
history.pushState = function(state) { | |
if (typeof history.onpushstate == "function") { | |
history.onpushstate({state: state}); | |
} | |
inject(); | |
return pushState.apply(history, arguments); | |
} | |
})(window.history); | |
} | |
var script = document.createElement('script'); | |
script.appendChild(document.createTextNode('('+ TwitchHtml5VideoPlayer +')();')); | |
(document.body || document.head || document.documentElement).appendChild(script); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment