Pr0gramm.com by Seglor

Improve das Pr0gramm

  1.  
  2. // ==UserScript==
  3. // @name Pr0gramm.com by Seglor
  4. // @namespace http://userscripts.org/scripts/show/486514
  5. // @description Improve das Pr0gramm
  6. // @include http://pr0gramm.com/*
  7. // @version 1.4
  8. // @grant none
  9. // @require http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js
  10. // ==/UserScript==
  11. (function() {
  12. var wheelLast = 0;
  13. var design = '1';
  14. /****/// CSS und Kommentarbox links
  15. var css = '#upload-form input[type="submit"] { position:relative; top: 290px; left: 350px; }'+
  16. '.tags { padding-left:3px; } div.item-tags { padding: 4px 0 8px 10% !important;} div.tagsinput { position:absolute; } input[value="Tags speichern"],input[value="Abbrechen"] { float:right; }'+
  17. '.comments-large-rectangle { height:auto; position:px; width:280px; right:0;top:0; position:relative; } .comments-large-rectangle > a > img { width: 280px; } #footer-links {z-index:200;} div.item-tags { padding: 4px 0 8px 20%;} div.item-info { text-align:center;} #zahlbreite { color: #FFFFFF; margin: 27px 0 0 15px; float: left;} div.stream-row { clear:right; }'+
  18. '.ui-widget-content {border: 1px solid #AAAAAA;color: #222222;}'+
  19. '.ui-slider { position: relative; text-align: left;}'+
  20. '.ui-slider-horizontal { height: 0.8em;}'+
  21. '.ui-corner-all { border-radius: 4px;}'+
  22. '.ui-slider-horizontal .ui-slider-range { height: 100%; top: 0;}'+
  23. '.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default {'+
  24. 'background: #E6E6E6; border: 1px solid #D3D3D3; color: #555555; font-weight: normal;}'+
  25. '.ui-slider-horizontal .ui-slider-handle { margin-left: -0.6em; top: -0.3em;}'+
  26. '.ui-slider .ui-slider-handle { cursor: default; height: 1.2em; position: absolute; width: 1.2em; z-index: 2;}'+
  27. '#slider { float: left; clear: left; width: 300px; margin: 30px 15px 5px; }#slider .ui-slider-range { background: #EE4D2E; } #slider .ui-slider-handle { border-color: #EE4D2E; }'+
  28. '@media screen and (max-width:1400px){ div#head {margin: 0 0 0 25% !important;} div#page {margin: 0 0 0 25% !important;} .item-comments {width: 24% !important;}} #head { z-index:200; } #stream-next, #stream-prev { z-index:122; } .item-image{max-height:460px;} .item-comments {\n position: fixed !important;\n top: 0;\n left: 0;\n \n width: 300px;\n height: 100vh;\n max-height: 100vh;\n overflow-y: auto;\n overflow-x: hidden;\n}\n \n.item-comments textarea.comment {\n resize: none;\n}\n \ndiv.comment-box > div.comment-box {\n background: none repeat scroll 0 0 rgba(0, 0, 0, 0.1);\n padding: 0 0 0 6px;\n}';
  29. if (typeof GM_addStyle != "undefined") {
  30. GM_addStyle(css);
  31. } else if (typeof PRO_addStyle != "undefined") {
  32. PRO_addStyle(css);
  33. } else if (typeof addStyle != "undefined") {
  34. addStyle(css);
  35. } else {
  36. var node = document.createElement("style");
  37. node.type = "text/css";
  38. node.appendChild(document.createTextNode(css));
  39. var heads = document.getElementsByTagName("head");
  40. if (heads.length > 0) {
  41. heads[0].appendChild(node);
  42. } else {
  43. document.documentElement.appendChild(node);
  44. }
  45. }
  46. $(function()
  47. {
  48. $('.item-comments').jScrollPane();
  49. });
  50. function update(e) {
  51. // nur in Uploads
  52. if ($("div.item-container").length) {
  53. //$('.item-container').hide();
  54. $('.item-container').fadeIn();
  55. $(".item-container").attr( 'id', 'bild' );
  56. var positionX = 0,
  57. positionY = 0;
  58. var pageElement = document.getElementById('bild');
  59. positionX += pageElement.offsetLeft;
  60. positionY += pageElement.offsetTop;
  61. //alert($(window).height());
  62. window.scrollTo(positionX, positionY-130);
  63. }
  64. }
  65. setInterval(function() {
  66. if ($('.item-image').length) {
  67. /*
  68. var vids = document.getElementsByTagName("video");
  69. for (i = 0; i < vids.length; i++) vids[i].setAttribute("controls", "true");
  70. */
  71. // + bei resized Bildern
  72. if (!$('.item-fullsize-link').length) {
  73. var imgu = document.getElementsByClassName('item-image')[0];
  74. if (imgu.naturalHeight > 460) {
  75. var link = imgu.getAttribute('src');
  76. $('.item-image-wrapper').append('<a class="item-fullsize-link" target="_blank" href="'+link+'" style="">+</a>');
  77. }
  78. }
  79. var stil = document.getElementsByTagName('html')[0];
  80. stil.style.overflow='hidden';
  81. $(".item-container").attr( 'id', 'bild' );
  82. var positionX = 0,
  83. positionY = 0;
  84. var pageElement = document.getElementById('bild');
  85. positionX += pageElement.offsetLeft;
  86. positionY += pageElement.offsetTop;
  87. //alert($(window).height());
  88. window.scrollTo(positionX, positionY-130);
  89. }else{
  90. var stil = document.getElementsByTagName('html')[0];
  91. stil.style.overflow='visible';
  92. }
  93. }, 200);
  94. // Breiteneinstellung in Settings
  95. function refreshdas() {
  96. if (design == '1') {
  97. var weite = $("#slider").slider("value");
  98. $("#page").css( "width", weite+"px");
  99. $("#head").css( "width", weite+"px");
  100. var proreihe = weite/128;
  101. var treshold = 0.55* $(window).width();
  102. document.getElementById("zahlbreite").innerHTML = weite+' Pixel';
  103. if (weite > treshold) {
  104. $(".item-comments").css( "top", "50px");
  105. }else{
  106. $(".item-comments").css( "top", "0");
  107. }
  108. }
  109. }
  110. function changedesign() {
  111. if (document.getElementById("design") && design == '1') {
  112. var elem = document.getElementById('design');
  113. elem.parentNode.removeChild(elem);
  114. }else{
  115. var css = '#page { width: 100% !important }'+
  116. '#head { width: 100% !important }'+
  117. '.comment-foot { width: 260px !important }'+
  118. '.item-comments { top: 48px !important; width: 312px !important;}' +
  119. '.item-container-content { margin-top: 20px !important }'+
  120. 'div.item-container { background: rgba(0, 0, 0, 0.9) !important; position: absolute !important; height: 100% !important; width: 100% !important; }'+
  121. '.stream-row { clear: none !important; margin-left: 0 !important; }'+
  122. '#main-view { max-width: 100% !important; width: 100% !important; }'+
  123. '.user-info { margin: 20px 30px 0 0 !important; }'+
  124. '#pr0gramm-logo { margin-left: 15px !important; }'+
  125. '.item-pointer { display: none !important; }'+
  126. 'div.item-tags { padding: 4px 0 8px 20% !important;}'+
  127. 'div.item-vote { left: 345px;)';
  128. if (!document.getElementById("design") && design == '2') {
  129. var node = document.createElement("style");
  130. node.type = "text/css";
  131. node.id = "design";
  132. node.appendChild(document.createTextNode(css));
  133. var heads = document.getElementsByTagName("head");
  134. if (heads.length > 0) {
  135. heads[0].appendChild(node);
  136. } else {
  137. document.documentElement.appendChild(node);
  138. }
  139. }
  140. }
  141. }
  142. // Settings öffnen
  143. $('#settings-link').click(function() {
  144. setInterval(function () {
  145. if ($("div.overlay-tabs").length && !$("#settings-optik").length) {
  146. $('div.overlay-tabs').append('<span id="settings-optik" class="link tab">Optik</span>');
  147. }
  148. var valus = parseInt(document.getElementById("page").style.width);
  149. $( "#slider" ).slider( "value", valus );
  150. $('span#settings-optik').click(function() {
  151. loaded = false;
  152. $('#settings-optik').attr('class', 'link tab active');
  153. $('div.overlay-content:eq(1)').attr('id', 'cont');
  154. document.getElementById("cont").innerHTML = '<div id="slider"></div><span id="zahlbreite" style="color:#fff;">788</span>'+
  155. '<div style="margin: 50px;"><br><br>Design wechseln: <input type="button" id="buttons1" value="Design 1"> <input type="button" id="buttons2" value="Design 2"></div>';
  156. $('#buttons1').click(function() {
  157. design = '1';
  158. changedesign();
  159. $('#slider').slider('enable');
  160. $('#slider').slider({ disabled: "false" });
  161. });
  162. $('#buttons2').click(function() {
  163. design = '2';
  164. changedesign();
  165. $('#slider').slider('disable');
  166. $('#slider').slider({ disabled: "true" });
  167. });
  168. $('#slider').slider({
  169. orientation: "horizontal",
  170. range: "min",
  171. max: $(window).width(),
  172. min: 788,
  173. value: valus,
  174. slide: refreshdas,
  175. change: refreshdas
  176. });
  177. });
  178. }, 300);
  179. });
  180. $('#stream-next').click(function() {
  181. update();
  182. });
  183. $('#stream-prev').click(function() {
  184. update();
  185. });
  186. // Space Vergrößerung und links/rechts Bildwechsel
  187. document.addEventListener("keydown", keydown, false);
  188. var spacepressed = false;
  189. function keydown(event) {
  190. if (event.keyCode == '37' || event.keyCode == '39') {
  191. update();
  192. }else if (event.keyCode == '32') {
  193. // falls textarea aktiv
  194. var el = document.activeElement;
  195. if (el && (el.tagName.toLowerCase() == 'input' && el.type == 'text' || el.tagName.toLowerCase() == 'textarea')) {
  196. return;
  197. }
  198. // Bild mit Space vergrößern
  199. if ($('.item-image').length != 0) {
  200. event.preventDefault();
  201. event.stopPropagation();
  202. if (!spacepressed && $("div.item-container").length) {
  203. $(".item-image").css( 'max-height', '100%' );
  204. spacepressed = true;
  205. }else{
  206. $(".item-image").css( 'max-height', '460px' );
  207. spacepressed = false;
  208. }
  209. }
  210. }else if (event.keyCode == '68') {
  211. //$('#stream-next').click();
  212. }else if (event.keyCode == '65') {
  213. //$('#stream-prev').click();
  214. }
  215. }
  216. // Image Scroll
  217. // Firefox
  218. document.addEventListener("DOMMouseScroll", handleWheel, false);
  219. // IE9, Chrome, Safari, Opera
  220. document.addEventListener("mousewheel", handleWheel, false);
  221. // IE 6/7/8
  222. if(!document.addEventListener) {
  223. document.attachEvent("onmousewheel", handleWheel);
  224. }
  225. function handleWheel(event) {
  226. if ($("div.item-container").length) {
  227. var coms = document.getElementsByClassName("item-comments");
  228. if (coms.length != 1 || isHover(coms[0])) {
  229. return;
  230. }
  231. event.preventDefault();
  232. event.stopPropagation();
  233. event.returnValue=false;
  234. var wheelWait = 200;
  235. var time = (new Date()).getTime();
  236. var msec = time - wheelLast;
  237. wheelLast = time;
  238. if (msec < wheelWait) {
  239. return;
  240. }
  241. var delta = 0;
  242. if (!event)
  243. event = window.event;
  244. if (event.wheelDelta) {
  245. delta = event.wheelDelta/120;
  246. } else if (event.detail) {
  247. delta = -event.detail/3;
  248. }
  249. if(delta<0){
  250. $('#stream-next').click();
  251. }else{
  252. $('#stream-prev').click();
  253. }
  254. update();
  255. }
  256. }
  257. function isHover(e) {
  258. if (!e) return false;
  259. return (e.parentElement.querySelector(':hover') === e);
  260. }
  261. })();
  262.