Skip to content

Instantly share code, notes, and snippets.

@sirtony
Last active January 5, 2017 07:23
Show Gist options
  • Select an option

  • Save sirtony/d46ea4e2e43940a78c9e to your computer and use it in GitHub Desktop.

Select an option

Save sirtony/d46ea4e2e43940a78c9e to your computer and use it in GitHub Desktop.

Revisions

  1. sirtony revised this gist Jan 5, 2017. 1 changed file with 35 additions and 7 deletions.
    42 changes: 35 additions & 7 deletions togethertube-fullscreen.user.js
    Original file line number Diff line number Diff line change
    @@ -1,28 +1,56 @@
    // ==UserScript==
    // @name Togethertube Fullscreen
    // @namespace https://github.com/SirTony
    // @version 0.1
    // @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;
    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 );
    } )();
    } );
  2. sirtony revised this gist Oct 16, 2015. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion togethertube-fullscreen.user.js
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,10 @@ $( "div#bs-example-navbar-collapse-1:nth-of-type(1) ul.nav.navbar-nav.navbar-rig

    $( "a#btn-fullscreen" ).click( function() {
    var frame = $( "div#player div iframe" )[0];
    var func = frame.requestFullscreen || frame.mozRequestFullScreen || frame.msRequestFullscreen || frame.webkitRequestFullScreen;
    var func = frame.requestFullscreen
    || frame.mozRequestFullScreen
    || frame.msRequestFullscreen
    || frame.webkitRequestFullScreen;

    if( typeof func !== "function" )
    {
  3. sirtony created this gist Oct 16, 2015.
    25 changes: 25 additions & 0 deletions togethertube-fullscreen.user.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    // ==UserScript==
    // @name Togethertube Fullscreen
    // @namespace https://github.com/SirTony
    // @version 0.1
    // @description Enables fullscreen on togethertube.com
    // @author Tony J. Ellis
    // @match https://togethertube.com/rooms/*
    // @grant none
    // ==/UserScript==

    $( "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 );
    } );