captzulu / Hide Frame TogetherTube(Dih's version)

// ==UserScript==
// @name         Hide Frame TogetherTube(Dih's version)
// @namespace    https://openuserjs.org/scripts/captzulu/Hide_Frame_TogetherTube(Dihs_version)
// @version      0.2
// @description  Hiding the video so you  can listen at work (and bigger chat)
// @author       Captzulu
// @match        https://togethertube.com/rooms/*
// @grant        none
// ==/UserScript==

var player=$('.player-overlay-wrapper');
var colChat=$("div[data-tt-chatlog]").parent();
var colPlayer=player.parents("div.col-xs-8");
var ButtonAdded;
(function() {
    ButtonAdded = $('<button id="ButtonHide" type="button" class="btn btn-default navbar-btn">' + '</button>');
    if(checkIfVisible(player)){
        ButtonAdded.text("Hide Player");
    }else{
        ButtonAdded.text("Show Player");
    }
    $("#bs-example-navbar-collapse-1").append(ButtonAdded);
    
    
    //--- Activate the newly added button.
    ButtonAdded.click(ButtonClickAction);
})();


function ButtonClickAction () {
    console.log("test");
    if(checkIfVisible(player)){
        colChat.removeClass("col-xs-4").addClass("col-xs-12").append(player.siblings("[data-tt-player-controls]"));
        player.css("display","none");
        ButtonAdded.text("Show Player");
    }else{
        player.parent("#player").append($('div[data-tt-player-controls]'));
        player.css("display","block");
        ButtonAdded.text("Hide Player");
        colChat.removeClass("col-xs-12").addClass("col-xs-4");
    }
}


function checkIfVisible (el) {
    if($(el).filter("[style='display: none;']").length===0){
        return true;
    }else{
        return false;
    }
}