Proxer-Kinomodus

Dieses Script fügt Proxer einen Kino-Modus-Button hinzu, der einen Kino-Modus startet

  1. // ==UserScript==
  2. // @name Proxer-Kinomodus
  3. // @namespace
  4. // @version 1.5 Theater-Modus-Ansicht zum Advent weniger weihnachtlich gemacht
  5. // @history 1.3
  6. // @description Dieses Script fügt Proxer einen Kino-Modus-Button hinzu, der einen Kino-Modus startet
  7. // @author Dominik Bissinger alias Nihongasuki
  8. // @include https://proxer.me/*
  9. // @include https://www.proxer.me/*
  10. // @include https://stream.proxer.me/embed*
  11. // @run-at document-start
  12. // @namespace
  13. // ==/UserScript==
  14.  
  15. //Starte die Funktion "addButton" beim Laden der Seite oder bearbeite das Player-Element, wenn es im Embed ausgeführt wird
  16. document.addEventListener('DOMContentLoaded', function(event) {
  17. if( window.location.href.indexOf( 'embed' ) > -1 ) {
  18. var style = document.getElementsByTagName( "style" )[0];
  19. var styleNormal = style.textContent;
  20.  
  21. window.addEventListener( "message", function( event ) {
  22. if( event.data.type === "TheaterOn" ) {
  23. var styleTheater = ".flowplayer { width: 100%; height: 100%; } #player_code { width: 100%; height: 100%; } .flowplayer video { height:"+event.data.height+"px !important; background-color: #000; }";
  24. style.textContent = styleTheater;
  25.  
  26. //Controls ausblenden
  27. document.getElementById( "psplayercontrols" ).style.display = "none";
  28.  
  29. //Curser ausblenden, wenn nicht bewegt wird
  30. var timeout;
  31. var hidden = false;
  32. document.addEventListener( "mousemove", function(event) {
  33. if( hidden ) {
  34. style.textContent = styleTheater;
  35. }
  36. clearTimeout(timeout);
  37. timeout = setTimeout(function(){
  38. style.textContent = styleTheater + " * { cursor: none; }";
  39. hidden = true;
  40. }, 2000);
  41. });
  42. } else {
  43. style.textContent = styleNormal;
  44. document.getElementById( "psplayercontrols" ).style.display = "";
  45. }
  46. });
  47.  
  48. return;
  49. }
  50.  
  51. $(document).ajaxComplete (function () {
  52. if (window.location.href.indexOf('watch') === -1 && window.location.href.indexOf('read') === -1) {
  53. document.getElementById('kinoButton').style.display = "none";
  54. document.getElementById('theaterButton').style.display = "none";
  55. document.getElementById('kinoDimmer').style.display = "none";
  56. document.getElementById('kinoDimmerBar').style.display = "none";
  57. document.getElementById('kinoStyle2').innerHTML = "";
  58. }else{
  59. document.getElementById('kinoButton').style.display = "block";
  60. };
  61. });
  62. addButton();
  63. });
  64.  
  65. //Fügt den Button "Kino" hinzu
  66. var t;
  67. var addButton = function() {
  68. if (window.location.href.indexOf('watch') > -1 || window.location.href.indexOf('read') > -1) {
  69. if (window.location.href.indexOf('forum') > -1) {
  70. return;
  71. };
  72. //Create Overall CSS and Additonal CSS; Apply Overall CSS
  73. var style1 = document.createElement("style");
  74. var style2 = document.createElement("style");
  75. style1.setAttribute("id","kinoStyle1");
  76. style2.setAttribute("id","kinoStyle2");
  77. document.head.appendChild(style1);
  78. document.head.appendChild(style2);
  79. document.getElementById('kinoStyle1').innerHTML = styleText1;
  80.  
  81. //Create Button
  82. var button = document.createElement("div");
  83. button.setAttribute("id","kinoButton");
  84. button.setAttribute("style","border-color: #777777; background-color: #5E5E5E; z-index: 2; bottom: 31px;");
  85. document.body.appendChild(button);
  86.  
  87. //Create Button Theatermodus
  88. var button2 = document.createElement( "div" );
  89. button2.setAttribute( "id", "theaterButton" );
  90. button2.setAttribute( "style", "border-color: #777777; background-color: #5E5E5E; z-index: 2;" );
  91. document.body.appendChild( button2 );
  92.  
  93. //Create Slider
  94. var dimmer = document.createElement("form");
  95. dimmer.setAttribute("id","kinoDimmerBar");
  96. dimmer.setAttribute("style","border-color: #777777; background-color: #5E5E5E; z-index: 2; min-width:200px; display:none;");
  97. document.body.appendChild(dimmer);
  98.  
  99. //Apply HTML
  100. document.getElementById('kinoDimmerBar').innerHTML = "<input type='range' id='opacity' name='opacity' min='0' max='1' step='0.01' value='0.5' style='width:100%; margin: 0; box-sizing: border-box;'>";
  101. document.getElementById('kinoButton').innerHTML = "<div id='kino' style='cursor: pointer; width: 100%; text-align: center;'>Kinomodus</div>";
  102. document.getElementById( "theaterButton" ).innerHTML = "<div id='theater' style='cursor: pointer; width: 100%; text-align: center;'>Theatermodus</div>";
  103.  
  104. //Get Opacity from local Storage and Set it as Value
  105. var value = localStorage.getItem('dimmer');
  106. if (value !== null) {
  107. document.getElementById('opacity').value = value;
  108. };
  109.  
  110. //Create Event Listeners
  111. document.getElementById('kinoButton').addEventListener("click",function () {
  112. trigger();
  113. });
  114. document.getElementById('opacity').addEventListener("input",function () {
  115. controlDimmer();
  116. });
  117. document.getElementById( "theaterButton" ).addEventListener( "click", function() {
  118. triggerTheater();
  119. });
  120.  
  121. //Set Style
  122. var color = "";
  123. var setStyle = function () {
  124. for (var i = 0; i < 4; i++) {
  125. if (color === "gray") {
  126. document.getElementById('kinoButton').style.backgroundColor = "#5E5E5E";
  127. document.getElementById('kinoButton').style.borderColor = "#777777";
  128. document.getElementById('kinoDimmerBar').style.backgroundColor = "#5E5E5E";
  129. document.getElementById('kinoDimmerBar').style.borderColor = "#777777";
  130. }else if (color === "black") {
  131. document.getElementById('kinoButton').style.backgroundColor = "#000";
  132. document.getElementById('kinoButton').style.borderColor = "#FFF";
  133. document.getElementById('kinoDimmerBar').style.backgroundColor = "#000";
  134. document.getElementById('kinoDimmerBar').style.borderColor = "#FFF";
  135. }else if (color === "old_blue") {
  136. document.getElementById('kinoButton').style.backgroundColor = "#F3FBFF";
  137. document.getElementById('kinoButton').style.borderColor = "#000";
  138. document.getElementById('kinoDimmerBar').style.backgroundColor = "#F3FBFF";
  139. document.getElementById('kinoDimmerBar').style.borderColor = "#000";
  140. }else{
  141. document.getElementById('kinoButton').style.backgroundColor = "#F3FBFF";
  142. document.getElementById('kinoButton').style.borderColor = "#000";
  143. document.getElementById('kinoDimmerBar').style.backgroundColor = "#F3FBFF";
  144. document.getElementById('kinoDimmerBar').style.borderColor = "#000";
  145. };
  146. };
  147. };
  148.  
  149. //Read Cookie
  150. var name = "style=";
  151. var cookieCheck = function () {
  152. var ca = document.cookie.split(';');
  153. for (var i = 0; i < ca.length; i++) {
  154. var c = ca[i];
  155. while (c.charAt(0) === " ") {
  156. c = c.substring(1);
  157. };
  158. if (c.indexOf(name) == 0) {
  159. color = c.substring(name.length,c.length);
  160. setStyle();
  161. };
  162. };
  163. if (color === "") {
  164. cookieCheck();
  165. };
  166. };
  167. cookieCheck();
  168.  
  169. //Create Dimming Layer
  170. var layer = document.createElement("div");
  171. layer.setAttribute("id","kinoDimmer");
  172. layer.setAttribute("style","background-color: #000; z-index:1; position: fixed; top: 0; left: 0; height: 100%; width: 100%; opacity: 0.5; display:none;");
  173. document.body.appendChild(layer);
  174.  
  175. //Set Opacity
  176. var opacity = document.getElementById('opacity');
  177. document.getElementById('kinoDimmer').style.opacity = opacity.value;
  178. };
  179. };
  180.  
  181. //Toggle Dimming on/off
  182. var trigger = function ( forceOff = false ) {
  183. var layer = document.getElementById('kinoDimmer');
  184. var bar = document.getElementById('kinoDimmerBar');
  185.  
  186. if( forceOff && layer.style.display === "none" ) {
  187. return;
  188. }
  189.  
  190. //Apply/Remove Additional CSS
  191. if (document.getElementById('kinoStyle2').innerHTML === styleText2) {
  192. document.getElementById('kinoStyle2').innerHTML = "";
  193. }else{
  194. document.getElementById('kinoStyle2').innerHTML = styleText2;
  195. };
  196.  
  197. //Enable/Disable Dimming by setting "display" style
  198. if (layer.style.display === "none") {
  199. bar.style.display = "inline";
  200. layer.style.display = "block";
  201. }else{
  202. layer.style.display = "none";
  203. bar.style.display = "none";
  204. };
  205. };
  206.  
  207. //Set Dimmer Opacity on input and save to local Storage
  208. var controlDimmer = function (event) {
  209. var opacity = document.getElementById('opacity');
  210. var dimmer = opacity.value;
  211. document.getElementById('kinoDimmer').style.opacity = dimmer;
  212. localStorage.setItem('dimmer', dimmer);
  213. };
  214.  
  215. //Start or end theater mode
  216. var triggerTheater = function() {
  217. if( window.location.href.indexOf('watch') === -1 ) {
  218. return;
  219. }
  220.  
  221. var btn = document.getElementById( "theaterButton" );
  222. var iframe = document.getElementsByTagName( "iframe" )[0];
  223. var ctn = iframe.contentWindow;
  224.  
  225. var navigation = document.getElementById("nav");
  226. var iframeStyle = "position: fixed; top:"+ navigation.offsetHeight +"px; left: 0px; z-index: 2;";
  227.  
  228. //Overkill HasClass xD
  229. if ( (" " + btn.className + " ").replace(/[\n\t]/g, " ").indexOf(" active ") > -1 ) {
  230. //Turn off
  231. iframe.height = 504;
  232. iframe.width = 720;
  233.  
  234. iframe.style = "";
  235.  
  236. var social = document.getElementsByClassName('shariff')[0];
  237. social.style.display = "";
  238.  
  239. var c1 = document.getElementById( "chatapp_toggle" );
  240. if( c1 !== null ) { c1.style.display = ""; }
  241. var c2 = document.getElementById( "chatapp_sidebar" );
  242. if( c2 !== null ) { c2.style.display = ""; }
  243.  
  244. document.getElementById( "kinoButton" ).style.display = "";
  245.  
  246. ctn.postMessage( { type: "TheaterOff" } , "*" );
  247. btn.className = "";
  248. } else {
  249. //Turn on
  250. iframe.height = window.innerHeight - navigation.offsetHeight;
  251. iframe.width = window.innerWidth;
  252.  
  253. iframe.style = iframeStyle;
  254.  
  255. var social = document.getElementsByClassName('shariff')[0];
  256. social.style.display = "none";
  257.  
  258. var c1 = document.getElementById( "chatapp_toggle" );
  259. if( c1 !== null ) { c1.style.display = "none"; }
  260. var c2 = document.getElementById( "chatapp_sidebar" );
  261. if( c2 !== null ) { c2.style.display = "none"; }
  262.  
  263. //Kinomodus ausschalten
  264. trigger( true );
  265.  
  266. document.getElementById( "kinoButton" ).style.display = "none";
  267.  
  268. ctn.postMessage( { type: "TheaterOn", height: iframe.height } , "*" );
  269. btn.className = "active";
  270. }
  271. }
  272.  
  273. //Overall CSS
  274. var styleText1 = "\
  275. #kinoButton, #theaterButton {\
  276. height: 20px; \
  277. width: 105px; \
  278. display: inline; \
  279. position: fixed; \
  280. bottom: 0px; \
  281. left: 0px; \
  282. border-right: 1px solid; \
  283. border-top: 1px solid; \
  284. padding: 5px; \
  285. }\
  286. \
  287. #kinoDimmerBar {\
  288. height: 20px; \
  289. display: inline; \
  290. position: fixed; \
  291. bottom: 0px;\
  292. margin: auto 40%;\
  293. left: 0;\
  294. right: 0;\
  295. border-right: 1px solid;\
  296. border-left: 1px solid\
  297. border-top: 1px solid; \
  298. padding: 5px; \
  299. border-radius: 10px 10px 0 0;\
  300. }\
  301. #theaterButton.active {\
  302. top: 50px; left: 5px; width: auto !important; background-color: #333 !important; border: 0;\
  303. }\
  304. ";
  305.  
  306. //Additional CSS
  307. var styleText2 = "\
  308. .wStream {\
  309. z-index: 2;\
  310. position: relative;\
  311. }\
  312. \
  313. .wMirror {\
  314. z-index: 2;\
  315. position: relative;\
  316. }\
  317. \
  318. .menu {\
  319. z-index: 2;\
  320. position: relative;\
  321. }\
  322. \
  323. #reader {\
  324. z-index: 2;\
  325. position: relative;\
  326. }\
  327. \
  328. #breadcrumb {\
  329. z-index: 2;\
  330. position: relative;\
  331. }\
  332. \
  333. #navigation {\
  334. z-index: 2;\
  335. position: relative;\
  336. }\
  337. ";