Skip to content

Instantly share code, notes, and snippets.

@KustoSan
Created September 16, 2015 10:32
Show Gist options
  • Save KustoSan/d763cbb7fbf25b164ab0 to your computer and use it in GitHub Desktop.
Save KustoSan/d763cbb7fbf25b164ab0 to your computer and use it in GitHub Desktop.
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