Last active
September 10, 2021 22:12
-
-
Save Dalet/52860b639638e99db782 to your computer and use it in GitHub Desktop.
Twitch HTML5 player userscript
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
// ==UserScript== | |
// @name Twitch HTML5 player | |
// @namespace Revolution | |
// @include http://*.twitch.tv/* | |
// @exclude http://api.twitch.tv/* | |
// @exclude http://tmi.twitch.tv/* | |
// @exclude http://chatdepot.twitch.tv/* | |
// @require https://gist.githubusercontent.com/BrockA/2625891/raw/9c97aa67ff9c5d56be34a55ad6c18a314e5eb548/waitForKeyElements.js | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
//parts of the code taken from https://github.com/EchoDev/TwitchHTML5 | |
var currentUrl = null; | |
setInterval(function () { | |
if (window.location.href === currentUrl) | |
return; | |
currentUrl = window.location.href; | |
if (/^\/[^/]+\/?$/.test(window.location.pathname)) { | |
waitForKeyElements('.js-player', function () { | |
$('.js-player').html($('<iframe>').attr({ | |
'src': 'http://player.twitch.tv/?branding=false&showInfo=false&html5&channel=' + window.location.pathname.substr(1), | |
"width": "100%", | |
"height": "100%", | |
"allowfullscreen": true, | |
"webkitallowfullscreen": true, | |
"mozallowfullscreen": true | |
}).css('border', 0) | |
); | |
var r = $('<button class="button primary float-left enter-theater-button"><span>Theater Mode</span></button>'); | |
$(".ember-chat .chat-interface .chat-buttons-container").append(r); | |
$(".enter-theater-button").toggle(function enable() | |
{ | |
$("#player").removeClass("dynamic-player"); | |
$(".app-main").addClass("theatre"); | |
$(".conversations-content .conversations-list-container").css("display","none"); | |
}, function disable() | |
{ | |
$("#player").addClass("dynamic-player"); | |
$(".app-main").removeClass("theatre"); | |
}); | |
}); | |
} | |
}, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
yes