Guest User

Cytube Cinema

a guest
Jun 3rd, 2021
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.96 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Cytube Cinema
  3. // @namespace https://cytu.be/
  4. // @version 0.1
  5. // @description Universal cinema script for cytube
  6. // @author You
  7. // @match https://cytu.be/r/*
  8. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12.  
  13. "use strict";
  14.  
  15. function removeUntilNext() {
  16. socket.once("changeMedia", unremoveVideo);
  17. return removeVideo()
  18. }
  19.  
  20. function removeVideo(event) {
  21. try {
  22. PLAYER.setVolume(0);
  23. if (PLAYER.type === "rv") {
  24. killVideoUntilItIsDead($(PLAYER.player))
  25. }
  26. } catch (e) {
  27. console.log(e)
  28. }
  29. CLIENT.removedOnGDrive = PLAYER.mediaType == "gd" ? true : false;
  30. $("#videowrap").hide().attr("id", "videowrap_disabled");
  31. $("#ytapiplayer").attr("id", "ytapiplayer_disabled");
  32. $("#chatwrap").removeClass("col-lg-5 col-md-5").addClass("col-md-12");
  33. $('a[onclick*="removeVideo"]').attr("onclick", "javascript:unremoveVideo(event)").text("Restore video");
  34. if (event) event.preventDefault()
  35. }
  36.  
  37. function unremoveVideo(event) {
  38. setTimeout(function() {
  39. PLAYER.setVolume(.33)
  40. }, 250);
  41. socket.emit("playerReady");
  42. $("#chatwrap").addClass("col-lg-5 col-md-5").removeClass("col-md-12");
  43. $("#videowrap_disabled").attr("id", "videowrap").show();
  44. $("#ytapiplayer_disabled").attr("id", "ytapiplayer");
  45. $('a[onclick*="removeVideo"]').attr("onclick", "javascript:removeVideo(event)").text("Remove video");
  46. if (event) event.preventDefault();
  47. if (CLIENT.removedOnGDrive) {
  48. CLIENT.removedOnGDrive = false;
  49. setTimeout(function() {
  50. $("#mediarefresh").click()
  51. }, 1e3)
  52. }
  53. }
  54.  
  55. function toggleChat() {
  56. if ($("#chatwrap").parent().attr("id") === "main") {
  57. $("#chatwrap").appendTo("#customSettingsStaging");
  58. $("#videowrap").css("margin", "0 auto");
  59. $("#videowrap").css("float", "initial");
  60. $("#videowrap").css("margin-bottom", "20px");
  61. $('a[onclick*="toggleChat"]').text("Restore Chat");
  62. return
  63. }
  64. if (!USEROPTS.layout.match(/synchtube/)) {
  65. $("#chatwrap").prependTo("#main")
  66. } else {
  67. $("#chatwrap").appendTo("#main")
  68. }
  69. $("#videowrap").css("margin", "");
  70. $("#videowrap").css("float", "");
  71. $("#videowrap").css("margin-bottom", "");
  72. $('a[onclick*="toggleChat"]').text("Remove Chat")
  73. }(function(CyTube_Layout) {
  74. return CyTube_Layout(window, document, window.jQuery, String)
  75. })(function(window, document, $, String, undefined) {
  76. $('nav.navbar a[href="#"][onclick]').attr("href", "javascript:void(0)");
  77. if (!$('a[onclick*="removeUntilNext"]').length) {
  78. $('a[onclick*="removeVideo"]').parent().parent().append($("<li>").append($("<a>").attr("href", "javascript:void(0)").attr("onclick", "javascript:removeUntilNext()").text("Remove Video Until Next")))
  79. }
  80. if (!$('a[onclick*="toggleChat"]').length) {
  81. $('a[onclick*="chatOnly"]').parent().after($("<li>").append($("<a>").attr("href", "javascript:void(0)").attr("onclick", "javascript:toggleChat()").text("Remove Chat")))
  82. }({
  83. host: "https://resources.pink.horse/css/",
  84. initialize: function() {
  85. if (CLIENT.cinemaMode) {
  86. return
  87. } else {
  88. CLIENT.cinemaMode = this
  89. }
  90. this.loadStyle()
  91. },
  92. createButtons: function() {
  93. $('a[onclick*="removeVideo"]').parent().parent().append($("<li>").append($("<a>").attr("href", "javascript:void(0)").attr("onclick", 'javascript:$("#cinematoggle").click()').text("Cinema Mode")));
  94. $('<div id="cinematoggle"><span class="glyphicon glyphicon-new-window "></span></div>').appendTo("body").click(function() {
  95. if (!$("body").hasClass("cinemachat")) {
  96. if ($("#userlist").is(":visible")) {
  97. $("#userlisttoggle").click()
  98. }
  99. }
  100. $("body").toggleClass("cinemachat");
  101. if ($("iframe[src*=livestream]").length) {
  102. PLAYER.mediaType = "";
  103. PLAYER.mediaId = "";
  104. socket.emit("playerReady")
  105. }
  106. handleWindowResize()
  107. })
  108. },
  109. createStyle: function(body) {
  110. this.style = $("<style>").attr("type", "text/css").attr("id", "cinemaStyle").html(body).appendTo("head")
  111. },
  112. handleCommand(message, target) {
  113. var params = message.substring(1).replace(/cinema ?/, "").trim();
  114. if (!params.length) {
  115. $("#cinematoggle").click()
  116. }
  117. if (params === "nopolls") {
  118. $("body").addClass("cinema-nopoll");
  119. $("#messagebuffer").trigger("whisper", `Cinema: Poll overlay disabled`);
  120. localStorage.setItem(`${CHANNEL.name}_cinemaHidePolls`, 1)
  121. }
  122. if (params === "polls") {
  123. $("body").removeClass("cinema-nopoll");
  124. $("#messagebuffer").trigger("whisper", `Cinema: Poll overlay enabled`);
  125. localStorage.setItem(`${CHANNEL.name}_cinemaHidePolls`, 0)
  126. }
  127. },
  128. registerCommand() {
  129. $("#chatline").trigger("registerCommand", ["cinema", this.handleCommand.bind(this)])
  130. },
  131. loadStyle: function() {
  132. $.ajax(this.host + "cinema.css?cache=" + Math.random()).done(data => {
  133. this.createButtons();
  134. this.createStyle(data);
  135. this.registerCommand();
  136. if (localStorage.getItem(`${CHANNEL.name}_cinemaHidePolls`) !== null) {
  137. if (parseInt(localStorage.getItem(`${CHANNEL.name}_cinemaHidePolls`))) {
  138. $("body").addClass("cinema-nopoll")
  139. }
  140. }
  141. })
  142. }
  143. }).initialize()
  144. });
Add Comment
Please, Sign In to add comment