Cytube Xaekai's Module Utility

Script closing and restoring video in CyTube (emerging text box)

// ==UserScript==
// @name        Cytube Xaekai's Module Utility
// @namespace   Script closing and restoring video in CyTube (emerging text box)
// @description Script closing and restoring video in CyTube (emerging text box)
// @author      Arg Anon (Original code by Xaekai)
// @version     1.2
// @homepageURL http://resources.pink.horse/js/module_layout.min.js
// @match       https://cytu.be/r/*
// @match       https://cytube.xyz/r/*
// @grant       none
// ==/UserScript==
$("#controlsrow").append('<textarea onClick="this.select();">"use strict";function removeUntilNext(){return socket.once("changeMedia",unremoveVideo),removeVideo()}function removeVideo(e){try{PLAYER.setVolume(0),"rv"===PLAYER.type&&killVideoUntilItIsDead($(PLAYER.player))}catch(e){console.log(e)}$("#videowrap").hide().attr("id","videowrap_disabled"),$("#ytapiplayer").attr("id","ytapiplayer_disabled"),$("#chatwrap").removeClass("col-lg-5 col-md-5").addClass("col-md-12"),$(\'a[onclick*="removeVideo"]\').attr("onclick","javascript:unremoveVideo(event)").text("Restore video"),e&&e.preventDefault()}function unremoveVideo(e){setTimeout(function(){PLAYER.setVolume(.33)},250),socket.emit("playerReady"),$("#chatwrap").addClass("col-lg-5 col-md-5").removeClass("col-md-12"),$("#videowrap_disabled").attr("id","videowrap").show(),$("#ytapiplayer_disabled").attr("id","ytapiplayer"),$(\'a[onclick*="removeVideo"]\').attr("onclick","javascript:removeVideo(event)").text("Remover"),e&&e.preventDefault(),CLIENT.removedOnGDrive&&(CLIENT.removedOnGDrive=!1,setTimeout(function(){$("#mediarefresh").click()},1e3))}function toggleChat(){if("main"===$("#chatwrap").parent().attr("id"))return $("#chatwrap").appendTo("#customSettingsStaging"),$("#videowrap").css("margin","0 auto"),$("#videowrap").css("float","initial"),$("#videowrap").css("margin-bottom","20px"),void $(\'a[onclick*="toggleChat"]\').text("Restore Chat");USEROPTS.layout.match(/synchtube/)?$("#chatwrap").appendTo("#main"):$("#chatwrap").prependTo("#main"),$("#videowrap").css("margin",""),$("#videowrap").css("float",""),$("#videowrap").css("margin-bottom",""),$(\'a[onclick*="toggleChat"]\').text("Remove Chat")}$(\'nav.navbar a[href="#"][onclick]\').attr("href","javascript:void(0)"),$(\'a[onclick*="removeUntilNext"]\').length||$(\'a[onclick*="removeVideo"]\').parent().parent().append($("<li>").append($("<a>").attr("href","javascript:void(0)").attr("onclick","javascript:removeUntilNext()").text("Remover hasta el sig."))),$(\'a[onclick*="toggleChat"]\').length||$(\'a[onclick*="chatOnly"]\').parent().after($("<li>").append($("<a>").attr("href","javascript:void(0)").attr("onclick","javascript:toggleChat()").text("Remove Chat")));$(\'\<button class="btn btn-sm btn-default" onclick="removeVideo()"\>Remover\</button\>\<button class="btn btn-sm btn-default" onclick="removeUntilNext()"\>Remover hasta sig.\</button\>\<button class="btn btn-sm btn-default" onclick="unremoveVideo()">Restaurar</button>\').appendTo("#leftcontrols");$("#controlsrow > textarea").remove();</textarea>');