Last active
January 5, 2017 07:23
-
-
Save SirTony/d46ea4e2e43940a78c9e to your computer and use it in GitHub Desktop.
A greasemonkey/tampermonkey userscript for enabling fullscreen on https://togethertube.com/
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 Togethertube Fullscreen | |
// @namespace https://github.com/SirTony | |
// @version 0.2 | |
// @description Enables fullscreen on togethertube.com | |
// @author Tony J. Ellis | |
// @match https://togethertube.com/rooms/* | |
// @grant none | |
// @require https://cdnjs.cloudflare.com/ajax/libs/URI.js/1.18.4/URI.min.js | |
// @require https://cdnjs.cloudflare.com/ajax/libs/URI.js/1.18.4/SecondLevelDomains.min.js | |
// ==/UserScript== | |
let registeredClick = false; | |
$( "div#bs-example-navbar-collapse-1:nth-of-type(1) ul.nav.navbar-nav.navbar-right" ) | |
.append( "<li><a id=\"btn-fullscreen\"><i class=\"fa fa-arrows-alt\"></i></a></li>" ); | |
$( "a#btn-fullscreen" ).click( function() { | |
var frame = $( "div#player div iframe" )[0]; | |
var func = frame.requestFullscreen || frame.mozRequestFullScreen || frame.msRequestFullscreen || frame.webkitRequestFullScreen; | |
if( typeof func !== "function" ) | |
{ | |
alert( "Fullscreen not available" ); | |
return; | |
} | |
func.call( frame ); | |
} ); | |
const search = $( "#videoSearchInput" ); | |
search.on( "input", function() { | |
const url = URI.parse( search.val() ); | |
if( !url.hostname ) | |
return; | |
( function() { | |
/* | |
Brute-force this event by trying to register it constantly until it works | |
because togethertube is a huge pain in the ass | |
*/ | |
const buttonId = setInterval( function() { | |
const voteUpButton = $( "div[data-ng-hide='searchInProgress'].ng-isolate-scope button.btn.btn-success.btn-block" ); | |
if( voteUpButton.length === 0 ) | |
return; | |
voteUpButton.click( function() { | |
angular.element( document.getElementById( "videoSearchInput" ) ).scope().videoSearchInput = ""; | |
} ); | |
clearInterval( buttonId ); | |
}, 1 ); | |
} )(); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment